MairDB 初始數據庫與表 (二)

第三部分 插入數據3d

3.1 格式:code

INSERT INTO 表名 (列名, 列名....) VALUES (數據, 數據....)blog

3.2 實例
插入兩條數據ip

 

MariaDB [study_db]> INSERT INTO booksget

    -> (book_name, publication_date)io

    -> VALUEStable

    -> ('跟我學MariaDB', NOW()),date

    -> ('NodeJS', '2016-12-02'),方法

    -> ('MYSQL', '2016-12-01');im

3.3 篩選數據

MariaDB [study_db]> SELECT * FROM books;

+---------+------------------+------------------+------------------+-------------+

| book_id | book_name        | book_author_name | publication_date | description |

+---------+------------------+------------------+------------------+-------------+

|       1 | 跟我學MariaDB    | NULL             | 2016-12-02       | NULL        |

|       2 | NodeJS           | NULL             | 2016-12-02       | NULL        |

+---------+------------------+------------------+------------------+-------------+

2 rows in set (0.00 sec)

 

3.4 查看錶結構的另一種方法

 

MariaDB [study_db]> SHOW CREATE  TABLE books \G

*************************** 1. row ***************************

       Table: books

Create Table: CREATE TABLE `books` (

  `book_id` int(11) NOT NULL AUTO_INCREMENT,

  `book_name` varchar(20) DEFAULT NULL,

  `book_author_name` varchar(20) DEFAULT NULL,

  `publication_date` date DEFAULT NULL,

  `description` text,

  PRIMARY KEY (`book_id`)

) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8

1 row in set (0.00 sec)

相關文章
相關標籤/搜索