2024年5月11日发(作者:)

第一篇 基本操作

--解锁用户 alter user 用户 account unlock;

--锁定用户 alter user 用户 account lock;

alter user scott account unlock;

--创建一个用户yc 密码为a create user 用户名 identified by 密码;

create user yc identified by a;

--登录不成功,会缺少create session 权限,赋予权限的语法 grant 权限名 to 用户;

grant create session to yc;

--修改密码 alter user 用户名 identified by 新密码;

alter user yc identified by b;

--删除用户

drop user yc ;

--查询表空间

select *from dba_tablespaces;

--查询用户信息

select *from dba_users;

--创建表空间

create tablespace ycspace

datafile 'E:oracleappproduct11.2.0dbhome_'

size 2m

autoextend on next 2m maxsize 5m

offline ;

--创建临时表空间

create temporary yctempspace

tempfile 'E:oracleappproduct11.2.0dbhome_'

size 2m

autoextend on next 2m maxsize 5m

offline ;

--查询数据文件

select *from dba_data_files;

--修改表空间

--1、修改表空间的状态

--默认情况下是online,只有在非离线情况下才可以进行修改

alter tablespace ycspace offline ; --离线状态,不允许任何对象对该表空间的使用,使用情况:

应用需要更新或维护的时候;数据库备份的时候

alter tablespace ycspace read write;--读写状态

alter tablespace ycspace online;

alter tablespace ycspace read only; --只读,可以查询信息,可以删除表空间的对象,但是不能

创建对象和修改对象 。使用情况:数据存档的时候

--2、修改表空间的大小

--增加文件的大小

alter database datafile 'E:oracleappproduct11.2.0dbhome_' resize 10m;

--增加数据文件

alter tablespace ycspace add datafile 'E:oracleappproduct11.2.0dbhome_' size

2m;

--删除表空间的数据文件

alter tablespace 表空间的名字 drop datafile 数据文件名;

--删除表空间

drop tablespace ycspace;

--删除表空间且表空间中的内容和数据文件

drop tablespace ycspace including contents and datafiles;

--指定表空间 的 创建用户的语法

create user yc1 identified by a default tablespace ycspace temporary tablespace temp;

--删除用户

drop user yc1;

--权限

--赋予创建会话的权限

grant create session to yc1;

--创建一个表

create table studentInfo(

sid int,

sname varchar2(10)