Data Dictionary Queries for SQL Server & Oracle


For SQL Server

–Finding all details of Primary Key constraint
select * from sysobjects
where xtype=’PK’

–Finding all details of Foreign Key constraint
select * from sysobjects
where xtype=’F’

–Finding all User-Defined objects (tables, etc)
select * from sysobjects
where xtype=’U’

–Finding all System objects
select * from sysobjects
where xtype=’S’

–Finding all user names
select * from sysusers

–Finding Column Names of Particular Table
–Select Pubs Database
select c.name from sysobjects o, syscolumns c
where o.id = c.id ando.name = ‘publishers’

For ORACLE
select * from sys.dba_objects
where owner = ‘scott’and object_type=’TABLE’
SELECT owner, object_name, object_type FROM sys.dba_objects
where object_type=’SEQUENCE’ and owner=’scott’;

Advertisements

Author: Imran Akram

A .NET/SharePoint Consultant and a political enthusiast who believes in putting the feet of the elected and/or unelected officials to fire in order to get good governance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s