First day of Oracle database learning

Source: Internet
Author: User

Crud additions and deletions change create read update delete
Installation of the 1--oracle database
system default creation of two user sys and system password customization
Super admin: Sys
Administrator: System
Password: 5615
2--Starting a database service
Service
Listener


3--Accessing the database
Using Oracle's own client Tools Sqlplus (Prerequisites: Adding D:\oracle\app\oracle\product\11.2.0\server\bin in Path)
Wind+r Key to open the Run window
Input: Sqlplus return
Prompt for user name and password
SYS and password cannot be directly logged into the database
System and password can log in directly to the database description: This method can only be logged in as a normal user
If you want to log in to the database with SYS
Wind+r key input Sqlplus sys/5615 as SYSDBA; Enter
View the login name of the current user
Show user; Enter

4--starting and shutting down the database
To close the database:
Shutdown immediate;
Start the database:
startup Open;
SYS can start and close the database
System does not have this permission

5--the operation of the database user
SYS Create User:
Create user Owen identified by 123;
After the user is created, the default is locked, and no roles are assigned, and the user needs to be unlocked
Alter user Owen account unlock;
SYS assigns roles to users
Grant Connect to Owen;
You can now log in to the database using the Owen user, but only the login permissions
Conn owen/123;
SYS assigns the user the resource role
Grant resource to Owen;
This allows you to manipulate objects under the current Owen user.
CREATE TABLE Owen_record (login_time varchar (19));
If you need to turn a user into a super administrator
Grant Sysdba to Owen;
Delete User
Drop user Owen;
Delete a user (remove all objects created by the user)
Drop user Owen Cascade;
Recovering sysdba roles from Owen users
Revoke SYSDBA from Owen;
Querying all table names under the current user role
Select table_name from User_tables;

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

Tablespace table Space
is the largest logical structure in the Oracle database
Logically, an Oracle database consists of several table spaces
Table space is closely related to the physical structure of a database, which corresponds to several data files on disk
Physically, the data in the database is stored in the data file, which logically means that the data is stored in the table space.
A data file can belong to only one table space, and a table space may have multiple data files
Oracle Data stores schema objects (tables, indexes, views, sequences) logically in a table space

|--Table Space 1
|--Table Space 2
|--Table Space 3
|--data file 1
|--Data File 2
|--Disk 1
|--data File 3
|--Disk 2
|--Data File 4
|--Disk 2


Create a temporary table space
Create temporary tablespace------The keywords for creating tablespace files
OWEN_TEMP------Table Space Name
Tempfile ' D:\oracle\user\owen_temp.dbf '------The path must be real
Size 100m------Initial size
Autoextend on------Turn on auto-expansion
Next 10m maxsize 1000m------size and maximum space per expansion

Create a data table space file statement
Create Tablespace
Owen_data
DataFile ' D:\oracle\user\owen_data.dbf '
Size 500m
Autoextend on
Next 20m maxsize 2000m

Create a user and specify a tablespace
Create user Owen identified by 123
Default Tablespace owen_data
Temporary tablespace owen_temp;

Unlock the user
Alter user Owen account unlock;

Authorization to the user
Grant Connect,resource to Owen;

Querying the specified user's tablespace in DBA role (username must be capitalized, single quotes must be used)
Select User_id,username,default_tablespace from dba_users where username = ' OWEN ';

Querying information for all table spaces
Select Tablespace_name,status,allocation_type from Dba_tablespaces;

Modify table space Names
Alter tablespace owen_data rename to New_owen_data;

Delete table space, delete only table space records
Drop Tablespace owen_data;

Delete Tablespace and tablespace files
Drop tablespace owen_data including contents and datafiles;

What are the entities (tables, indexes, views, sequences) permissions?
Select,update,insert,alter,index,delete,all (all includes all permissions)

SYS creates a table t_test
SYS grants user LP The right to select T_test tables
Grant Select on T_test to LP;

Conn LP/1;
Query the table
SELECT * from Sys.t_test;

Grant the user permission to all operations on this table
Grant all on T_test to LP;

Add a record
Insert into Sys.t_test (name) VALUES (' Owen ');


First day of Oracle database learning

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.