云数据库 GAUSSDB-CREATE DATABASE:示例

时间:2024-01-23 20:09:21

示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--创建jim和tom用户。
postgres=# CREATE USER jim PASSWORD 'xxxxxxxxxx';
postgres=# CREATE USER tom PASSWORD 'xxxxxxxxxx';

--创建一个GBK编码的数据库music(本地环境的编码格式必须也为GBK)。
postgres=# CREATE DATABASE music ENCODING 'GBK' template = template0;

--创建数据库music2,并指定所有者为jim。
postgres=# CREATE DATABASE music2 OWNER jim;

--用模板template0创建数据库music3,并指定所有者为jim。
postgres=# CREATE DATABASE music3 OWNER jim TEMPLATE template0;

--设置music数据库的连接数为10。
postgres=# ALTER DATABASE music CONNECTION LIMIT= 10;

--将music名称改为music4。
postgres=# ALTER DATABASE music RENAME TO music4;

--将数据库music2的所属者改为tom。
postgres=# ALTER DATABASE music2 OWNER TO tom;

--删除数据库。
postgres=# DROP DATABASE music2;
postgres=# DROP DATABASE music3;
postgres=# DROP DATABASE music4;

--删除jim和tom用户。
postgres=# DROP USER jim;
postgres=# DROP USER tom;

--创建兼容TD格式的数据库。
postgres=# CREATE DATABASE td_compatible_db DBCOMPATIBILITY 'TD';

--创建兼容ORA格式的数据库。
postgres=# CREATE DATABASE ora_compatible_db DBCOMPATIBILITY 'ORA';

--删除兼容TD、ORA格式的数据库。
postgres=# DROP DATABASE td_compatible_db;
postgres=# DROP DATABASE ora_compatible_db;
support.huaweicloud.com/devg-v1-gaussdb/gaussdb_devg_0534.html