博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PostgreSQL中,database,schema,table之间关系
阅读量:6946 次
发布时间:2019-06-27

本文共 2807 字,大约阅读时间需要 9 分钟。

从逻辑上看,schema,table,都是位于database之下。

首先,在postgres数据库下建立表(相当于建立在public schema下):

[pgsql@localhost bin]$ ./psql -d postgrespsql (9.1.2)Type "help" for help.postgres=# create table tab200(id integer);CREATE TABLEpostgres=# \q

然后,再在tester数据库下建立表(相当于建立在public schema下):

[pgsql@localhost bin]$ ./psql -d testerpsql (9.1.2)Type "help" for help.tester=# create table tab200(id integer);CREATE TABLEtester=# \q

然后,再在其他的数据库下进行查看:

[pgsql@localhost bin]$ ./psqlpsql (9.1.2)Type "help" for help.pgsql=# SELECT * FROM information_schema.tables WHERE table_name='tab200'; table_catalog | table_schema | table_name | table_type | self_referencing_column_name | reference_generation | user_defined_type_catalog | user_defined_type_schema | user_defined_type_name | is_insertable_into | is_typed | commit_action ---------------+--------------+------------+------------+------------------------------+----------------------+---------------------------+--------------------------+------------------------+--------------------+----------+---------------(0 rows)pgsql=# \q

然后,再在 postgres数据库和tester数据库下分别查看:

[pgsql@localhost bin]$ ./psql -d testerpsql (9.1.2)Type "help" for help.tester=# SELECT * FROM information_schema.tables WHERE table_name='tab200'; table_catalog | table_schema | table_name | table_type | self_referencing_column_name | reference_generation | user_defined_type_catalog | user_defined_type_schema | user_defined_type_name | is_insertable_into | is_typed | commit_action ---------------+--------------+------------+------------+------------------------------+----------------------+---------------------------+--------------------------+------------------------+--------------------+----------+--------------- tester        | public       | tab200     | BASE TABLE |                              |                      |                           |                          |                        | YES                | NO       | (1 row)tester=# \q [pgsql@localhost bin]$ ./psql -d postgrespsql (9.1.2)Type "help" for help.postgres=# SELECT * FROM information_schema.tables WHERE table_name='tab200'; table_catalog | table_schema | table_name | table_type | self_referencing_column_name | reference_generation | user_defined_type_catalog | user_defined_type_schema | user_defined_type_name | is_insertable_into | is_typed | commit_action ---------------+--------------+------------+------------+------------------------------+----------------------+---------------------------+--------------------------+------------------------+--------------------+----------+--------------- postgres      | public       | tab200     | BASE TABLE |                              |                      |                           |                          |                        | YES                | NO       | (1 row)

 

转载地址:http://anenl.baihongyu.com/

你可能感兴趣的文章
Javascript函数小结(一)
查看>>
Go结构体
查看>>
修改RAC public ip,vip private ip
查看>>
hql
查看>>
软件包管理工具(2): YUM
查看>>
如何构建高精度室内定位系统
查看>>
Maven学习总结(六)——Maven与Eclipse整合
查看>>
青春路上,岁月如烟
查看>>
Java打印出现16位进制地址问题解决
查看>>
Git常见问题 资料汇总
查看>>
CMD命令视频教程-初识CMD-0
查看>>
八皇后问题
查看>>
Tomcat7 搭建 websocket服务
查看>>
关于java调用的存贮过程
查看>>
JSTL核心标签:taglib指令代码分享
查看>>
Java Web学习总结(12)——使用Session防止表单重复提交
查看>>
整合apache和tomcat构建Web服务器
查看>>
我的友情链接
查看>>
python获取按字典值排序的列表
查看>>
iis短文件名漏洞解决方法
查看>>