USE db1;
CREATE TABLE student(
sid INT(4) NOT NULL PRIMARY KEY,
sname VARCHAR (36),
gid INT(4) NOT NULL
)ENGINE=INNODB;
/*插入数据*/
INSERT INTO student VALUE(4,'赵六',4);/*插入一条数据*/
INSERT INTO student VALUES(1,'张三',1),(2,'李四',2),(3,'王五',3);/*插入多条数据*/
/*更新数据*/
UPDATE student SET sname='张一' WHERE sid=1;/*将sid为1的记录的sname改为'张一'*/
/*查看数据*/
SELECT */*所有数据*/ FROM student;
SELECT sid,sname,gid/*指定的字段*/ FROM student;
SELECT * FROM student WHERE sid>2/*sid>2 的数据*/;
/*删除数据*/
DELETE FROM student WHERE sid=2;/*删除sid为2的记录*/
DELETE FROM student;/*删除表中所有数据*/
TRUNCATE TABLE student;/*删除表中所有数据*/
【MySQL】基本增删改查
最新推荐文章于 2024-10-31 23:41:03 发布