2023-01-09 LightDB创建数据库.md

LightDB-创建数据库

  • 创建数据库语法格式
createdb [OPTION]... [DBNAME] [DESCRIPTION]

#指令帮助
$ createdb --help
createdb creates a LightDB 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 <https://github.com/hslightdb>.
LightDB home page: <https://www.hs.net/lightdb>
  • 使用示例

创建一个新数据库,命名为:mydb

[lightdb@localhost ~]$ createdb mydb

查验创建结果

[lightdb@localhost ~]$ ltsql 
ltsql (13.8-22.3)
Type "help" for help.

lightdb@lt_test=# \l
                               List of databases
   Name    |  Owner  | Encoding |  Collate   |   Ctype    |  Access privileges  
-----------+---------+----------+------------+------------+---------------------
 lightdb   | lightdb | UTF8     | en_US.utf8 | en_US.utf8 | 
 lt_test   | lightdb | UTF8     | en_US.utf8 | en_US.utf8 | 
 mydb      | lightdb | UTF8     | en_US.utf8 | en_US.utf8 | 
 postgres  | lightdb | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | lightdb | UTF8     | en_US.utf8 | en_US.utf8 | =c/lightdb         +
           |         |          |            |            | lightdb=CTc/lightdb
 template1 | lightdb | UTF8     | en_US.utf8 | en_US.utf8 | =c/lightdb         +
           |         |          |            |            | lightdb=CTc/lightdb
(6 rows)

删除数据库

[lightdb@localhost ~]$ dropdb mydb
lightdb@lt_test=# \l
                               List of databases
   Name    |  Owner  | Encoding |  Collate   |   Ctype    |  Access privileges  
-----------+---------+----------+------------+------------+---------------------
 lt_test   | lightdb | UTF8     | en_US.utf8 | en_US.utf8 | 
 postgres  | lightdb | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | lightdb | UTF8     | en_US.utf8 | en_US.utf8 | =c/lightdb         +
           |         |          |            |            | lightdb=CTc/lightdb
 template1 | lightdb | UTF8     | en_US.utf8 | en_US.utf8 | =c/lightdb         +
           |         |          |            |            | lightdb=CTc/lightdb
(4 rows)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值