Tuesday, June 23, 2009

SQL Server : Information Schema

In my previous post, explained how to get the relation ships between the tables. Here is some important hints about the SQL server.
In SQL server Information_Schema is very use full to get the details of the tables. The below list of Information_Schema's are used to retrieve the tables and fields details.
Information_Schema.Check_Constraints Information_Schema.Column_Domain_Usage Information_Schema.Column_Privileges Information_Schema.ColumnsInformation_Schema.Constraint_Column_Usage Information_Schema.Constraint_Table_Usage Information_Schema.Domain_Constraints Information_Schema.DomainsInformation_Schema.Key_Column_Usage Information_Schema.ParametersInformation_Schema.Referential_ConstraintsInformation_Schema.Routine_ColumnsInformation_Schema.RoutinesInformation_Schema.SchemataInformation_Schema.Table_ConstraintsInformation_Schema.Table_PrivilegesInformation_Schema.Tables Information_Schema.Views Information_Schema.View_Column_Usage Information_Schema.View_Table_Usage

For Example : if you want to see how many tables you are using in the database:
select * from Information_Schema.Tables where Table_Type = 'BASE TABLE'
if you want to see how many views you are using in the database:
select * from Information_Schema.Tables where Table_Type = 'VIEW'

Like this you can use Information_Schema to get the details of the database.

No comments:

Post a Comment