pg 表名大小写问题

testdb=# create table TEST3 ( A INT);
CREATE TABLE
testdb=# \d test3;
               Table "public.test3"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 a      | integer |           |          |

testdb=# \d
                      List of relations
 Schema |         Name         |       Type        |  Owner
--------+----------------------+-------------------+----------
 public | TEST2                | table             | postgres
 public | TEST3                | partitioned table | postgres
 public | test                 | table             | postgres
 public | test3                | table             | postgres
 public | test3_y2006m02       | table             | postgres
(27 rows)

testdb=# \d TEST3
               Table "public.test3"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 a      | integer |           |          |

testdb=# insert into test3 values (1);
INSERT 0 1
testdb=# select * from test3;
 a
---
 1
(1 row)

testdb=# select *  from TEST3;
 a
---
 1
(1 row)

testdb=# drop table test3;
DROP TABLE
testdb=# \d
                      List of relations
 Schema |         Name         |       Type        |  Owner
--------+----------------------+-------------------+----------
 public | TEST2                | table             | postgres
 public | TEST3                | partitioned table | postgres
 public | test                 | table             | postgres
 public | test3_y2006m02       | table             | postgres
(26 rows)

testdb=# select * from test3;
ERROR:  relation "test3" does not exist
LINE 1: select * from test3;
                      ^
testdb=# select *  from TEST3;
ERROR:  relation "test3" does not exist
LINE 1: select *  from TEST3;
                       ^
testdb=# ^C
testdb=# ^C
testdb=# ^C
testdb=# select *  from "TEST3";
 city_id | logdate | peaktemp | unitsales
---------+---------+----------+-----------
(0 rows)

testdb=#

经过以上测试,  创建表的时候表名可以区分大小写。

但是select 的时候,是大写转成小写的。 !!!!!

why??

原因找到了,是因为创建表的时候, 表名加了" " , 所以select 查询,dml 等操作的时候也要加“ “ 。

而且创建表的时候表名和列名写大写,默认会转成小写。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值