前言:
最近参加了由opengauss、墨天轮、鲲鹏社区一起推出的活动《每日一练 opengauss 3.0.0 数据库在线实训课程》,共21天,墨天轮提供实操环境,特此记录学习笔记。
活动详情:https://www.modb.pro/db/551619
主题:
学习查看表的相关信息
学习笔记
第15天:表管理3
先来看看表的概念:
表(Table)
表是由行与列组合成的,是数据库中用来存储数据的对象,是整个数据库系统的基础。
每张表只能属于一个数据库,也只能对应到一个表空间。每张表对应的数据文件必须在同一个表空间中。
1.创建测试表
root@modb:~# su - omm
omm@modb:~$ gsql -r
gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:00 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
omm=# \conninfo
You are connected to database "omm" as user "omm" via socket in "/tmp" at port "5432".
omm=# create table test(
omm(# id bigint,
omm(# name varchar(50) not null,
omm(# age int default 20,
omm(# primary key(id));
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_pkey" for table "test"
CREATE TABLE
omm=#
2.在gsql中查看表的定义、模式和所有者

3.查看某个模式下有哪些表
查看public模式下的所有表名
omm=# SELECT table_name FROM information_schema.tables WHERE table_schema='public';
table_name
------------
test
(1 row)
omm=#
4.查看一个表下有哪些约束

5.查看一个表属于数据库的哪个模式

总结:
第15天,知道了怎么去查看表的定义、模式和所有者。 以及查看模式下有哪些表以及表的约束信息。
information_schema.tables
我们在最后查一个表属于数据库的哪个模式的时候用到了这个视图,那顺便学一下这个视图。
我们在oracle数据库中如果想查看表的一些关系信息的时候,会用到dba_tables这个视图,那在opengauss的dba_tables就是information_schema.tables

同样的,提到dba_tables就会想到DBA_TAB_COLUMNS,那这个在opengauss中对应的是information_schema.columns

最后修改时间:2022-12-09 10:11:41
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




