select *from student; (列的顺序,是按照建表的时候排列的)
select name,sex from student;
select sname,2016-age as”year of birth” from s;
注意:列可以是表达式 as<别名>,在显示列名的时候 变会以别名来显示。as有时候可以省略
消除取值重复的行
原始的:select sdept from s;
改变后为:select distinct sdept from s;
(比较范围)
select age from s where age<22;
(确定集合)
between and 语句
select name,age from s where age between 20 and 25;
(查询条数)
select count(distinct name)from student
select count(*)from student
求平均数
select AVG(age) from student;
删除数据
delete from student where age<20
修改数据
update student set name=”xiaoming” where name=”xiaogou”
插入数据
insert into student values(“xiaoming”,”male”,24)
对查询结果进行排序
select age from student order by age
删除表
drop table student
创建表
create table student
{
id int ,
name char(20)
}