next up previous contents
Next: Select 查詢資料表 Up: Query 紀錄詢問 Previous: Query 紀錄詢問   Contents   DYWANG_HOME

Insert into 新增紀錄

  1. 登入 mariadb。
    [root@kvm8 ~]# 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 - Lewis Peckover
    
  2. 使用資料庫 dyw。
    mariadb root@localhost:(none)> use dyw;                                         
    You are now connected to database "dyw" as user "root"
    Time: 0.001s
    
  3. 新增三筆紀錄到資料表 tbl,回應資料表 tbl 不存在。
    mariadb root@localhost:dyw> insert into tbl (title,author,submission_date) value
                                s("PHP","david",NOW());                             
    (1146, "Table 'dyw.tbl' doesn't exist")
    
  4. 因上一章已刪除資料表 tbl,重新產生資料表。
    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.091s
    
  5. 新增第一筆資料到資料表 tbl。
    mariadb root@localhost:dyw> insert into tbl (title,author,submission_date) value
                                s("PHP","david",NOW());                             
    Query OK, 1 row affected
    Time: 0.006s
    
  6. 新增第二筆資料到資料表 tbl。
    mariadb root@localhost:dyw> insert into tbl (title,author,submission_date) value
                                s("MariaDB","dywang","2020-01-01");                 
    Query OK, 1 row affected
    Time: 0.004s
    
  7. 新增第三筆資料到資料表 tbl。
    mariadb root@localhost:dyw> insert into tbl (title,author,submission_date) value
                                s("Linux","linux","2020-01-11");                    
    Query OK, 1 row affected
    Time: 0.004s
    



De-Yu Wang 2020-04-07