sqlplus /nolog
回车后,将出现提示符 SQL>
这时输入
conn / as sysdba
一般即可登录,如果失败的话,可以试一下用conn sys/sys用户的密码 as sysdba来重试一下
接下来,我们看看您当前的数据库文件一般都是放在哪里的:
select name from v$datafile;
windows下可能看到的结果如下:
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
D:\oracle\oradata\orcl\system01.dbf
D:\oracle\oradata\orcl\undotbs01.dbf
D:\oracle\oradata\orcl\cwmlite01.dbf
D:\oracle\oradata\orcl\drsys01.dbf
D:\oracle\oradata\orcl\indx01.dbf
D:\oracle\oradata\orcl\tools01.dbf
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/oracle/oradata/orcl/system01.dbf
/oracle/oradata/orcl/undotbs01.dbf
/oracle/oradata/orcl/cwmlite01.dbf
/oracle/oradata/orcl/drsys01.dbf
/oracle/oradata/orcl/indx01.dbf
/oracle/oradata/orcl/tools01.dbf
create tablespace yang datafile 'D:\oracle\oradata\orcl\yang.dbf' size 3000m;
3000m指的是3000MB
对于上述的Linux的情况:
create tablespace yang datafile '/oracle/oradata/orcl/yang.dbf' size 3000m;
至此,所需的表空间已建立。
接下来我们开始创建用户,创建用户的命令格式如下:
create user 用户名 identified by 密码 default tablespace 用户默认使用哪一个表空间;
修改用户的权限:
grant 角色1,角色2 to 用户名;
举例如下:
create user yanglei identified by yang123 default tablespace yang;
grant dba, connect to yanglei;
授权成功。 ps:下面看下Oracle创建用户的方法,具体代码如下所示: 创建用户
-- Create the user
create user MEP
identified by whq1987
default tablespace MEP
temporary tablespace MEP_TEMP
profile DEFAULT;
-- Grant/Revoke role privileges
grant connect to MEP;
grant datapump_exp_full_database to MEP;
grant datapump_imp_full_database to MEP;
grant dba to MEP;
grant exp_full_database to MEP;
grant imp_full_database to MEP;
grant resource to MEP;
-- Grant/Revoke system privileges
grant alter_user to MEP;
grant comment any table to MEP;
grant create any view to MEP;
grant create session to MEP;
grant create user to MEP;
grant delete any table to MEP;
grant drop user to MEP;
grant export full database to MEP;
grant unlimited tablespace to MEP;