MySQL基础(增删改查)

前提:创建数据库

CREATE TABLE teacher (id INT,NAME VARCHAR (20),address VARCHAR (20));

上面创建了一个表格,表头有id,name,address

 

(1)增

# 没有在teacher后加()指明,则按照表头顺序
INSERT INTO teacher VALUES (10001,'hello','zheli');
​
# 也可加(),则按照括号里的顺序
INSERT INTO teacher (NAME,id,address) 
VALUES ('cheng',111,'zhelihenali');

(2)删

# where指明要删除的地点,如下删除一整行
DELETE FROM teacher WHERE NAME='hello';

(3)改

# where指明那一行,set后面内容重新改写
UPDATE teacher SET NAME='huang' WHERE id='10001';

(4)查

SELECT*FROM teacher;

MySQL基础(增删改查)_第1张图片

 

你可能感兴趣的:(mysql,数据库)