1.创建数据库
TEMPLATE1=# create database dbtom owner tom tablespace ts_data; CREATE DATABASE Time: 328.663 ms
2.创建数据库指定字符集UTF8
create database dbtom owner tom ENCODING 'UTF8';
3.从模板创建数据库
create database templatedb template template0;
4.查看数据库
TEMPLATE1=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------+-------------+----------------------- DBTOM | TOM | UTF8 | C | zh_CN.UTF-8 | POSTGRES | GAUSSDBA | UTF8 | C | zh_CN.UTF-8 | TEMPLATE0 | GAUSSDBA | UTF8 | C | zh_CN.UTF-8 | =c/GAUSSDBA + | | | | | GAUSSDBA=CTc/GAUSSDBA TEMPLATE1 | GAUSSDBA | UTF8 | C | zh_CN.UTF-8 | =c/GAUSSDBA + | | | | | GAUSSDBA=CTc/GAUSSDBA (4 rows) postgres=# \l+ List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description ------------+------------+-----------+---------+-------+-----------------------+---------+------------+-------------------------------------------- db_corrupt | db_corrupt | SQL_ASCII | C | C | | 8049 kB | pg_default | db_tom | postgres | SQL_ASCII | C | C | | 8337 kB | s
5.切换数据库
TEMPLATE1=# \c dbtom You are now connected to database "DBTOM". DBTOM=#
6.从操作系统链接数据库
[gaussdba@hwcmdb data]$ gsql -d dbtom gsql (9.2.4) Type "help" for help.
