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 等操作的时候也要加“ “ 。
而且创建表的时候表名和列名写大写,默认会转成小写。