Oracle Database Common Operations commands

Source: Internet
Author: User

User's login:

[Username/password] [@server] [As Sysdba/sysoper] Example: Sys/pass as Sysdba

User's switchover:

[Connect] [Username/password] [@server] [As Sysdba/sysoper] Example: Connect system/pass

Show currently logged in User:

Show user

Display the fields in the data dictionary:

Desc dba_users

Desc table_spaces

Desc user_tablespaces

Desc user_users

Desc dba_data_files

Desc dba_temp_files

Desc Dba_role_privs

To create a user and specify a tablespace:

CREATE USER username identified by password
DEFAULT tablespace Test_data
Temporary tablespace test_temp;

Granting permissions to users:

GRANT
Create SESSION, create any TABLE, create any VIEW, create any INDEX,

CREATE any procedure,alter any TABLE, ALTER any PROCEDURE,

Drop any TABLE, drop no VIEW, drop any INDEX, drop any PROCEDURE,
SELECT any table, INSERT any table, UPDATE all table, DELETE any table
to username;

The role is granted to username:

GRANT role to username;

To set the default or temporary tablespace for a user:

ALTER USER username default| Temporary tablespace tablespace_name

To create a table space:

CREATE [temporary] tablespace tablespace_name tempfile| DataFile ' xx.dbf ' SIZE xx;

Example:

To create a temporary tablespace:

CREATE Temporary tablespace test_temp

Tempfile ' D:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf '

SIZE 32M
Autoextend on
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;

To create a user table space:

    CREATE tablespace Test_data
LOGGING
DataFile ' D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\TEST_DATA01. DBF '
SIZE 32M
Autoextend on
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;

To modify the state of a tablespace:

To set the online or offline status of a tablespace:

ALTER tablespace tablespace_name online| OFFLINE

To set tablespace read-only or read-write status:

ALTER tablespace tablespace_name READ only| READ WRITE

To modify a table space's data file:

Add data files:

ALTER tablespace tablespace_name ADD datafile ' xx.dbf ' SIZE xx

To delete a data file:

ALTER tablespace tablespace_name DROP datafile ' xx.dbf '

To delete a table space:

DROP tablespace tablespace_name [including CONTENTS]

  

Oracle Database Common Operations commands

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.