Retrieving Schema Information of SQL CE Database

Posted: August 3, 2007 in SQL Server
There are very limited features offered in SQL Compact Edition (SQL CE). But with those offered you can do many things if you know what is there and what is not there.

Following are some views available in SQL CE which you can use to retrieve information about the tables in the database.
 
— Gets the list of Columns with their associated Tables. You will be able to retrieve the column properties such as Data Type, Allow Null, Default Values, etc.

SELECT * FROM INFORMATION_SCHEMA.COLUMNS

— Retrieves information about the indexes contained in the database.

SELECT * FROM INFORMATION_SCHEMA.INDEXES

— Retrieves information about the Primary Keys used in the tables.

SELECT

* FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE

— Retrieves all the Tables in the database including the System tables.

SELECT

* FROM INFORMATION_SCHEMA.TABLES

— Retrieves all the Constrains in the database.

SELECT

* FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS

— Retrieves all the Data Types available in the database.

SELECT

* FROM INFORMATION_SCHEMA.PROVIDER_TYPES

— If you have any referential integrity constraints in your database defined, those will be returned by this.

SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS

Advertisements

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