Oracle scope of spfile, memory, both the difference

Oracle inside a man named spfile do something, that is, the dynamic parameter files, which set up Oracle's various parameters.

The so-called dynamic, that you can without shutting down the database, change the database parameters, recorded in the spfile inside.

Change the parameters of time, there are four kinds of scope options, scope is the scope

1, scope = spfile spfile only change inside the record, does not change memory, that is, does not take effect immediately, but the next time the database starts to take effect. There are only allowed to change some of the parameters in this way

2, scope = memory only change the memory, do not change spfile. That is, the next time you start to fail

3, scope = both memory and spfile are changed

4, do not specify the scope search parameters, equivalent to the scope = both.

In ALTER SYSTEM SCOPE = SPFILE / MEMORY / BOTH distinction:

SCOPE = SPFILE

The change is applied in theserverparameter file only. The effect is as follows:

For dynamic parameters, the change is effective at the next startup and is persistent.

For static parameters, the behavior. is the same as for dynamic parameters. This is the only SCOPE specification allowed for static parameters.

(Write this change initialization parameter file, the changes will take effect next time you start dynamic and static parameters are the same parameters can be. The only way you can also use static parameters.)

SCOPE = MEMORY

The change is applied in memory only. The effect is as follows:

For dynamic parameters, the effect is immediate, but it is not persistent because the server parameter file is not updated.

For static parameters, this specification is not allowed.

(Only modified in memory, with immediate effect, but will no longer restart to take effect, because there is no written to the initialization parameter file. Applies only to dynamic parameters, static parameters is not allowed.)

SCOPE = BOTH

The change is applied in both the server parameter file and memory. The effect is as follows:

For dynamic parameters, the effect is immediate and persistent.

For static parameters, this specification is not allowed.

(Both written to the initialization parameter file, modify the memory also with immediate effect. The same also applies only to dynamic parameters, static parameters is not allowed.)

 

oracle in "cascade" usage summary

 Cascading deletes, such as when you delete a table behind the increase in the keyword, and other objects will delete the table in a relationship at the same time delete the table

1. Cascade delete the information in the table, the fields in Table B, once the information is deleted in the B field, the information of Table A Table A is also deleted automatically when the fields referenced. (When the parent table to delete information, the information is also automatically deleted child table)

Basic information, such as department and the company's employees during the following two tables are stored. We
Create Table Dept
(DEPTNO Number (10) Not null,
the deptname VARCHAR2 (30) Not null,
constraint pk_dept Primary Key (DEPTNO));
and
Create Table EMP
(EMPNO Number (10) Not null,
fname VARCHAR2 (20 is),
VARCHAR2 lname (20),
the dept Number The (10),
constraint A pk_emp Primary key (empno));

then we try to increase the foreign key on delete cascade

Table EMP ALTER
the Add constraint fk_emp_dept Foreign Key (Dept) References Dept (DEPTNO) Delete Cascade ON;
to increase foreign key. Then insert the data.
insert into dept values (1, 'sales');
INSERT INTO Dept values (2, 'Finance Department');
INSERT INTO EMP values (2, 'Mary', 'Song',. 1);
INSERT INTO EMP values (. 3 , 'Linda', 'Liu', 2);
INSERT INTO emp values (4, 'Linlin', 'Zhang', 1);
and now I want to delete the sales department, what will happen then?
delete from dept where deptno = 1;
we found that in addition to a data dept is deleted, and the two emp data has been deleted, which emp in two data reference to the sales of this data, which it is easy to understand on delete cascade up.

 

Next we look at on delete set null, the name suggests, the foreign key constraints created this way, when the referenced data is deleted, the value of the data corresponding to those of the reference data will become null value, or below us by experiments to prove that on delete set null effects:
first, that just a few data recovery, and then change the constraint:
the ALTER the Table emp
the Add Foreign Key constraint a fk_emp_dept (the dept) the References the dept (deptno) on delete set null;
then we delete operation :
the delete the WHERE deptno from dept = 1;
you will find that in addition to the sales dept is deleted, emp dept reference to the value of two data of this data is automatically assigned empty, this is the on delete set null a role.

Use on delete set null point to note is that, by referring to the reference table that other columns must be nulling, there can not null constraints , for the example above is the emp dept column must not have constraints not null, If you have defined not null constraints, and use the on delete set null to delete the data referenced will occur: ORA-01407: unable to update ( "DD" "EMP" " DEPT"..) the error nULL .

Overall, on the role and delete cascade on delete set null is used to deal with the problem of cascading deletes, if you want to delete the data referred to by other data, then you should decide in the end hope oracle how to deal with those referring to those about to data deletion of data, you can have three ways:
prohibition deletion, which is the default oracle
will be assigned null data corresponding column reference to those values, this requires the use of keywords on delete set null
data to a reference to those values and remove the need to use keywords on delete cascade

 

2. Oracle delete users Times "must specify CASCADE to remove the 'SE'"

