课后作业
1.创建表空间newtbs1
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=# create tablespace newtbs1 relative location 'tablespace/new_tbs1';
CREATE TABLESPACE
2.创建3个数据库newdb1、newdb2、newdb3,默认表空间为newtbs1
omm=# create database newdb1 tablespace newtbs1;
omm=# CREATE DATABASE
omm=# create database newdb2 tablespace newtbs1;
CREATE DATABASE
omm=# create database newdb3 tablespace newtbs1;
CREATE DATABASE
3.使用sql查看表空间newtbs1上有几个数据库
omm=# select datname,dattablespace,spcname from pg_database d, pg_tablespace t where d.dattablespace=t.oid and spcname='newtbs1';
datname | dattablespace | spcname
---------+---------------+---------
newdb1 | 16389 | newtbs1
newdb2 | 16389 | newtbs1
newdb3 | 16389 | newtbs1
(3 rows)
4.在文件系统中查看表空间newtbs1中的多个数据库
omm@modb:~$ cd /var/lib/opengauss/data/pg_tblspc/
omm@modb:/var/lib/opengauss/data/pg_tblspc$ ls -lart
total 12
drwx------ 26 omm root 4096 Dec 14 21:20 ..
lrwxrwxrwx 1 omm omm 56 Dec 14 21:26 16389 -> /var/lib/opengauss/data/pg_location/tablespace/test_ts10
lrwxrwxrwx 1 omm omm 55 Dec 14 22:03 16444 -> /var/lib/opengauss/data/pg_location/tablespace/test_ts1
lrwxrwxrwx 1 omm omm 59 Dec 14 22:04 16446 -> /var/lib/opengauss/data/pg_location/tablespace/tablespace_1
lrwxrwxrwx 1 omm omm 62 Dec 14 22:06 16453 -> /var/lib/opengauss/data/pg_location/tablespace/yangkai_newtbs1