database schema table index create-alter-drop
1.数据库的创建与删除和使用
create database SQL;
drop database SQL;
use SQL;
2.模式\架构的创建和删除(属于用于guest)
create schema TTY authorization guest;
drop schema TTY;
3.表的创建和删除(需要注意 只有表为unique才能被其他表当作外键)
create table Student(
Sno char(9) primary key,
Sname varchar(20) unique,
Sex char(2),
Sdept char(20)
);
4.修改表
alter table Student add Entrance date;
alter table Student add aha char(10);
alter table Student add zzc char(10) not null;
alter table Student drop column aha;
alter table Student alter column zzc int;
alter table Student drop constraint UQ__Student__1CC0725B1A14E395;
alter table Student add unique(Entrance);
alter table Student add unique(Aha);
5.索引的创建与删除
create unique index Courno on Course(Cno);
drop index Course.Courno;