[root@kvm3 ~]# mycli -S /var/lib/mysql/mysql.sock -uroot -p123qwe mariadb 10.3.11-MariaDB mycli 1.20.1 Chat: https://gitter.im/dbcli/mycli Mail: https://groups.google.com/forum/#!forum/mycli-users Home: http://mycli.net Thanks to the contributor - Terje Røsten
mariadb root@localhost:(none)> use dyw; (1049, "Unknown database 'dyw'")
mariadb root@localhost:(none)> create database dyw; Query OK, 1 row affected Time: 0.001s
mariadb root@localhost:(none)> use dyw; You are now connected to database "dyw" as user "root" Time: 0.001s
tbl
,共有 4 個欄位,id
是主鍵,不能是 NULL 且自動增加;title
最長 100 個字元的字串,不能是空的;author
最長 40 個字元的字串,不能是空的;submission_date
記錄寫入時間。
mariadb root@localhost:dyw> create table tbl(id int not null auto_increment, tit le varchar(100) not null, author varchar(40) not nul l,submission_date date, primary key(id)); Query OK, 0 rows affected Time: 0.019s
tbl
資料表欄位型態。
mariadb root@localhost:dyw> show columns from tbl; +-----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | <null> | auto_increment | | title | varchar(100) | NO | | <null> | | | author | varchar(40) | NO | | <null> | | | submission_date | date | YES | | <null> | | +-----------------+--------------+------+-----+---------+----------------+ 4 rows in set Time: 0.025s
mariadb root@localhost:dyw> quit; Goodbye!
tbl
。
[root@kvm3 ~]# mysql -uroot -p123qwe -e "use dyw; show tables;" +---------------+ | Tables_in_dyw | +---------------+ | tbl | +---------------+