第三部分插入数据
3.1格式:
INSERT INTO表名(列名,列名....) VALUES (数据,数据....)
3.2 实例
插入两条数据
MariaDB[study_db]> INSERT INTO books
-> (book_name, publication_date)
-> VALUES
-> ('跟我学MariaDB', NOW()),
-> ('NodeJS', '2016-12-02'),
-> ('MYSQL', '2016-12-01');
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)