设置多个主键:
create table sc(
Sno char(3),
Cno varchar(2),
Grade smallint(6),
primary key(Sno,Cno),
foreign key(Sno) references student(Sno),
foreign key(Cno) references course(Cno)
);
create table hello(id int,name varchar(20),CONSTRAINT 别名 PRIMARY KEY (id,name));
修改列名:
alter table sc change column Sno sno char(3);
where
子句中不能使用聚集函数,聚集函数只能用于select
子句和group by
的having
子句。
group by
对结果进行分组处理,使用having
进一步进行细化结果。
where
子句作用于基本表和视图;having
子句作用于组,操作对象是每个组中的指定元素。
查看所有视图:
show table status where comment='view';