Obtain fields of the specified type of table in Oracle

Source: Internet
Author: User

-- Obtain the table primary key and type
Select acc. column_name, ATC. data_type
From all_constraints AC, all_cons_columns ACC, all_tab_columns ATC
Where AC. table_name = upper ('table name ')
And AC. constraint_type = 'P'
And AC. constraint_name = acc. constraint_name
And AC. table_name = ATC. table_name
And acc. column_name = ATC. column_name

Select acc. column_name
From all_constraints AC, all_cons_columns ACC
Where AC. table_name = upper ('table name ')
And AC. constraint_type = 'P'
And AC. constraint_name = acc. constraint_name

-- Obtain fields of the specified type in the table
Select column_name as cloumn
From all_tab_columns
Where table_name = upper ('table name ')
And data_type = 'varchar2 ';

-- Obtain the table containing the Date Field in the primary key, which can also be specified as number, varchar2

select ACC. column_name, ATC. data_type, ATC. table_name
from all_constraints AC, all_cons_columns ACC, all_tab_columns ATC
where AC. constraint_type = 'P'
and AC. constraint_name = ACC. constraint_name
and AC. table_name = ATC. table_name
and ACC. column_name = ATC. column_name
and ATC. data_type = 'date';

Related Article

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.