一、启动数据库
1、查看数据库是否启动
[root@localhost ~]#su oracle
bash-3.2$ ps -ef|grep smon
oracle 4642 4608 0 12:08 pts/2 00:00:00 grep smon
bash-3.2$
发现没有启动
2、先启动监听器
bash-3.2$ lsnrctlstart
LSNRCTL for Linux:Version 11.2.0.1.0 - Production on 03-JAN-2015 12:09:45
Copyright (c) 1991,2009, Oracle. All rights reserved.
Starting/u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux:Version 11.2.0.1.0 - Production
System parameterfile is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages writtento /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of theLISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version11.2.0.1.0 - Production
Start Date 03-JAN-2015 12:09:45
Uptime 0 days 0 hr. 0 min. 20 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener ParameterFile /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener LogFile /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening EndpointsSummary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
The listenersupports no services
The commandcompleted successfully
监听器启动成功
3、启动数据库
bash-3.2$ sqlplus /as sysdba
SQL*Plus: Release11.2.0.1.0 Production on Sat Jan 3 12:11:38 2015
Copyright (c) 1982,2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL>
连接到了一个空的实例
4、启动数据库实例
SQL> startup
ORACLE instancestarted.
Total System GlobalArea 839282688 bytes
FixedSize 2217992 bytes
VariableSize 503318520 bytes
DatabaseBuffers 327155712 bytes
RedoBuffers 6590464 bytes
Databasemounted.
Databaseopened.
SQL>
数据库实例启动成功,这个启动时间跟机器性能有关。
5、创建表空间
SQL> createtablespace com datafile '/u01/app/oracle/oradata/com/com01.dbf' size 50mautoextend on;
Tablespacecreated.
6、创建用户,设置默认表空间
SQL>create user studyuser identified by aaaaaa default tablespace com;
User created.
7、授权
SQL> grantconnect,resource to studyuser;
Grantsuccessded.
Connect和resource是两个角色,把这两个角色赋予studyuser,studyuser就具有了这两个角色的权限。
8、测试
SQL> show user
USERis "SYS"
说明目前是sys用户
切换用户
SQL> connstudyuser/ab2008
Connected.
SQL> show user
USERis "STUDYUSER"
SQL> create tabletest (id number, name varchar2(20));
Tablecreated.
SQL> insert intotest values (1,'dbstyle');
1 row created.
SQL> select *from test;
ID NAME
------------------------------
1 dbstyle
SQL> commit;
Commitcomplete.
暂时离开数据库,到linxu环境,
SQL> !
bash-3.2$ exit
exit
SQL>