--建表
create table STUDENT
(
ID NUMBER(20),
NAME VARCHAR2(20),
SEX VARCHAR2(3)
);
INSERT INTO STUDENT (ID, NAME, SEX) VALUES (1, 'LI', '女');
INSERT INTO STUDENT (ID, NAME, SEX) VALUES (2, 'ZHAO', '男');
INSERT INTO STUDENT (ID, NAME, SEX) VALUES (3, 'Tom', '男');
COMMIT ;
1.修改表名
--将student修改成STUDENTS
ALTER TABLE STUDENT RENAME TO STUDENTS;
--将students修改成student
ALTER TABLE STUDENTS RENAME TO STUDENT;
2.修改字段名
--将字段name修改成names
ALTER TABLE STUDENT RENAME COLUMN NAME TO NAMES;
3.修改数据类型
--将字段sex修改成char类型
ALTER TABLE STUDENT MODIFY SEX CHAR(3);
4.增加age字段
ALTER TABLE STUDENT ADD AGE NUMBER;
5.删除age字段
ALTER TABLE STUDENT DROP COLUMN AGE;