Script to check Database data field naming conventions and legality

Source: Internet
Author: User

--Check for field names that do not conform to the database naming conventions

Select Table_name,column_name,data_type
From User_tab_columns
Where column_name in--(Select keyword from v$reserved_words)
(' ACCESS ', ' ADD ', ' All ', ' ALTER ', ' and ', ' any ', ' as ', ' ASC ', ' AUDIT ',
' BETWEEN ', ' by ', ' CHAR ', ' CHECK ', ' CLUSTER ',
' COLUMN ', ' COMMENT ', ' COMPRESS ', ' CONNECT ', ' CREATE ', ' current ',
' DATE ', ' DECIMAL ', ' DEFAULT ', ' DELETE ',
' DESC ', ' DISTINCT ', ' DROP ', ' ELSE ', ' EXCLUSIVE ', ' EXISTS ', ' FILE ',
' FLOAT ', ' for ', ' from ', ' GRANT ', ' GROUP ',
' Have ', ' identified ', ' IMMEDIATE ', ' in ', ' INCREMENT ', ' INDEX ',
' INITIAL ', ' INSERT ', ' INTEGER ', ' INTERSECT ',
' into ', ' are ', ' level ', ' like ', ' LOCK ', ' LONG ', ' maxextents ', ' minus ',
' MLSLABEL ', ' MODE ', ' MODIFY ', ' Noaudit ',
' Nocompress ', ' not ', ' nowait ', ' NULL ', ' number ', ' of ', ' OFFLINE ', ' on ',
' ONLINE ', ' OPTION ', ' OR ', ' order ',
' PCTFREE ', ' PRIOR ', ' privileges ', ' public ', ' RAW ', ' RENAME ', ' RESOURCE ',
' REVOKE ', ' ROW ', ' ROWID ', ' rownum ',
' ROWS ', ' SELECT ', ' Session ', ' SET ', ' SHARE ', ' SIZE ', ' SMALLINT ', ' START ',
' Successful ', ' synonym ', ' sysdate ',
' TABLE ', ' THEN ', ' to ', ' TRIGGER ', ' UID ', ' UNION ', ' UNIQUE ', ' UPDATE ',
' USER ', ' VALIDATE ', ' ValueS ', ' VARCHAR ',
' VARCHAR2 ', ' VIEW ', ' whenever ', ' WHERE ', ' with '
Or column_name like '%% '

--Check for field names of different types in the database

select a.column_name,a.data_type,b.data_type From
(select distinct column_name,data_type from
all_tab_columns Where TABLE_NAME Like 'T%') a,
(select distinct column_name,data_type from
all_tab_columns Where TABLE_NAME Like 'T%') b
where a.column_name=b.column_name and a.data_type<>b.data_type

--Check for field names of different lengths of the same type in the database

select a.column_name,a.data_type,b.data_type,
a.data_length,b.data_length From
(select distinct column_name,data_type,
data_length from all_tab_columns Where TABLE_NAME Like 'T%') a,
(select distinct column_name,data_type,
data_length from all_tab_columns Where TABLE_NAME Like 'T%') b
where a.column_name=b.column_name and a.data_type=b.data_type And A.DATA_LENGTH<>B.DATA_LENGTH

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.