create table student1(
id int primary key,
name varchar(20),
city varchar(18),
gender char(1),
score int
);
insert into student1 values(1,'张三','郑州','男',98),(2,'李四','上海','男',99),(3,'小红','洛阳','女',95),(4,'小李','开封','男',90);
insert into student1 VALUES (5,'钱七','上海','男',95),(6,'孙八','上海','女',58);
select name,score from student1 where city='郑州';
select *from student1 where score>=80 ORDER BY score desc;
select count(*)from student1;
select city, avg(score) as 平均分 from student1 group by city HAVING avg(score)>75;
select gender, max(score) as 最高分 from student1 GROUP BY gender;
select name from student1 where name like '张%'or name like '李%';
delete from student where id=18;
DELETE from student;
drop table student;
alter table students add age int;
show databases;
use mydb;
select database();
show tables;
desc student1;
select*FROM student1;
show create database mydb;
alter table students add ip varchar(20);
alter table student1 add address varchar(15);
alter table student1 change address addresses varchar(20);
alter table student1 change addresses address varchar(50);
alter table student1 drop address;
alter table students MODIFY age int;
alter table student1 modify gender varchar(18);
alter table student1 rename student;
alter table students rename student1;
delete from student where score=99;
alter table student add address varchar(20);
UPDATE student set address ='郑州';
update student set address='洛阳' where name='张三';
create table a(
id int PRIMARY KEY not null,
name varchar(20) unique,
address varchar(18) DEFAULT('南阳')
);
insert into a (name,id) values ('张三',18),
('李四',19);
insert into a(name,id) VALUES('张四',20);
drop table a;