In Oracle, change the case of table names and field names

Source: Internet
Author: User
Tags lowercase

1. Change the table name and field name to uppercase see-http://www.cnblogs.com/wenboge/articles/4121331.html

2. Change the table name and field name to lowercase

① change table name to lowercase

begin    forCinch(SelectTABLE_NAME TN fromUser_tableswheretable_name<> Lower(table_name)) Loopbegin          ExecuteImmediate'ALTER TABLE'||C.tn||'Rename to "'||Lower(c.tn)||'"'; Exception whenOthers ThenDbms_output.put_line (c.tn||'already exists'); End; EndLoop;End;

② field is named lowercase

begin      forTinch(SelectTABLE_NAME TN fromuser_tables) Loopbegin          forCinch(SelectCOLUMN_NAME CN fromUser_tab_columnswheretable_name=t.tn) Loopbegin                ExecuteImmediate'ALTER TABLE'||T.tn||'Rename Column'||c.cn||'To "'||Lower(c.cn)||'"'; Exception whenOthers ThenDbms_output.put_line (t.tn||'.'||c.cn||'already exists'); End; EndLoop; End; EndLoop;End;

Note:

1. If the fields and table names are changed to lowercase, change the fields first and then change the table.

2. If the table name gets the field name to lowercase, enclose the table and field names in the query statement with double quotation marks

Cases.

Table name lowercase: SELECT * from "department";

Field name lowercase: select "id" from "department";

And I don't know why.

In Oracle, change the case of table names and field names

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.