第一步,以最高级别 SYSDBA 身份登录数据库
cmd 进入命令行
登录方式一:
C:\Documents and Settings\Administrator>sqlplus sys/sys as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 5 月 2916:08:00 2010
Copyr ight (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OL AP and Data Mining options
SQL>
登录方式二:
C:\Documents and Settings\Administrator>sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 5 月 2916:27:31 2010
Copyr ight (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn sys/sys@orcl as sysdba
已连接。
SQL>
登录方式三:
C:\Documents and Settings\Administrator>sqlplus
SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 5 月 2916:28:45 2010
Copyr ight (c) 1982, 2005, Oracle. All rights reserved.
请输入用户名: sys@orcl as sysdba
输入口令:
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OL AP and Data Mining options
SQL>
登录方式四:
C:\Documents and Settings\Administrator>sqlplus
SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 5 月 2916:31:18 2010
Copyr ight (c) 1982, 2005, Oracle. All rights reserved.
请输入用户名: scott
输入口令:
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OL AP and Data Mining options
SQL> conn sys/sys@orcl as sysdba;
已连接。
SQL>
登录方式五:
C:\Documents and Settings\Administrator>sqlplus sys/sys@orcl as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 5 月 2916:37:18 2010
Copyr ight (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OL AP and Data Mining options
SQL>
============================================================================================
第二部:创建表空间
1、创建表空间
create tablespace tb_nanc
datafile 'C:\Javawork\oracle10g\productd\oradata\orcl\tb_nanc.dbf'
size 50M
autoextend on next 50m maxsize 2048m
extent management local;
创建表空间 名为:tb_nanc,
存放文件地址为 C:\Javawork\oracle10g\productd\oradata\orcl\
表空间大小为 50M,超过了就自动增加 50M,最大 2G,
2、创建临时表空间
create temporary tablespace tb_nanc_temp
tempfile
'C:\Javawork\oracle10g\productd\oradata\orcl\tb_nanc_temp.dbf'
size 32m
autoextend on next 32m maxsize 1024m
extent management local;
创建临时表空间 名为:tb_nanc_temp,
存放文件地址为 C:\Javawork\oracle10g\productd\oradata\orcl\
临时表空间大小为 32M,超过了就自动增加 32M,最大 1G
3、删除表空间及数据
drop tablespace tb_nanc including contents and datafiles;
drop tablespace tb_nanc_temp including contents and datafiles;
DROP TABLESPACE TBS01 INCLUDING CONTENTS AND DATAFILES
select * from dba_data_files
alter database default tablespace system;(更改默认表空间)
============================================================================================
第三部:创建用户并授权
1、创建用户
create user tb_nanc identified by tb_nanc default tablespace tb_nanc
temporary tablespace tb_nanc_temp;
创建了用户 tb_nanc 密码是 tb_nanc
默认在表空间 tb_nanc 和临时表空间 tb_nanc_temp 里面。
2、给用户授权
1,grant connect,resource to tb_nanc;
将 connect,resource 角色权限授权给 tb_nanc
2,grant dba to tb_nanc;
将 dba 角色权限授权给 tb_nanc
3、撤销权限
revoke dba on table1 from zhangch //收回权限
revoke dba from zhangch
数据库特权 说明
DBA 数据库创建者/所有者。能够授予数据库中的其他对象上的特权。
Resource 能够连接到数据库并创建其他对象。
Connect 能够连接到数据库执行查询。
3、如果用户被锁住了,就用语句给解开
alter user tb_nanc account unlock;
==========================