oracle之DDL

创建表

create table student(
id number(5),
name varchar2(50),
age number(2),
sex varchar2(2)
);

重命名

rename student to stu;

添加备注(表和字段)&查询当前用户下的所有(表和字段)的备注

comment on table stu is '学生表';
comment on column stu.id is 'ID';
comment on column stu.name is '学生名称';
comment on column stu.age is '学生年龄';
comment on column stu.sex is '学生性别';

select * from user_tab_comments;
select * from user_col_comments;

修改表结构

# 修改表字段类型
alter table stu modify sex number(1);
# 增加表字段
alter table stu add grade number(1);
# 删除表字段
alter table stu drop  COLUMN sex;

-- 修改表中的列名
alter table stu rename  COLUMN grade to grades;

删除表

-- 删除表
drop table stu;
posted @ 2022-09-04 20:38  King-DA  阅读(11)  评论(0)    收藏  举报