DROP TABLE STUDY;
DROP TABLE STUDENT;
DROP TABLE COURSE;
/
CREATE TABLE STUDENT
(
SID VARCHAR(10),
SName varchar(30),
primary key (SID)
);
/
CREATE TABLE COURSE
(
CID VARCHAR(10),
CName varchar(50),
primary key (CID)
);
/
CREATE TABLE STUDY
(
SID VARCHAR(10),
CID VARCHAR(10),
SCORE INTEGER DEFAULT 0 CHECK (SCORE between 0 and 100),
constraint PK_STUDY PRIMARY KEY (SID) --注意此处设置主键约束名,便于后面修改表的主键
);
/
COMMIT;
/
select * from student;
select * from study;
/
--以表 student,study,score 为例
--1.增加列
alter table student add (sex varchar2(2) DEFAULT '女',age integer,address varchar(100)) ;
/
--2.修改列定义
ALTER TABLE student MODIFY s