Oracle First chapter: Log Management
1.forcing Log Switches
sql> alter system switch logfile;
2.forcing checkpoints
Sql> alter system checkpoint;
3.adding Online Redo Log groups
sql> ALTER DATABASE Add logfile [Group 4]
Sql> ('/disk3/log4a.rdo ', '/disk4/log4b.rdo ') size 1m;
4.adding Online Redo Log Members
sql> ALTER DATABASE Add logfile Member
Sql> '/disk3/log1b.rdo ' to group 1,
Sql> '/disk4/log2b.rdo ' to group 2;
5.changes the name of the online redo logfile
sql> ALTER DATABASE rename file ' C:/oracle/oradata/oradb/redo01.log '
sql> to ' C:/oracle/oradata/redo01.log ';
6.drop Online Redo Log groups
sql> ALTER DATABASE drop logfile Group 3;
7.drop Online Redo Log Members
sql> ALTER DATABASE drop logfile member ' C:/oracle/oradata/redo01.log ';
4.change the storage setting
sql> alter tablespace App_Data minimum extent 2m;
sql> alter tablespace app_data default storage (initial 2m next 2m maxextents 999);
5.taking tablespace offline or online
sql> alter tablespace App_Data offline;
sql> alter tablespace App_Data online;
6.read_only tablespace
Sql> alter tablespace App_Data read only|write;
7.droping tablespace
Sql> drop tablespace app_data including contents;
8.enableing automatic extension of data files
Sql> alter tablespace app_data add datafile ' c:\oracle\oradata\app_data01.dbf ' size 200m
Sql> Autoextend on next 10m maxsize 500m;
9.change the size fo data files manually
sql> ALTER DATABASE datafile ' C:\ORACLE\ORADATA\APP_DATA.DBF ' resize 200m;
10.Moving Data Files:alter tablespace
sql> alter tablespace app_data rename datafile ' c:\oracle\oradata\app_data.dbf '
sql> to ' c:\oracle\app_data.dbf ';
11.moving Data Files:alter Database
sql> ALTER DATABASE rename file ' c:\oracle\oradata\app_data.dbf '
sql> to ' c:\oracle\app_data.dbf ';
7.move tablespace
Sql> ALTER TABLE employee move tablespace users;
8.deallocate of unused space
Sql> ALTER TABLE table_name deallocate unused [keep integer]
9.truncate a table
Sql> TRUNCATE TABLE table_name;
10.drop a table
sql> DROP TABLE table_name [cascade constraints];
11.drop a column
Sql> ALTER TABLE table_name DROP COLUMN comments cascade constraints checkpoint 1000;
ALTER TABLE table_name DROP columns continue;
12.mark a column as unused
Sql> ALTER TABLE TABLE_NAME SET UNUSED column comments cascade constraints;
ALTER TABLE table_name drop unused columns checkpoint 1000;
ALTER TABLE orders drop columns continue checkpoint 1000
Data_dictionary:dba_unused_col_tabs
Fourth Chapter: Index
1.creating function-based Indexes
Sql> CREATE index summit.item_quantity on Summit.item (quantity-quantity_shipped);
2.create a B-tree index
Sql> create [unique] index index_name on table_name (column,.. Asc/desc) tablespace
sql> tablespace_name [Pctfree integer] [initrans integer] [maxtrans integer]
sql> [Logging | nologging] [NOSORT] Storage (initial 200k next 200k Pctincrease 0
Sql> maxextents 50);
3.pctfree (Index) = (maximum number of rows-initial number of rows) *100/maximum number of rows
4.creating Reverse Key indexes
Sql> Create unique index xay_id on Xay (a) reverse Pctfree storage (initial 200k
Sql> next 200k pctincrease 0 maxextents tablespace indx;
5.create Bitmap Index
Sql> Create bitmap index xay_id on Xay (a) pctfree storage (initial 200k next 200k
sql> pctincrease 0 maxextents) tablespace indx;
6.change Storage parameter of index
sql> ALTER INDEX XAY_ID storage (next 400k maxextents 100);
7.allocating Index Space
Sql> ALTER INDEX XAY_ID allocate extent (size 200k datafile ' c:/oracle/index.dbf ');
8.alter index xay_id deallocate unused;
Fifth chapter: Restraint
1.define constraints as immediate or deferred
Sql> alter session set CONSTRAINT[S] = Immediate/deferred/default;
Set Constraint[s] Constraint_name/all immediate/deferred;
2. sql> DROP TABLE table_name CASCADE constraints
Sql> drop tablespace tablespace_name including contents cascade constraints
3. Define constraints while create a table
Sql> CREATE TABLE Xay (ID number (7) Constraint xay_id primary key deferrable
Sql> using index Storage (initial 100k next 100k) tablespace indx);
Primary key/unique/references table (column)/check
4.enable constraints
Sql> ALTER TABLE Xay enable Novalidate constraint xay_id;
5.enable constraints
Sql> ALTER TABLE Xay enable validate constraint xay_id;
Sixth chapter: Load data
1.loading Data using Direct_load Insert
sql> Insert/*+append */into EMP nologging
Sql> select * from Emp_old;
2.parallel direct-load Insert
Sql> alter session enable parallel DML;
sql> Insert/*+parallel (emp,2)/into EMP nologging
Sql> select * from Emp_old;
4.checking Transport Set
Sql> Dbms_tts.transport_set_check (ts_list => ' sales_ts ' ..., incl_constraints=>true);
View in Table Transport_set_violations
Sql> dbms_tts.isselfcontained is true to represent the self contained
Eighth chapter: Managing Password Security and resources
1.controlling account Lock and password
sql> alter user Juncky identified by Oracle account unlock;
2.user_provided Password function
sql> function_name (userid in Varchar2 (a), password in VARCHAR2 (30),
Old_password in VARCHAR2 (m) Return Boolean
2.grant system Privilege
Sql> Grant create session,create table to managers;
Sql> Grant create session to Scott with admin option;
With admin option can grant or revoke privilege the from any user or role;
3.SYSDBA and Sysoper privileges:
Sysoper:startup,shutdown,alter database Open|mount,alter database backup Controlfile,
Alter tablespace begin/end Backup,recover database
ALTER DATABASE archivelog,restricted session
Sysdba:sysoper privileges with admin option,create database,recover database until
4.password file members:view:=> v$pwfile_users
5.o7_dictionary_accessibility =true restriction access to view or tables in the other schema
6.revoke system Privilege
Sql> revoke CREATE table from Karen;
Sql> revoke create session from Scott;
7.grant Object Privilege
Sql> Grant execute on dbms_pipe to public;
Sql> Grant Update (first_name,salary) on "employee to" Karen with GRANT option;
1.create roles
sql> Create role Sales_clerk;
Sql> Create role Hr_clerk identified by bonus;
Sql> Create role Hr_manager identified externally;
2.modify role
sql> alter role Sales_clerk identified by commission;
sql> alter role Hr_clerk identified externally;
sql> alter role Hr_manager not identified;
3.assigning roles
Sql> Grant Sales_clerk to Scott;
Sql> Grant Hr_clerk to Hr_manager;
Sql> Grant Hr_manager to Scott with admin option;
4.establish Default Role
sql> ALTER user Scott default role Hr_clerk,sales_clerk;
sql> ALTER user Scott default role all;
sql> ALTER user Scott default role all except Hr_clerk;
sql> ALTER user Scott default role none;
5.enable and disable roles
sql> set role Hr_clerk;
Sql> set role Sales_clerk identified by commission;
Sql> set role all except Sales_clerk;
Sql> set role none;
6.remove role from user
Sql> revoke Sales_clerk from Scott;
Sql> revoke hr_manager from public;
7.remove role
sql> drop role Hr_manager;
8.display Role Information
View: =>dba_roles,dba_role_privs,role_role_privs,dba_sys_privs,role_sys_privs,role_tab_privs,session_roles
5.restore to a different location
> Connect System/manager as Sysdba
> Startup mount
> ALTER DATABASE Rename file '/disk1/. /user.dbf ' to '/disk2/. /USER.DBF ';
> ALTER DATABASE open;
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.