--
首先需要创建一个表空间
-- 1.创建表空间
-- 2.规定文件路径
-- 3.设定文件大小 自动增长打开
create tablespace Product
datafile ' e:\product.dbf '
size 10m autoextend on ;
-- 创建用户
-- 1.创建用户
-- 2.设定密码
-- 3.设定默认的表空间
create user prod
identified by prod
default tablespace Product;
-- 删除用户
-- 1.删除用户和用户所有的模式对象
-- 2.删除用户
drop user prod cascade ;
drop user prod;
-- 授权用户登陆数据库权限(system名下)
grant connect to Prod;
-- 授权用户创建表权限(system名下)
grant resource to Prod;
-- 用户a授权b操作表的权限
-- 1.a给予b查询权限
-- 2.a给予b更新权限
grant select on a to b;
grant update on a to b;
-- 创建表
create table ProductDetails
(
Pro_no number ,
Pro_id varchar2 ( 10 ),
Pro_name varchar2 ( 10 ),
Pro_price number ( 3 )
)
;
-- 察看表的数据类型
desc ProductDetails;
-- 更新表(表必须为空)
-- 1.修改表的字段
-- 2.向表中添加新列
-- 3.删除表的一个字段
alter table ProductDetails
modify(Pro_no int not null primary key );
alter table ProductDetails
add (Pro_count int );
alter table ProductDetails
drop colum Pro_count;
-- 1.创建表空间
-- 2.规定文件路径
-- 3.设定文件大小 自动增长打开
create tablespace Product
datafile ' e:\product.dbf '
size 10m autoextend on ;
-- 创建用户
-- 1.创建用户
-- 2.设定密码
-- 3.设定默认的表空间
create user prod
identified by prod
default tablespace Product;
-- 删除用户
-- 1.删除用户和用户所有的模式对象
-- 2.删除用户
drop user prod cascade ;
drop user prod;
-- 授权用户登陆数据库权限(system名下)
grant connect to Prod;
-- 授权用户创建表权限(system名下)
grant resource to Prod;
-- 用户a授权b操作表的权限
-- 1.a给予b查询权限
-- 2.a给予b更新权限
grant select on a to b;
grant update on a to b;
-- 创建表
create table ProductDetails
(
Pro_no number ,
Pro_id varchar2 ( 10 ),
Pro_name varchar2 ( 10 ),
Pro_price number ( 3 )
)
;
-- 察看表的数据类型
desc ProductDetails;
-- 更新表(表必须为空)
-- 1.修改表的字段
-- 2.向表中添加新列
-- 3.删除表的一个字段
alter table ProductDetails
modify(Pro_no int not null primary key );
alter table ProductDetails
add (Pro_count int );
alter table ProductDetails
drop colum Pro_count;