You can use the table name and field name to query the field type.

Source: Internet
Author: User

You can use the table name and field name to query the field type.

Today, I encountered a problem: I want to obtain the field type of this field through the table name and field name. I found a lot of methods on the Internet, but I was not successful (my database knowledge is scarce ). Later, I found a correct statement, which is recorded here.

Select data_type from user_tab_columns where table_name = 'table name' and column_name = 'field name'


 


How to find the table name

Select a. name table name, B. name column name
From sysobjects a, syscolumns B
Where a. id = B. id
And B. name = 'field name'
And a. type = 'U'

How can I query the field types, field comments, and field names in an oracle table?

You can use the following statement:
SELECT B. column_name -- field name
, B. data_type -- field type
, B. data_length -- Field Length
, A. comments -- field comment
FROM user_col_comments
, All_tab_columns B
WHERE a. table_name = B. table_name and
A. table_name = 'table _ name ';

PS:
Table_name is case sensitive.

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.