This shows that you want to delete user oracle "SE" below as well as database objects such as table, view, etc., must be added when this option cascade you delete a user: drop user se cascade; SE means to delete a user, delete all users in the SE data objects. Another way is to delete all the data objects under se, so se had nothing to become a user, some empty, then drop user se;  
3.ORACLE consequences of the Drop table cascade constraints 
When you drop a table, the table if you delete the action will cause the trigger or constraint conflict, the system will warn of an error message appears and will not allow execution .. A very simple example, such as you have a basic employee data table above may have an employee number and employee name and other fields, and another table a sales staff, sales staff and employees number two fields above, staff salary scale of employees ID field is a foreign key reference to the employee base table employee number: 
the SQL> drop table T; 
the table Dropped. 
the SQL> drop table T1; 
the table Dropped. 
the SQL> Create table T (ID number, name VARCHAR2 (20 is)); 
the Table Created. 
the SQL> Create Table T1 (ID Number, SAL Number); 
 
. the Table Created 
the SQL> ALTER Table T the Add constraint t_pk Primary Key (ID); 
. the Table Altered 
the SQL> ALTER Table T1 the Add constraint t_fk Foreign Key (ID) References T (ID); 
the Table Altered. 
the SQL> INSERT INTO T values (. 1, # 39; # 39 & JACK;); 
. 1 Row Created.
The SQL> INSERT INTO T values (2, # 39; # 39 & MARY;); 
.. 1 Row Created 
the SQL> a COMMIT; 
the Commit Complete. 
The SQL> INSERT INTO T1 values (1,1000); 
.. 1 Row Created 
the SQL> INSERT INTO T1 values (2,1500); 
.. 1 Row Created 
the SQL> the commit; 
the SQL> INSERT INTO T1 values (3,200); 
INSERT INTO T1 values (3,200) 
* 
ERROR AT Line. 1: 
ORA-02291: Integrity constraint (SYS.T_FK) Violated                     
(violation of the constraint, employees basic information table no 3 this staff, how to record sales.) 
 
SQL> drop the table t; 
drop the table t 
* 
ERROR AT Line 1: 
ORA-02449: UNIQUE / Primary Keys in the table referenced by foreign keys 
(a violation of constraint, sales staff table t1 has reference to table t, the reference relation does not allow you t the table drop) 
SQL> drop the table t the Constraints Cascade; 
the Table dropped Total.
The SQL> SELECT * from T1; 
ID SAL 
---------- ---------- 
. 1 1000 
2 1500 
the SQL> CONSTRAINT_NAME SELECT, WHERE owner = TABLE_NAME from the DBA_CONSTRAINTS # 39; # 39 & the SYS ; and TABLE_NAME = & # 39; T1 & # 39; 
NO rows the Selected 
SQL> 
we can see can delete the associated table t the constraint to achieve the purpose of your drop table t use drop table cascade constraints, originally belonging t1 of the foreign key constraint has been followed is deleted, but stored in table t1 data can not be deleted, that is to say Drop table cascade constraints is without prejudice to the row data stored in the objec inside.


A table space has at least one data file, a database file can only belong to one table space
 
Create, modify, delete table space
create tablespace qin datafile '/u01/app/oracle/oradata/qin01.dbf' size 100M;
alter tablespace qin add datafile '/u01/app/oracle/oradata/qin02.dbf' size 100M;
alter database datafile '/u01/app/oracle/oradata/qin01.dbf' autoextend on next 10M maxsize 500M;
alter database datafile '/u01/app/oracle/oradata/qin01.dbf' resize 200M;
 
drop tablespace qin including contents;
create tablespace qin datafile '/u01/app/oracle/oradata/qin01.dbf' reuse
drop tablespace qin including contents and datafiles; - delete segment and the physical file
 
select file#,status,enabled from v$datafile;
select tablespcae_name,file#,v.status,v.enabled from dba_data_files d,v$datafile v where d.file_id=v.file#
alter tablespace users read only;
alter tablespace users read write;
alter tablespace users offline;
alter tablespace users online;
 
online system must have read write
sysaux can not be read only offline
can not read only can not undo offline
 
Table space was renamed
create tablespace t1 datafile '/u01/app/oracle/oradata/t1.dbf' size 100M 
alter tablespace t1 rename to t01;
 
The method of changing the size of the tablespace
1, automatic data file extension
2, manually modify data file size
3, table space plus data files
 
Data file renaming and relocation
Archive premise
1, if the database is currently open state, the following steps
a. The need to rename tablespace data file offline
b. Mobile operating system data files (or rename)
c. Perform the following rename command
alter tablespace qin rename datafile '/u01/app/oracle/oradata/qin01.dbf' to 
'/u01/app/oracle/oradata/qin.dbf'
d. Place tablespace ONLINE, check
 
2, if the database is not currently open state, the following steps
a. Start the database to mount state
b. Mobile operating system data files (or rename)
c. Perform the following rename command
alter tablespace qin rename datafile '/u01/app/oracle/oradata/qin01.dbf' to '/u01/app/oracle/oradata/qin.dbf'
d. Open the database
 
dba_tablespace
v$tablespace
dba_data_files
v$datafile
dba_temp_files
v$tempfile

Guess you like

Origin www.cnblogs.com/klb561/p/11294265.html