1、创建数据库表——CREATE TABLE语句:
CREATE TABLE customer
(
ID int,
Name varchar(200),
Birthday date,
Tel varchar(50)
);
2、插入数据——INSERT语句:
1)单行插入:
INSERT INTO customer VALUES(1,'刘备','20200401',123456789);
2)多行插入:
INSERT INTO customer (ID,Name,Birthday,Tel) VALUES
(2,'关羽','20200402',132456789),
(3,'张飞','20200403',142356789),
(4,'曹操','20200404',154623789),
(5,'孙坚','20200405',145623789),
(6,'孙策','20200406',154687923),
(7,'诸葛亮','20200407',456789123);
3)插入部分字段:
INSERT INTO customer(ID,Name)VALUES(8,'周瑜'),(9,'黄忠'),(10,'陶谦');
查看插入结果:
select * from customer order by id;
id | name | birthday | tel
----+--------+------------+-----------
1 | 刘备 | 2020-04-01 | 123456789
2 | 关羽 | 2020-04-02 | 132456789
3 | 张飞 | 2020-04-03 | 142356789
4 | 曹操 | 2020-04-04 | 154623789
5 | 孙坚 | 2020-04-05 | 145623789
6 | 孙策 | 2020-04-06 | 154687923
7 | 诸葛亮 | 2020-04-07 | 456789123
8 | 周瑜 | |
9 | 黄忠 | |
10 | 陶谦 | |
(10 rows)