简体   繁体   English

PostgreSQL自动将列名重命名为所有小写

[英]PostgreSQL automate renaming column names to all lowercase

I'm converting someone's Microsoft Access database to PHP/PostgreSQL. 我正在将某人的Microsoft Access数据库转换为PHP / PostgreSQL。 Referencing all lowercase column names works just fine however the people who created the Access databases "APPARENTLY" "ALWAYS" "SCREAMED" "ALL" "THE" "TIME" "AND" "IT" "MEANS" "HAVING" "TO" "PUT" "QUOTES" "AROUND" "ALL" "COLUMN" "NAMES". 引用所有小写的列名都可以,但是创建Access数据库的人员“大约”,“总是”,“已尖叫”,“全部”,“时间”,“和”,“它”,“意味着”,“正在”,“到”,“输入”,“ QUOTES”,“周围”,“全部”,“列”,“名称”。 I never use capitol letters in column names ever in absolute. 我从不绝对在列名中使用大写字母。

How do I ALTER all the column names so that they have the same names though all lowercase? 我如何ALTER所有列名,以便所有小写字母都具有相同的名称?

There are no same-names/different cases (eg there are no column sets like "TableName" and "tableName"). 没有相同名称/不同大小写(例如,没有“ TableName”和“ tableName”之类的列集)。

update pg_attribute set attname=lower(attname);

That will make sure there are no upper case letters in any of your tables. 这将确保您的任何表中都没有大写字母。 You may wish to toss a where clause on there if there are columns that legitimately need an upper case letter. 如果存在合法需要大写字母的列,则您可能希望在该处扔一个where子句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM