Common Oracle 11g commands

Source: Internet
Author: User

1. Listening
Start listening
LSNRCTL start
Stop listening
LSNRCTL stop
View listener status
LSNRCTL status

2. Start
Enter
Su-Oracle
Run the sqlplus command to enter the sqlplus environment. The nolog parameter indicates no logon;
Sqlplus/nolog
Enter in administrator Mode
Conn/As sysdba
Start Database
Startup;
Stop Database
Shutdown immediate

Remote database connection
Sqlplus/nolog
Conn sys/sys @ IP: 1521/orainstance as sysdba

You can also run the following command directly:
Dbstart // start the database script
Dbshut // stop the database script

Refer:
Startup [force] [restrict] [nomount] [migrate] [Quiet]
[Pfile = <file_name>]
[Mount [exclusive] <database_name> X |
Open <read {only | write [recover]} | recover>
<Database_name>]

Shutdown <normal | abort | immediate | transactional [local]>

3. user management
create a user
create user "username" identified by "userpassword";
note: the table space can be followed by
deleting a user
drop user "username" cascade;
note: the cascade parameter is used to cascade all objects of the user, users often encounter problems that users cannot delete objects without this parameter. Therefore, users habitually add this parameter
authorization
grant connect, resource, DBA to "username";
view the role of the current user
select * From user_role_privs;
select * From session_privs;
view the current user's system permissions and table-level permissions
select * From user_sys_privs;
select * From user_tab_privs;
query the user table
select username from dba_users;
modify the User Password
alter user "username" identified by "password ";
display current user
show user;

4. Tables and tablespaces
Create a tablespace
Create tablespace data01 datafile '/Oracle/oradata/DB/data01.dbf' size 500 m;
Delete a tablespace
Drop tablespace data01 including contents and datafiles;
Modify the tablespace size
Alter database datafile '/path/naddate05.dbf' resize 100 m;
Add tablespace
Alter tablespace newccs add datafile '/U03/oradata/newccs/newccs04.dbf' size 4896 m;
Query database files
Select * From dba_data_files;
Query the existing tablespace
Select * from V $ tablespace;
Table space
Select tablespace_name, sum (bytes)/1024/1024 from dba_data_files group by tablespace_name;
Query the remaining table space
Select tablespace_name, sum (bytes)/1024/1024 from dba_free_space group by tablespace_name;
View table structure
Desc table;

Modify connections: to restart the database
Alter system set processses = 1000 scope = spfile;
Shutdown immediate;
Startup;
View Current user connections
Select count (*) from SYS. V _ $ session;

PL/SQL

[Declare
/* Declaration, which is generally a variable and constant */]
[Begin
/* Execution part, process structure control, and SQL part */]
[Exception
/* Exception Handling part */]
End

set serveroutput on // turn on the output switch
begin
dbms_output.put_line ('Hello world! '); // Output result
end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.