Playing with oracle study notes (1) - Oracle management

1. Uninstallation of Oracle

1. Run oracle's universal installer

2. Run regedit, enter the registry, select HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE, and delete the key value as shown below.

 

Select the key value starting with Oracle under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.


3. Restart the computer and delete the ORACLE directory on the hard disk

If the directory is not allowed to be deleted, then change the directory to another name, restart the machine, and delete it.

4. Delete the Oracle directory under Program Files

 

2. Oracle management tools

1. SQL Plus

The tool software that comes with oracle is mainly used to execute SQL statements and pl\sql blocks.

Open method:

a. Start->Programs->Oracle – OraHome92->Application Development->SQL Plus

b. Enter in the run bar: sqlplusw

c. Start->Programs->Oracle – OraHome92->Application Development->SQL Plus Worksheet

 

2. Operation under sqlplus dos

Similar in function to SQL Plus

Open method:

a. Enter sqlplus in the run bar

b. Find the executable file sqlplus.exe, in the oracle home directory \ora92\bin\sqlplus.exe, double-click the mouse

 

3. Oracle Enterprise Manager (oem oracle enterprise manager)

Start -> Programs -> Oracle - OraHome92->Enterprise Manager Console to start Oracle's Enterprise Manager, which is a graphical interface environment.

 

4. pl/sql developer

It belongs to third-party software and is mainly used to develop, test, and optimize Oracle pl/sql stored procedures, such as triggers.

 

3. SQL Plus Common Commands

1. Connection command

(1).conn[ect]

Usage: conn username/password@network service name [as sysdba/sysoper]

When connecting as a privileged user, you must bring as sysdba or as sysoper

(2).disc[onnect]

Description: This command is used to disconnect from the current database.

(3) .passw [word]

Description: This command is used to modify the user's password. If you want to change the password of other users, you need to log in with sys/system.

(4).show user

Description: Displays the current user name

(5).exit

Description: This command will disconnect from the database and exit SQL Plus

 

2. File Operation Commands

(1).start and @

Description: run sql script

Such as: sql>@ d:\a.sql or sql>START d:\a.sql

(2).edit

Description: This command can edit the specified sql script

Such as: sql>edit d:\a.sql

(3).spool

Description: This command can output the contents of the SQL Plus screen to the specified file.

For example: sql>spool d:\b.sql and enter sql>spool off

 

3. Interactive commands

(1).&

Description: You can substitute a variable that requires user input when it is executed.

Sql>select * from emp where job=’&job’

(2).edit

Same as above file operation command

(3).spool

Same as above file operation command

 

4. Display and set environment variables

Overview: It can be used to control various formats of output. If you want to permanently save related settings with set show, you can modify the glogin.sql script.

(1).linesize

Description: Set the width of the display line, the default is 80 characters

sql>show linesize

sql>set linesize 90

(2)pagesize

Description: Set the number of lines displayed on each page, the default is 14

Usage is the same as linesize

The use of other environmental parameters is also similar

 

4. Management of Oracle users

1. Create a user

Overview: To create a new user in Oracle, use the create user statement, which is generally only available with dba (database administrator) authority.

create user username identified by password

 

2. Change the password for the user

Overview: Modify the password for yourself and use it directly

sql>password username

If you want to change the password for others, you need to have dba authority, or have the system authority of alter user

sql>alter user username identified by new password

 

3. Delete user

Overview: Generally, a user is deleted as a dba. If another user is used to delete a user, the permission of drop user is required.

For example drop user username [cascade]

 

4. Comprehensive case of user management

Overview: The new user created does not have any authority, not even the authority to log in to the database, and needs to be assigned the corresponding authority. Use the command grant to grant permissions to a user, and use the command revoke to revoke permissions.

 

Fives. Oralce Privilege Management

1. sys has the permission to create database, but system does not. Other sys is similar to system. In the daily management of oracle, it is enough to use system.

2. When deleting a user, if the user to be deleted has already created a table, the cascade parameter needs to be included when deleting.

3. Example of an empowerment statement

        a) I hope xiaoming users can query scott's emp table

grant select on emp to xiaoming

        b) I hope xiaoming users can modify scott's emp table

grant update on emp to xiaoming

        c) I hope xiaoming users can modify, delete, query and add scott's emp table

grant all on emp to xiaoming

        d) scott wants to revoke xiaoming's query permission on the emp table

revoke select on emp from xiaoming

        e) I hope that Xiaoming users can query Scott's emp table, and also hope that Xiaoming can continue to give this permission to others

If it is an object permission, add with grant option

grant select on emp to xiaoming with grant option

If it is a system permission, add with admin option when system gives xiaoming permission

grant connect to xiaoming with admin option

        f) If scott reclaims xiaoming's query permission on emp table, then the query permission on emp table assigned by xiaoming to other users (such as xiaohong) will also be reclaimed (ie cascade recovery mechanism)

 

six. Use profiles to manage user passwords

         Overview: Profile is a command set of password restrictions and resource restrictions. When a database is created, Oracle will automatically create a profile named default. When creating a user without specifying the profile option, Oracle will assign default to the user.

1. Account Lockout

Specify the maximum number of times the account (user) can enter the password when logging in, and also specify the time (days) for the user to lock. Generally, the dba identity is used to execute this command.

Example: Specify that the user scott can only attempt to log in at most 3 times, and the lock time is 2 days.

create profile lock_account limit failed_login_attempts 3 password_lock_time 2;

alter user xiaoming profile lock_account;

2. Unlock the account (user)

alter user xiaoming account unlock;

3. Terminate password

In order to allow the user to periodically change the password, the command to terminate the password can be used, and this command also requires the dba identity to operate.

Example: Create a profile file for the previously created user xiaoming, and require the user to change the login password every 10 days, with a grace period of 2 days.

create profile myprofile limit password_life_time 10 password_grace_time 2;

alter user xiaoming profile myprofile

4. Password History

If you want users to change their passwords, they can't use the previously used passwords, you can use the password history, so Oracle will store the password modification information in the data dictionary. Comparison, when the old and new passwords are found to be the same, the user is prompted to re-enter the password.

example:

a). Create a profile

create profile password_history limit password_life_time 10 password_grace_time 2 password_reuse_time 10

password_reuse_time //Specify the reusable time of the password, that is, it can be reused after 10 days

b). Assign to a user

5. Delete profile

        When a profile file is not needed, it can be deleted.

drop profile password_history [cascade]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326341859&siteId=291194637