2020年4月27日
INSERT INTO users (name,phone)VALUES('QT3,'13245564');
INSERT INTO users (name,phone)VALUES('QT4,'13245565');
INSERT INTO users VALUES(0,'QT5,'13245566','123456');
INSERT INTO users (name,phone)
VALUES
('QT6','13245567'),
('QT7','13245568')
;
INSERT INTO users
VALUES
(0,'QT8','13245569,'123456'),
(0,'QT9','132455610,'123456')
;
INSERT INTO birds_body_shapes(body_id, body_shape)
VALUES
('HMD','Hummingbird'),
('LLW','Long-Legged wader'),
('MHH','Marsh Hen'),
('PHB','Perching Bird'),
('PWB','Perching Water Bird')
;
INSERT INTO birds_wing_shapes(wing_id,wing_shape)
VALUES
('HMD','Broad'),
('LLW','Rounded'),
('MHH','Pointed'),
('PHB','Long'),
('PWB','Very Long')
;
INSERT INTO users (name,phone)VALUES('QT3,'13245564');
INSERT INTO users (name,phone)VALUES('QT4,'13245565');
INSERT INTO users VALUES(0,'QT5,'13245566','123456');
INSERT INTO users (name,phone)
VALUES
('QT6','13245567'),
('QT7','13245568')
;
INSERT INTO users
VALUES
(0,'QT8','13245569,'123456'),
(0,'QT9','132455610,'123456')
;
INSERT INTO birds_body_shapes(body_id, body_shape)
VALUES
('HMD','Hummingbird'),
('LLW','Long-Legged wader'),
('MHH','Marsh Hen'),
('PHB','Perching Bird'),
('PWB','Perching Water Bird')
;
INSERT INTO birds_wing_shapes(wing_id,wing_shape)
VALUES
('HMD','Broad'),
('LLW','Rounded'),
('MHH','Pointed'),
('PHB','Long'),
('PWB','Very Long')
;
INSERT INTO users (name,phone)VALUES('QT3,'13245564');
INSERT INTO users (name,phone)VALUES('QT4,'13245565');
INSERT INTO users VALUES(0,'QT5,'13245566','123456');
INSERT INTO users (name,phone)
VALUES
('QT6','13245567'),
('QT7','13245568')
;
INSERT INTO users
VALUES
(0,'QT8','13245569,'123456'),
(0,'QT9','132455610,'123456')
;
INSERT INTO birds_body_shapes(body_id, body_shape)
VALUES
('HMD','Hummingbird'),
('LLW','Long-Legged wader'),
('MHH','Marsh Hen'),
('PHB','Perching Bird'),
('PWB','Perching Water Bird')
;
INSERT INTO birds_wing_shapes(wing_id,wing_shape)
VALUES
('HMD','Broad'),
('LLW','Rounded'),
('MHH','Pointed'),
('PHB','Long'),
('PWB','Very Long')
;
笔记:
插入数据语法:
INSERT INTO 表名[(字段1,字段2…)] VALUES(value…) [,(value…),…];
插入单挑数据的基本方式:数据的基本单位都是按行来提示
插入特点的字段:可以插入部分字段数据来添加一行,字段可以设置默认值,如果没有被插入则使用默认值;
例如:INSERT INTO users(name,phone)VALUES(‘QT5’,’13245566’);
NOT NULL指的是值不能为null,设置之后默认值还是null,那字段就必须被插入
插入所有字段:
INSERT INTO users VALUES(0,’QT6,’123456’);
DEFAULT:直接使用数据库里的默认值
一次插入多条数据
指定字段
INSERT INTO users (name,phone)
VALUES
(‘QT6’,’13245567’),
(‘QT7’,’13245568’),
…;
所有字段
INSERT INTO users
VALUES
(0,’QT8’,’13245569,’123456’),
(0,’QT9’,’132455610,’123456’),
…;
明确插入:一次只能插入一条数据
INSERT INTO 表名 SET 字段名1=值1[,字段名2=值2 …];
INSERT INTO users SET name=’QT10’,phone=’132455611’;
替换重复数据(擦汗如数据操作)
支持多条数据插入
在唯一键的字段下遇到重复值,则会删除数据表内原有的一行数据,再将新数据插入
REPLACE INTO users(name,phone) VALUES(‘QT11’,’132455611’);