Common Oracle commands in Linux
Common Oracle commands in Linux
1. Start the oracle database:
// Switch to an Oracle user:
[Root @ server36 ~] # Su-oracle
// Enter the sqlplus environment. The nolog parameter indicates no Logon:
[Oracle @ server36 ~] $ Sqlplus/nolog
// Log on as an administrator:
[Oracle @ server36 ~] $ Sqlplus/as sysdba
SQL * Plus: Release 11.2.0.3.0 Production on Fri Apr 17 10:13:07 2015
Copyright (c) 1982,201 1, Oracle. All rights reserved.
Connected.
// Start the database
SQL> startup
// Stop the database
SQL> shutdown immediate
2. Database listening:
// Start the listening service
[Root @ server36 ~] # Su-oracle
[Oracle @ server36 ~] $ Lsnrctl start
// Stop the listening service
[Oracle @ server36 ~] $ Lsnrctl stop
// View the listener status
[Oracle @ server36 ~] $ Lsnrctl status
3. user permission management:
Note: The following commands require the DBA permission.
// Create a user
Create user ittbank identified by 123456;
// Grant the tablespace permission to the user
Alter user ittbank default tablespace ittbank ;;
// Or combine the two commands
Create user ittbank identified by 123456 default tablespace ittbank;
(Note: The newly created user does not have any permissions and does not have logon permissions. Therefore, you need to continue the authorization operation, but must be an authorized user, such as sys and system. A role is a set of system permissions. When a user is generally authorized, if no role exists, separate operations are required. Generally, a role consists of multiple system permissions. Common roles have three connect (7 permissions), dba and resource (create tables in any tablespace )).
// Grant user management Permissions
Grant connect, resource, dba to ittbank;
// Delete a user
Drop user "name" cascade;
(Note: The cascade parameter is used to cascade all objects of the user. if the user has an object but does not add this parameter, the user cannot delete it. Therefore, this parameter is habitually added. The quotation marks of "name" are the same .)
4. Data Tables and tablespaces:
// Create a tablespace
Create tablespace ittbank datafile '/u01/app/oracle/oradata/ORCL/ittbank. dbf' size 300 m autoextend on;
Note: The autoextend on Parameter at the end indicates that the table space will be automatically resized when the tablespace size is insufficient. We recommend that you add the autoextend on parameter to all tables.
// Query the current tablespace
Select * from v $ tablespace;
// Query all tablespaces
Select * from sys. dba_tablespaces; -- Query table space
// View the current number of user connections
Select count (*) from sys. v _ $ session;