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

2.4 查

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

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章