SQL

Tuesday, November 4, 2008

 

Metadata Queries: Listing a Table's Columns

Metadata Queries: Listing a Table's Columns
DB2
Query SYSCAT.COLUMNS:
select colname, typename, colno  from syscat.columns where tabname = 'EMP' and tabschema = 'SMEAGOL'

Oracle
Query ALL_TAB_COLUMNS:
select column_name, data_type, column_id from all_tab_columns where owner  = 'SMEAGOL' and table_name = 'EMP'

PostgreSQL, MySQL, and SQL Server
Query INFORMATION_SCHEMA.COLUMNS:
select column_name, data_type, ordinal_position from information_schema.columns  where table_schema = 'SMEAGOL'  and table_name   = 'EMP'

Each vendor provides ways for you to get detailed information about your column data. In the examples above only the column name, data type, and position are returned. Additional useful items of information include length, nullability, and default values

posted by kanun  # 6:07 AM
Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

Archives

September 2008   October 2008   November 2008  

This page is powered by Blogger. Isn't yours?

Subscribe to Comments [Atom]