SQL Server可用关键字列表

时间:2018-01-07 15:02:20

标签: sql-server

似乎我无法在SQL Server中使用SHOW命令,如SHOW COLUMNS FROM...SHOW TABLES

是否有某个列表显示所有可用的命令,所以我知道我可以使用什么?

3 个答案:

答案 0 :(得分:0)

获取表格和列信息

Select * From INFORMATION_SCHEMA.COLUMNS

Select * From INFORMATION_SCHEMA.Tables

保留字

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql

从验证例程中删除并修改

Declare @Reserved table (Word varchar(100))
Insert Into @Reserved values
('ADD'),('ALL'),('ALTER'),('AND'),('ANY'),('AS'),('ASC'),('AUTHORIZATION'),('BACKUP'),('BEGIN'),('BETWEEN'),('BREAK'),('BROWSE'),('BULK'),('BY'),
('CASCADE'),('CASE'),('CHECK'),('CHECKPOINT'),('CLOSE'),('CLUSTERED'),('COALESCE'),('COLLATE'),('COLUMN'),('COMMIT'),('COMPUTE'),('CONSTRAINT'),
('CONTAINS'),('CONTAINSTABLE'),('CONTINUE'),('CONVERT'),('CREATE'),('CROSS'),('CURRENT'),('CURRENT_DATE'),('CURRENT_TIME'),('CURRENT_TIMESTAMP'),
('CURRENT_USER'),('CURSOR'),('DATABASE'),('DBCC'),('DEALLOCATE'),('DECLARE'),('DEFAULT'),('DELETE'),('DENY'),('DESC'),('DISK'),('DISTINCT'),
('DISTRIBUTED'),('DOUBLE'),('DROP'),('DUMP'),('ELSE'),('END'),('ERRLVL'),('ESCAPE'),('EXCEPT'),('EXEC'),('EXECUTE'),('EXISTS'),('EXIT'),('EXTERNAL'),
('FETCH'),('FILE'),('FILLFACTOR'),('FOR'),('FOREIGN'),('FREETEXT'),('FREETEXTTABLE'),('FROM'),('FULL'),('FUNCTION'),('GOTO'),('GRANT'),('GROUP'),
('HAVING'),('HOLDLOCK'),('IDENTITY'),('IDENTITY_INSERT'),('IDENTITYCOL'),('IF'),('IN'),('INDEX'),('INNER'),('INSERT'),('INTERSECT'),('INTO'),('IS'),
('JOIN'),('KEY'),('KILL'),('LEFT'),('LIKE'),('LINENO'),('LOAD'),('MERGE'),('NATIONAL'),('NOCHECK'),('NONCLUSTERED'),('NOT'),('NULL'),('NULLIF'),
('OF'),('OFF'),('OFFSETS'),('ON'),('OPEN'),('OPENDATASOURCE'),('OPENQUERY'),('OPENROWSET'),('OPENXML'),('OPTION'),('OR'),('ORDER'),('OUTER'),('OVER'),
('PERCENT'),('PIVOT'),('PLAN'),('PRECISION'),('PRIMARY'),('PRINT'),('PROC'),('PROCEDURE'),('PUBLIC'),('RAISERROR'),('READ'),('READTEXT'),('RECONFIGURE'),
('REFERENCES'),('REPLICATION'),('RESTORE'),('RESTRICT'),('RETURN'),('REVERT'),('REVOKE'),('RIGHT'),('ROLLBACK'),('ROWCOUNT'),('ROWGUIDCOL'),('RULE'),
('SAVE'),('SCHEMA'),('SECURITYAUDIT'),('SELECT'),('SEMANTICKEYPHRASETABLE'),('SEMANTICSIMILARITYDETAILSTABLE'),('SEMANTICSIMILARITYTABLE'),('SESSION_USER'),
('SET'),('SETUSER'),('SHUTDOWN'),('SOME'),('STATISTICS'),('SYSTEM_USER'),('TABLE'),('TABLESAMPLE'),('TEXTSIZE'),('THEN'),('TO'),('TOP'),('TRAN'),('TRANSACTION'),
('TRIGGER'),('TRUNCATE'),('TRY_CONVERT'),('TSEQUAL'),('UNION'),('UNIQUE'),('UNPIVOT'),('UPDATE'),('UPDATETEXT'),('USE'),('USER'),('VALUES'),('VARYING'),
('VIEW'),('WAITFOR'),('WHEN'),('WHERE'),('WHILE'),('WITH'),('WITHIN GROUP'),('WRITETEXT')

Select A.* 
 From  INFORMATION_SCHEMA.COLUMNS  A
 Join  @Reserved 
   on  Column_Name = Word

答案 1 :(得分:0)

ISO标准是查询INFORMATION_SCHEMA views元数据信息。更简洁的方法是在SQL Server中列出表/视图列sp_help

EXEC sp_help 'your-object-name-here';

在SSMS中,您可以在查询窗口中突出显示所需的对象名称,然后按ALT + F1以对该对象执行sp_help。使用SQL Operations Studio,ALT-F12将查看对象定义。

答案 2 :(得分:0)

SELECT Distinct TABLE_NAME FROM information_schema.TABLES

希望这对列有帮助并且类似。另外,到目前为止我还没有看到任何这样的清单,但是一旦我看到它,肯定会在将来添加。