1、连接
gsql -h 171.44.xxx.xxx -p 25108 -d dlp_user -U dlp -W 1234@ 登录
2、编码
show server_encoding; 查看当前数据库编码
3、搜索路径
show search_path; 查看模式搜索路径,无论如何搜索路径前两个一定是pg_temp和pg_catalog
set search_path to my_schema,public; 将my_schema,public两个模式加入搜索路径
4、模式
select current_schema; 查看数据库当前模式
set current_schema=my_schema; 设置当前数据库模式。
\dn 查看所有模式及其所有者
create schema my_schema authorization dlpuser; 创建schema并指定owner
用户只能访问属于自己schema中的数据库对象,若要访问其他人的schema中数据库对象则必须具有该schema的usage权限。
5、用户
select * from pg_user; 查看当前数据库用户
create user joe with password '123456';
6、数据库
select datname from pg_database; 查看数据库列表
create database my_database template template0; 参考template0新建数据库(默认template1)
7、表
select * from pg_tables; 查看当前数据库拥有的表
select * from dba_tab_partitions; 查看当前数据库拥有的分区表
\d+ my_schema.t_emp; 查看表的属性
select * from my_schema.t_emp_partition partition(p1); 查看分区表P1分区数据
create table my_sch
GaussDB(DWS)数据库入门语法
于 2021-09-26 10:14:00 首次发布