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.
- INFORMATION_SCHEMA.CHECK_CONSTRAINTS
- INFORMATION_SCHEMA.COLUMN_DOMAIN_USAGE
- INFORMATION_SCHEMA.COLUMN_PRIVILEGES
- INFORMATION_SCHEMA.COLUMNS
- INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
- INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE
- INFORMATION_SCHEMA.DOMAIN_CONSTRAINTS
- INFORMATION_SCHEMA.DOMAINS
- INFORMATION_SCHEMA.KEY_COLUMN_USAGE
- INFORMATION_SCHEMA.PARAMETERS
- INFORMATION_SCHEMA.REFERENCIAL_CONSTRAINTS
- INFORMATION_SCHEMA.ROUTINE_COLUMNS
- INFORMATION_SCHEMA.ROUTINES
- INFORMATION_SCHEMA.SCHEMA_DATA
- INFORMATION_SCHEMA.TABLE_CONSTRAINTS
- INFORMATION_SCHEMA.TABLE_PRIVILEGES
- INFORMATION_SCHEMA.TABLES
- INFORMATION_SCHEMA.VIEW_COLUMN_USAGE
- INFORMATION_SCHEMA.VIEW_TABLE_USAGE
- 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.
精彩评论