MySQL数据库测试数据编写 与 SQL增删改查语句

 1. 编写学生表:id、stuname、stuemail

DROP TABLE IF EXISTS `student`;

CREATE DATABASE school;

USE school;

CREATE TABLE `student` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `stuname` varchar(50) DEFAULT NULL,
  `stuemail` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


INSERT INTO student (id, stuname, stuemail) VALUES
(1, 'zhangsan', '[email protected]'),
(2, 'lisi', '[email protected]'),
(3, 'wangwu', '[email protected]');

2. SQL增删改查

2.1 增

insert into student (id,stuname,stuemail) values (default,'小红','[email protected]');

2.2 删

delete from student where id=1

2.3 改

update student set stuname='三少' where id=2

update student set stuname='三少' , stuage=12 where id=2

2.4 查

select * from student  或者  select id,stuname,stuemail from student

猜你喜欢

转载自blog.csdn.net/weixin_45450428/article/details/104646822