您的位置:首页 > 数据库 > Oracle

oracle sqlplus基本操作

2012-09-04 15:39 489 查看
说明:以下操作均在windows cmd下进行

进入sqlplus:
sqlplus /nolog

登录Oracle数据库管理员
conn username/password as sysdba;

查看数据库中的用户
select username,account_status from dba_users;

给scott用户解锁
alter user scott account unlock;

给scott用户修改密码
alter user scott identified by aa123;

登录scott用户
conn scott/aa123

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/*创建用户及其表空间分为四步 */
/*第1步:创建临时表空间  */
create temporary tablespace user_temp
tempfile 'D:\oracle\oradata\Oracle9i\user_temp.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;

/*第2步:创建数据表空间  */
create tablespace test_data
logging
datafile 'D:\oracle\oradata\Oracle9i\user_data.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;

/*第3步:创建用户并指定表空间  */
create user username identified by password
default tablespace user_data
temporary tablespace user_temp;

/*第4步:给用户授予权限  */
grant connect,resource,dba to username;

删除表空间,临时表空间
DROP TABLESPACE user_temp INCLUDING CONTENTS AND DATAFILES;
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

向scott用户导入表结构和数据
sql>@E:\report_data.sql;

查看用户下得所有表
Select table_name from user_tables;

查看表中字段
Select column_name from user_tab_columns where table_name=’*****’;


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息