INSERT 插入数据
insert 语法一:
INSERT [INTO] table_name [(column_name)] {VALUES|VALUE}
insert 语法二:
INSERT [INTO] tbl_name SET col_name={expr|DEFAULT}
insert
指定列插入: INSERT INTO tb_name(col_names) VALUES (col_values);
全列插入: INSERT INTO tb_name VALUES (all_values);
多行插入: INSERT INTO tb_name(col_names)
VALUES (value_1), (value_2), …;
区别
指定列插入:插入某列某值,单行操作
全列插入:需要给所有列赋值,单行操作
多行插入:插入多行数据
SELECT
查询数据指定列查询:SELECT col_names FROM tb_name;
全列查询: SELECT * FROM tb_name;
带条件的查询: SELECT col_names FROM tb_name WHERE conditions;
UPDATE 更新数据
UPDATE tb_name
SET field_1=value_1,
field_2=value_2,
…
WHERE a_field = a_value;
delete 删除 语法:
DELETE FROM tbl_name WHERE where_conditon;
DELETE FROM tb_name
WHERE a_field = a_value;
注意:一定要写 where 条件,
不然会删除或改变全部数据