ORALCE表基本操作

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33051685/article/details/84988797

1.创建表空间

–用于查询现在有的表空间的存储位置
select * from dba_data_files;

–datafiele 替换成自己需要的存储位置
create tablespace ehc
logging
datafile ‘C:\oracle\oradata\Oracle11\ehc.dbf’
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;

–设置账号和密码
create user ehc identified by ehc default tablespace ehc;

–赋权限给设置好的账号
grant connect,resource,dba to ehc;

2.创建表,如:
create table tab_car_info(
car_id number not null,
car_no varchar2(20) not null,
car_color number(2),
company_id number,
car_economy_type number(4),
primary key(car_id)
)

–添加备注
comment on table tab_car_info is ‘车辆信息表’;
comment on column tab_car_info.car_id is ‘车辆id’;
comment on column tab_car_info.car_no is ‘车牌号’;
comment on column tab_car_info.car_color is ‘车牌颜色 1-蓝色,2-黄色,3-黑色,4-白,9-其它’;
comment on column tab_car_info.company_id is ‘所属车企’;
comment on column tab_car_info.car_economy_type is ‘经营类型’;

3.修改表字段
–字段重命名
alter table original_tableName rename column PIC to NEWPIC;

–删除字段
alter table rig drop column syscontplan ;

–添加字段
alter table rig add syscontplan varchar2(10) ;

–修改字段
alter table Tab_Elec_Point modify(car_type NUMBER(3));

4.修改表
–表重命名
alter table original_tableName rename to dest_tableName ;

创建序列
CREATE SEQUENCE SEQ_DEMO
INCREMENT BY 1
START WITH 1
NOMAXvalue
NOCYCLE
NOCACHE;

猜你喜欢

转载自blog.csdn.net/qq_33051685/article/details/84988797
今日推荐