Gets the field definition for the specified table

Source: Internet
Author: User

MySQL Gets the field definition for the specified table (assuming the table name is MyTable):

DESCRIBE mytable

Gets the field definition for the specified table in MySQLServer (assuming the table name is MyTable):

 select syscols.name as column_name,st.name as data_type,syscomm.text as data_default,syscols.isnullable as NULLABLE from syscolumns syscolsleft join Systypes St on syscols.xusertype=st.xusertypeleft join syscomments syscomm on syscols.cdefault=syscomm.idwhere syscols.id=object_id (N" mytable ") order Span class= "Hljs-keyword" >by syscols.id,syscols.colorder         

The All_tab_columns table in Oracle is the field definition for all tables in the system, where the TABLE_NAME field is the table name, so the field definition for the specified table is obtained (assuming the table name is MyTable):

select COLUMN_NAME,DATA_TYPE,DATA_DEFAULT,NULLABLE from all_tab_columns where TABLE_NAME ="MYTABLE"

The Syscat.columns table in DB2 is the field definition for all tables in the system, where the TabName field is the table name, so the field definition for the specified table is obtained (assuming the table is named MyTable):

select COLNAME as COLUMN_NAME, TYPENAME as DATA_TYPE,DEFAULT asDATA_DEFAULT,NULLS as NULLABLEfrom syscat.columns where TABNAME="MYTABLE"

Gets the field definition for the specified table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.