[email protected]:~$ /usr/local/pgsql/bin/psql psql 14.2 Type 'help' for help. po...">

当前位置:网站首页>PostgreSQL create database

PostgreSQL create database

2022-06-11 15:53:00 happytree001

One 、 Environmental Science

docker Compiled in postgreSQL14.2

[email protected]:~$ /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)

Two 、 Create database

2.1 Use createdb

src/bin/scripts/createdb.c

[email protected]:~$ /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 <[email protected]>.
PostgreSQL home page: <https://www.postgresql.org/>
[email protected]:~$ /usr/local/pgsql/bin/createdb -h 127.0.0.1 -p 5432 mydb

2.2 Use psql Command line

[email protected]:~$ /usr/local/pgsql/bin/psql 
psql (14.2)
Type "help" for help.

postgres=# CREATE DATABASE test2;
CREATE DATABASE
postgres=# 

3、 ... and 、 Delete database

postgres=# DROP DATABASE test2;
<p>DROP DATABASE</p>
postgres=# 
原网站

版权声明
本文为[happytree001]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111539195547.html