Workspace allows multiple transactions to exist within one table in a schema. This allows several departments or functional areas to work against a single schema without interfering with data from other groups. Changes to version-enabled tables are captured as new rows within the workspace. These changes are invisible to other workspaces until they are merged into a parent workspace.
The functionality (Packages, Procedures, Functions) used for the Workspace Manager are found in the wmsys schema.
In a workspace hierarchy consisting of Live->PreProduction->Development workspaces, the Development workspace can see all row changes made in the PreProduction workspace, along with all committed data from non-version-enabled tables belonging to the Live workspace. In addition it can see data from version-enabled tables in Live as they were when the PreProduction workspace was created. Once a workspace is refreshed, all changes can be cascaded down the hierarchy.
Workspace Manager makes only a copy of row it is changed ,which reduce hardware , software and time needed to manage multiple version of data in different schemas .A workspace is a virtual environment not physical storage.The default workspace is called LIVE.
Main concepts used for workspace are Instead of Triggers and Context .
For More On WorkSpace
To get Version
SELECT dbms_wm.getversion FROM dual;
To create Workspace
begin
dbms_wm.createworkspace('B_focus_1');
end;
select workspace, parent_workspace from user_workspaces;
To move to workspace
begin
dbms_wm.gotoworkspace('B_focus_1');
end;
To enable versoning for a table
begin
dbms_wm.enableversioning (table_name,hist);
end;
1)The length of a table name must not exceed 25 characters. The name is not case sensitive
2) Hist
NONE: No modifications to the table are tracked. (This is the default.)
VIEW_W_OVERWRITE: The with overwrite (W_OVERWRITE) option: A view named
VIEW_WO_OVERWRITE: The without overwrite (WO_OVERWRITE) option: A view named
If the table is version-enabled with the VIEW_WO_OVERWRITE hist option specified, this option can later be disabled and re-enabled by calling the SetWoOverwriteOFF Procedure and SetWoOverwriteON Procedure.
begin
DBMS_WM.SetWoOverwriteOFF();
end;
This procedure enables the VIEW_WO_OVERWRITE history option that had been disabled by the SetWoOverwriteOFF Procedure.
begin
DBMS_WM.SetWoOverwriteON();
end;
---------------------------------------
a)Only the owner of a table can enable versioning on the table.
b)Tables that are version-enabled and users that own version-enabled tables cannot be deleted. You must first disable versioning on the relevant table or tables.
c)Tables owned by SYS cannot be version-enabled.
d)DDL operations are not allowed on version-enabled tables.
e)Index-organized tables cannot be version-enabled.
f)Object tables cannot be version-enabled.
g)A table with one or more columns of LONG data type cannot be version-enabled.
------------------------------------------------------------
Example
begin
dbms_wm.enableversioning ('TEST');
end;
This will rename the TEST table to TEST_LT(LT stands for Long Transaction ie:Completes over days or week ) and create a view called TEST (which contains original data for more detail refer script of view) addition to this 9 other views will be created.The view uses instead-of triggers to perform all operations against the version enabled table. This hides a lot of the versioning mechanism from the users.
The TEST_LT table has the following additional columns:
VERSION NOT NULL NUMBER(38)
NEXTVER VARCHAR2(500)
DELSTATUS NUMBER(38)
LTLOCK VARCHAR2(100)
Values for following tables when table is version enabled (0,-1,10,!O!)
Test_MV (Materialized view) View it contains data ;which the field is not affected ;with two extra fields WM_MODIFIEDBY and WM_OPTYPE
Test_base view contains the field of original table in addition RID,version,nextver,delstatus,ltlock
Test_BPKC contains fields Rowids of child,parent and base ,childstate ,parentstate ,DS and VER of child,parent & base (ie : 12 fields) if we are in LIVE workspace there will not be an data in it because it is in parent state if it is in any of child workspace there will be data
Test_PKC contains all the fields of Text_BPKC excluding Firstchildver
TEST_HIST This view is created only if ; during table versioning (ie: enableversioning) if we supply hist parameter if hist parameter is NONE then this view will not be there to track history details .
IF active workspace is LIVE then TEST,TEST_BASE,TEST_MV view only have records
Test_conf (Conflict) view contains all fields in Test addition to those wm_workspace,wm_delted
To disable versoning
begin
dbms_wm.disableversioning ('TEST');
end;
To compress WorkSpace
begin
dbms_wm.compressworkspace('LIVE');
end;
To view curent workspace
SELECT DBMS_WM.getworkspace FROM DUAL;
To view versionenabled tables
select * from wmsys.wm$table_parvers_view
SELECT * FROM user_wm_versioned_tables;
select * from wmsys.
select * from wmsys.
select * from wmsys.
select * from wmsys.
You should be in a workspace other than LIVE then only we get data from this view ; because for LIVE workspace is parent of .
select * from wmsys.
select * from wmsys.
select * from wmsys.
select * from wmsys.
To get savepoint
--------------------------------------------------------
No comments:
Post a Comment