postgresql创建数据库
pg创建数据库
·
一、环境
docker中编译的postgreSQL14.2
postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/psql
psql (14.2)
Type "help" for help.
postgres=# select version();
version
--------------------------------------------------------------------------------------------------
PostgreSQL 14.2 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, 64-bit
(1 row)
二、创建数据库
2.1 使用createdb
src/bin/scripts/createdb.c
postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/createdb --help
createdb creates a PostgreSQL database.
Usage:
createdb [OPTION]... [DBNAME] [DESCRIPTION]
Options:
-D, --tablespace=TABLESPACE default tablespace for the database
-e, --echo show the commands being sent to the server
-E, --encoding=ENCODING encoding for the database
-l, --locale=LOCALE locale settings for the database
--lc-collate=LOCALE LC_COLLATE setting for the database
--lc-ctype=LOCALE LC_CTYPE setting for the database
-O, --owner=OWNER database user to own the new database
-T, --template=TEMPLATE template database to copy
-V, --version output version information, then exit
-?, --help show this help, then exit
Connection options:
-h, --host=HOSTNAME database server host or socket directory
-p, --port=PORT database server port
-U, --username=USERNAME user name to connect as
-w, --no-password never prompt for password
-W, --password force password prompt
--maintenance-db=DBNAME alternate maintenance database
By default, a database with the same name as the current user is created.
Report bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>
postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/createdb -h 127.0.0.1 -p 5432 mydb
2.2 使用psql命令行
postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/psql
psql (14.2)
Type "help" for help.
postgres=# CREATE DATABASE test2;
CREATE DATABASE
postgres=#
三、删除数据库
postgres=# DROP DATABASE test2;
<p>DROP DATABASE</p>
postgres=#
更多推荐
已为社区贡献4条内容
所有评论(0)