Oracle和SQL Server保留的关键字

时间:2013-05-27 09:08:54

标签: sql-server oracle select keyword reserved

我需要一个Oracle Database 10g和SQL Server 2008保留关键字的列表。我的应用程序执行DDL语句,因此我需要针对保留字验证输入的表,列名等。我知道我可以复制并粘贴网站上的文字: Oracle 10gSQL Server 2008

但我更喜欢SQL命令,以便可以动态加载关键字。对于oracle,存在命令:

SELECT KEYWORD FROM V$RESERVED_WORDS
ORDER BY KEYWORD ASC
;

这个命令检索1146个单词很奇怪,但在线列表只包含456个单词!有原因吗?是否还有可用于SQL Server数据库的命令?

2 个答案:

答案 0 :(得分:2)

通过这种方式,您可以获得MS SQL Server的所有关键字 -

SELECT t.keyword
FROM (
    VALUES 
        ('ABSOLUTE'),('ACTION'),('ADA'),('ADD'),
        ('ADMIN'),('AFTER'),('AGGREGATE'),('ALIAS'),
        ('ALL'),('ALLOCATE'),('ALTER'),('AND'),
        ('ANY'),('ARE'),('ARRAY'),('AS'),
        ('ASC'),('ASENSITIVE'),('ASSERTION'),('ASYMMETRIC'),
        ('AT'),('ATOMIC'),('AUTHORIZATION'),('AVG'),
        ('BACKUP'),('BEFORE'),('BEGIN'),('BETWEEN'),
        ('BINARY'),('BIT'),('BIT_LENGTH'),('BLOB'),
        ('BOOLEAN'),('BOTH'),('BREADTH'),('BREAK'),
        ('BROWSE'),('BULK'),('BY'),('CALL'),
        ('CALLED'),('CARDINALITY'),('CASCADE'),('CASCADED'),
        ('CASE'),('CAST'),('CATALOG'),('CHAR'),
        ('CHAR_LENGTH'),('CHARACTER'),('CHARACTER_LENGTH'),
        ('CHECK'),('CHECKPOINT'),('CLASS'),('CLOB'),('CLOSE'),
        ('CLUSTERED'),('COALESCE'),('COLLATE'),('COLLATION'),('COLLECT'),('COLUMN'),('COMMIT'),
        ('COMPLETION'),('COMPUTE'),('CONDITION'),('CONNECT'),
        ('CONNECTION'),('CONSTRAINT'),('CONSTRAINTS'),('CONSTRUCTOR'),
        ('CONTAINS'),('CONTAINSTABLE'),('CONTINUE'),('CONVERT'),('CORR'),
        ('CORRESPONDING'),('COUNT'),('COVAR_POP'),('COVAR_SAMP'),('CREATE'),
        ('CROSS'),('CUBE'),('CUME_DIST'),('CURRENT'),('CURRENT_CATALOG'),
        ('CURRENT_DATE'),('CURRENT_DEFAULT_TRANSFORM_GROUP'),('CURRENT_PATH'),('CURRENT_ROLE'),('CURRENT_SCHEMA'),
        ('CURRENT_TIME'),('CURRENT_TIMESTAMP'),('CURRENT_TRANSFORM_GROUP_FOR_TYPE'),('CURRENT_USER'),('CURSOR'),('CYCLE'),
        ('DATA'),('DATABASE'),('DATE'),('DAY'),('DBCC'),('DEALLOCATE'),('DEC'),('DECIMAL'),('DECLARE'),
        ('DEFAULT'),('DEFERRABLE'),('DEFERRED'),('DELETE'),('DENY'),('DEPTH'),('DEREF'),('DESC'),('DESCRIBE'),
        ('DESCRIPTOR'),('DESTROY'),('DESTRUCTOR'),('DETERMINISTIC'),('DIAGNOSTICS'),('DICTIONARY'),('DISCONNECT'),('DISK'),
        ('DISTINCT'),('DISTRIBUTED'),('DOMAIN'),('DOUBLE'),('DROP'),('DUMP'),('DYNAMIC'),('EACH'),('ELEMENT'),
        ('ELSE'),('END'),('END-EXEC'),('EQUALS'),('ERRLVL'),('ESCAPE'),('EVERY'),('EXCEPT'),
        ('EXCEPTION'),('EXEC'),('EXECUTE'),('EXISTS'),('EXIT'),('EXTERNAL'),
        ('EXTRACT'),('FALSE'),('FETCH'),('FILE'),('FILLFACTOR'),('FILTER'),('FIRST'),('FLOAT'),('FOR'),
        ('FOREIGN'),('FORTRAN'),('FOUND'),('FREE'),('FREETEXT'),('FREETEXTTABLE'),('FROM'),('FULL'),('FULLTEXTTABLE'),('FUNCTION'),
        ('FUSION'),('GENERAL'),('GET'),('GLOBAL'),('GO'),('GOTO'),('GRANT'),('GROUP'),('GROUPING'),('HAVING'),
        ('HOLD'),('HOLDLOCK'),('HOST'),('HOUR'),('IDENTITY'),('IDENTITY_INSERT'),('IDENTITYCOL'),('IF'),
        ('IGNORE'),('IMMEDIATE'),('IN'),('INCLUDE'),('INDEX'),('INDICATOR'),('INITIALIZE'),('INITIALLY'),('INNER'),('INOUT'),
        ('INPUT'),('INSENSITIVE'),('INSERT'),('INT'),('INTEGER'),('INTERSECT'),('INTERSECTION'),
        ('INTERVAL'),('INTO'),('IS'),('ISOLATION'),('ITERATE'),('JOIN'),('KEY'),('KILL'),('LANGUAGE'),
        ('LARGE'),('LAST'),('LATERAL'),('LEADING'),('LEFT'),('LESS'),('LEVEL'),('LIKE'),('LIKE_REGEX'),('LIMIT'),('LINENO'),('LN'),
        ('LOAD'),('LOCAL'),('LOCALTIME'),('LOCALTIMESTAMP'),('LOCATOR'),('LOWER'),
        ('MAP'),('MATCH'),('MAX'),('MEMBER'),('MERGE'),('METHOD'),('MIN'),('MINUTE'),('MOD'),('MODIFIES'),('MODIFY'),('MODULE'),
        ('MONTH'),('MULTISET'),('NAMES'),('NATIONAL'),('NATURAL'),('NCHAR'),('NCLOB'),('NEW'),('NEXT'),('NO'),('NOCHECK'),
        ('NONCLUSTERED'),('NONE'),('NORMALIZE'),('NOT'),('NULL'),('NULLIF'),
        ('NUMERIC'),('OBJECT'),('OCCURRENCES_REGEX'),('OCTET_LENGTH'),('OF'),('OFF'),('OFFSETS'),('OLD'),('ON'),('ONLY'),('OPEN'),
        ('OPENDATASOURCE'),('OPENQUERY'),('OPENROWSET'),('OPENXML'),('OPERATION'),('OPTION'),('OR'),
        ('ORDER'),('ORDINALITY'),('OUT'),('OUTER'),('OUTPUT'),
        ('OVER'),('OVERLAPS'),('OVERLAY'),('PAD'),('PARAMETER'),
        ('PARAMETERS'),('PARTIAL'),('PARTITION'),('PASCAL'),('PATH'),
        ('PERCENT'),('PERCENT_RANK'),('PERCENTILE_CONT'),('PERCENTILE_DISC'),('PIVOT'),('PLAN'),('POSITION'),
        ('POSITION_REGEX'),('POSTFIX'),('PRECISION'),('PREFIX'),('PREORDER'),('PREPARE'),('PRESERVE'),
        ('PRIMARY'),('PRINT'),('PRIOR'),
        ('PRIVILEGES'),('PROC'),('PROCEDURE'),('PUBLIC'),('RAISERROR'),
        ('RANGE'),('READ'),('READS'),('READTEXT'),
        ('REAL'),('RECONFIGURE'),('RECURSIVE'),('REF'),('REFERENCES'),('REFERENCING'),('REGR_AVGX'),('REGR_AVGY'),('REGR_COUNT'),
        ('REGR_INTERCEPT'),('REGR_R2'),('REGR_SLOPE'),('REGR_SXX'),('REGR_SXY'),('REGR_SYY'),('RELATIVE'),
        ('RELEASE'),('REPLICATION'),('RESTORE'),('RESTRICT'),
        ('RESULT'),('RETURN'),('RETURNS'),('REVERT'),
        ('REVOKE'),('RIGHT'),('ROLE'),('ROLLBACK'),('ROLLUP'),('ROUTINE'),
        ('ROW'),('ROWCOUNT'),('ROWGUIDCOL'),('ROWS'),('RULE'),('SAVE'),('SAVEPOINT'),('SCHEMA'),('SCOPE'),
        ('SCROLL'),('SEARCH'),('SECOND'),('SECTION'),('SECURITYAUDIT'),('SELECT'),('SENSITIVE'),
        ('SEQUENCE'),('SESSION'),('SESSION_USER'),
        ('SET'),('SETS'),('SETUSER'),('SHUTDOWN'),('SIMILAR'),('SIZE'),('SMALLINT'),('SOME'),
        ('SPACE'),('SPECIFIC'),('SPECIFICTYPE'),('SQL'),('SQLCA'),('SQLCODE'),('SQLERROR'),
        ('SQLEXCEPTION'),('SQLSTATE'),('SQLWARNING'),('START'),('STATE'),('STATEMENT'),
        ('STATIC'),('STATISTICS'),('STDDEV_POP'),('STDDEV_SAMP'),('STRUCTURE'),('SUBMULTISET'),
        ('SUBSTRING'),('SUBSTRING_REGEX'),('SUM'),('SYMMETRIC'),('SYSTEM'),('SYSTEM_USER'),
        ('TABLE'),('TABLESAMPLE'),('TEMPORARY'),('TERMINATE'),('TEXTSIZE'),('THAN'),('THEN'),('TIME'),
        ('TIMESTAMP'),('TIMEZONE_HOUR'),('TIMEZONE_MINUTE'),('TO'),('TOP'),
        ('TRAILING'),('TRAN'),('TRANSACTION'),('TRANSLATE'),('TRANSLATE_REGEX'),('TRANSLATION'),
        ('TREAT'),('TRIGGER'),('TRIM'),('TRUE'),('TRUNCATE'),('TSEQUAL'),
        ('UESCAPE'),('UNDER'),('UNION'),('UNIQUE'),('UNKNOWN'),('UNNEST'),('UNPIVOT'),('UPDATE'),('UPDATETEXT'),
        ('UPPER'),('USAGE'),('USE'),('USER'),('USING'),('VALUE'),
        ('VALUES'),('VAR_POP'),('VAR_SAMP'),('VARCHAR'),('VARIABLE'),
        ('VARYING'),('VIEW'),('WAITFOR'),('WHEN'),('WHENEVER'),
        ('WHERE'),('WHILE'),('WIDTH_BUCKET'),('WINDOW'),('WITH'),('WITHIN'),('WITHOUT'),('WORK'),
        ('WRITE'),('WRITETEXT'),('XMLAGG'),('XMLATTRIBUTES'),
        ('XMLBINARY'),('XMLCAST'),('XMLCOMMENT'),('XMLCONCAT'),('XMLDOCUMENT'),
        ('XMLELEMENT'),('XMLEXISTS'),('XMLFOREST'),('XMLITERATE'),('XMLNAMESPACES'),
        ('XMLPARSE'),('XMLPI'),('XMLQUERY'),('XMLSERIALIZE'),('XMLTABLE'),
        ('XMLTEXT'),('XMLVALIDATE'),('YEAR'),('ZONE')
) AS t(keyword)

答案 1 :(得分:0)

我不能保证其可信度和完整性,但多年来我一直赞赏Pete Freitag的“SQL保留字检查器”作为一个快速而方便的参考(并牢记交叉兼容性问题): http://www.petefreitag.com/tools/sql_reserved_words_checker/