开发者

sql server compatible queries for given oracle queries

I want Microsoft SQL server queries corresponding to the following Oracle que开发者_开发问答ries

//get schema of a table
desc tablename;

//get the names of all tables
select * from tab;


You have access to that info through metadata tables. Check this link out.

INFORMATION_SCHEMA.Tables -> gives you access to table names

INFORMATION_SCHEMA.Columns -> gives you access to column names

Here is another link with a complete list of catalog tables.

  1. INFORMATION_SCHEMA.CHECK_CONSTRAINTS
  2. INFORMATION_SCHEMA.COLUMN_DOMAIN_USAGE
  3. INFORMATION_SCHEMA.COLUMN_PRIVILEGES
  4. INFORMATION_SCHEMA.COLUMNS
  5. INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
  6. INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE
  7. INFORMATION_SCHEMA.DOMAIN_CONSTRAINTS
  8. INFORMATION_SCHEMA.DOMAINS
  9. INFORMATION_SCHEMA.KEY_COLUMN_USAGE
  10. INFORMATION_SCHEMA.PARAMETERS
  11. INFORMATION_SCHEMA.REFERENCIAL_CONSTRAINTS
  12. INFORMATION_SCHEMA.ROUTINE_COLUMNS
  13. INFORMATION_SCHEMA.ROUTINES
  14. INFORMATION_SCHEMA.SCHEMA_DATA
  15. INFORMATION_SCHEMA.TABLE_CONSTRAINTS
  16. INFORMATION_SCHEMA.TABLE_PRIVILEGES
  17. INFORMATION_SCHEMA.TABLES
  18. INFORMATION_SCHEMA.VIEW_COLUMN_USAGE
  19. INFORMATION_SCHEMA.VIEW_TABLE_USAGE
  20. INFORMATION_SCHEMA.VIEWS

Keep in mind though, that you will probably need special permission to access those tables/views.

The other thing you might try as an alternative is using ODBC, Java, .NET or any other programming language or library to access metadata information. They have complete access to that through their APIs.


Table desctiption:

sp_help table_name

All tables in the current database:

select * from sysobjects where xtype='U'

And you can use sysobjects, syscolumns, sysindexes etc. tables to get the information about database structure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