Insert into 新增紀錄

  1. 登入 mariadb。
    [root@kvm3 ~]# mycli -uroot -p123qwe
    Connecting to socket /var/lib/mysql/mysql.sock, owned by user mysql
    MariaDB 10.5.16
    mycli 1.26.1
    Home: http://mycli.net
    Bug tracker: https://github.com/dbcli/mycli/issues
    Thanks to the contributor - Georgy Frolov
    MariaDB root@(none):(none)>
    
  2. 使用資料庫 dyw。
    mariadb root@(none):(none)> use dyw;                                         
    You are now connected to database "dyw" as user "root"
    Time: 0.001s
    
  3. 新增三筆紀錄到資料表 tbl,回應資料表 tbl 不存在。
    mariadb root@(none):dyw> insert into tbl (title,author,submission_date) value
                                s("PHP","david",NOW());                             
    (1146, "Table 'dyw.tbl' doesn't exist")
    
  4. 因上一章已刪除資料表 tbl,重新產生資料表。
    mariadb root@(none):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.091s
    
  5. 新增第一筆資料到資料表 tbl。
    MariaDB root@(none):dyw> insert into tbl (title,author,submission_date) values("
                          -> PHP","david",NOW());
    Query OK, 1 row affected
    Time: 0.009s
    
  6. 新增第二筆資料到資料表 tbl。
    MariaDB root@(none):dyw> insert into tbl (title,author,submission_date) values("
                          -> Linux","linux","2023-01-30");
    Query OK, 1 row affected
    Time: 0.014s
    
  7. 新增第三筆資料到資料表 tbl。
    MariaDB root@(none):dyw> insert into tbl (title,author,submission_date) values("
                          -> Mariadb","dywang","2023-03-30");
    Query OK, 1 row affected
    Time: 0.027s