Oracle Database Pure DOS code operation

Source: Internet
Author: User
Tags dba sqlplus

1, after successful installation into the DOS interface operation

You need to start the Oracle service when you do the following.

A, enter the SQL interface: Start-run--cmd: input Sqlplus Enter

Prompt to enter the correct user name and password

B, start and All Programs-àoracle-à Run SQL command, directly enter with conn username/password

The default user name is Sys,system.

The password is the password you installed

Enter the correct user name and password to enter the interface.

2. Password modification

When you forget your password, you can use

Sqlplus sys/aaa as sysdba;--logged in as a database administrator. If you are logged on as a native

The password can be entered freely. Where Sys is a user name and AAA is the password for that user name

Change Password:

Modify the password for the system user is System

Alter user system identified by system;

Alter user identified by is a keyword.

3. Switch User operation

A, first exit and then login

Exit;

1. Login command sqlplus system/system Direct login

2, Sqlplus

--Prompt to enter user name

--Prompt to enter a password

B, can also not quit directly in the sql> operation with Conn Scott/tiger conn/username/password Switch user

Note: No semicolon ends when logging in.

4. The tables in Oracle are categorized according to the user.

SYS Super User (highest privilege)

System Database Administrator (performs most administrative operations)

Customizing user test users

5. Simple Getting Started command

SELECT * FROM tabs,---Query the current user under what table (Multi-query system table);

Select table_name from User_tables; ---queries the names of all tables under the current user.

DESC table name---See which columns (the structure of the table) are in the table, and DESC is the abbreviation for describe

6. Create User commands

A, connect to the user sql> conn System/root

B. Create a User: Sql> created users Scott identified by Tiger;

C, switch User:sql> conn Scott/tiger//user switch failed

Not logged on

Note: The user does not have the session permission to prompt.

So you should assign session permissions

7. Assigning Permissions

Grant permission name to user name;

Sql> Conn system/root;//First step switch to Administrator

Sql> Grant create session to Scott; Authorized for User

Grant succeeded//is authorized to succeed

Note When authorized, Scott can log on, but when the user creates the table, the permissions are insufficient. In Oracle, you assign permissions to users through their roles. Detailed Reference role

8. Role (one role contains multiple permissions)

Connect

Create session

CREATE table

......

Resource

Use permissions on a table space

......

Grant Connect,resource to Scott;

Note: 1, the user's creation, the allocation of rights, only the administrator can operate, ordinary users can not be implemented.

2, Create user username identified by password; (not full number)

3, Grant create session,create table,resource to user name;//assign permissions to users

4, start directory (D:/EMP.SQL);//Note that the file cannot be placed on the desktop for what (the directory cannot contain spaces otherwise the following error occurs:

sql> start c:/a a a/emp.sql;

Error reading file

)

Complete the Operation case:

Sql> Conn system/red; Switch to System user, password is red

Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0

Connected as System

Sql> create user Redarmychen identified by Redarmy; Create a user and set the password for the user to Redarmy

User created

Sql> Grant Connect,resource to Redarmychen; Authorizing the user to Connect,resource

Grant succeeded

Sql> Conn Redarmychen/redarmy; Switch to the newly created user

Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0

Connected as Redarmychen

sql> start c:/emp.sql; How to import external SQL files

Sql> select * from tabs; Query all tables below the user

Sql> Select table_name from User_tables; Query the names of all the tables under the user

table_name

------------------------------

PRODUCT

ORDERS

OrderItem

Tmp

PAGES

STUDENT

COURSE

Sc

TEST

DEPT

Emp

Salgrade

USERS

Rows selected

Sql> desc Product//View the structure of the product table

Name Type Nullable Default Comments

----------- ------------ -------- ------- --------

PRODUCTID Number (6)

PRODUCTNAME VARCHAR2 (30)

Price Number (10,2)

SQL Plus common commands

L conn Switch Connecting user

L DESC Display Table structure

L host executes operating system commands

L Start Execute File system SQL statement

L Exit

L Col Formatted output

L/execute a recent SQL or new definition procedure

L Startup DB Instance (DBA)

L Shutdown Close db instance (DBA)

Attention:

The startup shutdown must be a sys system user to perform

Other users cannot use the. And this command can only be executed in sqlplus. Cannot be used in client tools.

Oracle Database Pure DOS code operation

Related Article

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.