openGauss每日一练第15天
学习表管理3
学习表相关信息的查看,如表约束,表定义,表与模式信息等,完成课后作业
创建表t1并定义列级约束
在omm用户下通过gsql -r连接数据库后创建表并设置列级约束,使用元命令\d <tablename>查看列约束信息
omm=# create table t1(id bigint primary key,name char(100) not null,age int default 20); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t1_pkey" for table "t1" CREATE TABLE omm=# \d t1 Table "testsm.t1" Column | Type | Modifiers --------+----------------+----------- id | bigint | not null name | character(100) |
查看表的模式和Owner
可以使用元命令\dt+ <tablename>查看表定义,模式和所有者,使用元命令\x可以修改结果排版。
omm=# \x Expanded display is on. omm=# \dt+ t1 List of relations -[ RECORD 1 ]--------------------------------- Schema | testsm Name | t1 Type | table Owner | omm Size | 0 bytes Storage | {orientation=row,compression=no} Description |
查看表的定义
使用元命令\d <tablename>即可查看表的定义
omm=# \d t1 Table "testsm.t1" Column | Type | Modifiers --------+----------------+------------ id | bigint | not null name | character(100) | not null age | integer | default 20 Indexes: "t1_pkey" PRIMARY KEY, btree (id) TABLESPACE pg_default
总结
使用元命令\dt+ <tablename>就能查看表的所有者,模式,和名字非常的方便,而如果想要查看表定义,则可以使用元命令\d加上+号的命令可以查看到更多信息如\d+
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




