SQL那些事儿(四)--oracle创建表空间、用户创建

来源:互联网 发布:软通动力java试题2016 编辑:程序博客网 时间:2024/05/17 01:14
1、select tablespace_name,file_id, file_name,round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name; 



 2、创建临时表空间

create temporary tablespace db_temp

tempfile 'C:\app\xcy\oradata\orcl\db_temp.dbf'
size 32m
autoextend on
next 32m maxsize unlimited
extent management local; 



3、创建表空间

create tablespace DNC

logging
datafile 'C:\app\xcy\oradata\orcl\dnc.dbf'
size 32m
autoextend on
next 32m maxsize unlimited
extent management local;


4、创建用户

create user xxx identified by 123

account unlock
default tablespace dnc
temporary tablespace db_temp;

5、授予权限

grant connect,resource,dba to xxx;


路径可以自己设置,

最终用户名:xxx

密码:123

//////////////////////////////////////////////////////////////////
//查询表空间大小;
select tablespace_name,file_id,bytes,file_name from dba_data_files;
//修改表空间大小
alter database datafile 'C:\app\xcy\oradata\orcl\USERS01.DBF' resize 800M;
//查看用户所在表空间
select default_tablespace from dba_users where username ='XCY';
///////////////////////////////////////////////////////////////////////////////////
grant create session to testcreate;
grant CREATE TABLE to xxx;

grant unlimited tablespace to xxx;



补充:

由于Oracle 11g安装完成后,默认的帐户有效期为180天,如果超过180天用户密码未做修改则该用户无法登录,提示“ORA-28001: thepassword has expired”。一般我们都是通过IE管理界面去修改为Unlimited(无限制),如果不登录IE,在pl/sql中用如下语句:

查看有效期​

SQL>select* from dba_profiles where profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';

修改有效期为无限制​

SQL>alter profile default limit PASSWORD_LIFE_TIME unlimited;


0 0
原创粉丝点击