How to find a table in all schemas and truncation
HelloI am creating a procedure to perform the next task.
(1) lists all create users
(2) for each user found, look for a table called "lsw_bpd_instance_documents" on the schema of the user
(3) if the table is found, her truncate.
For this work, I have the following code, but it's not right :(
Select it to found the users work well, but I don't know if I used the right method to store the result inside the CURSOR.
I'm not sure if I use the right way to perform a "foreach" CURSOR content and on my way to build my truncated sentence... Can I just concatenate strings as I do below in the call for the IMMEDIATE DELIVERY?
DECLARE
CURSOR all_users IS select lower(username) as username from dba_users where user_id between 87 and 1000;
check_table INTEGER;
BEGIN
FOR selected_user IN all_users LOOP
select count(*) INTO check_table from dba_tables where owner = UPPER(selected_user.username) and table_name = 'LSW_BPD_INSTANCE_DOCUMENTS';
--if table exists
IF ( check_table > 0 )
THEN
EXECUTE IMMEDIATE 'truncate ' || selected_user.username || '.LSW_BPD_INSTANCE_DOCUMENTS';
END IF;
END LOOP;
END;
I appreciate all the help
Really not sure why you are too complicated. This is all that is needed:
BEGIN
FOR r in ( select owner from dba_tables
where table_name = 'LSW_BPD_INSTANCE_DOCUMENTS' )
LOOP
EXECUTE IMMEDIATE 'truncate table ' || r.owner || '.LSW_BPD_INSTANCE_DOCUMENTS';
END LOOP;
END;
/
Note that I corrected the syntax error in your dynamic SQL statement. TRUNCATE is DDL, so it requires the keyword TABLE.
Cheers, APC
Tags: Database
Similar Questions
-
How to find the table in a schema, if I only have a particular column name
Hi all
Ideal if some1 could help me, I know not a column name and I need to find the table that actually holds this column paricular name I know.
is it possible to find this particular table with SQL?
Thank you
RahulSelect the table TABLE_NAME from user_tab_columns where column_name = 'COLUMN_NAME '.
-
How to find the sizes of all schema objects
Hi guru,.
I have a 10.2.0.4 database on the Windows platform.
How can I calculate the size of a particular schema objects (i.e.table, index, Mviews etc.)?
Is any dynamic script available for the same thing?
Thanks in advance.Why do you want to include nom_segment in the State? You need size of all objects in the schema.
simply question query provided that WHEN the OWNER = "tbl";
If you need that in Excel, you can use SQL Developer or any available for Oracle GUI tools.Murali Mohan
-
How to find a table, using the name of the column in the database schema
Dear all,
Please help me on
using the name of the column, how to find a table name in the database schema.
Thanks in advanceHello
You can query the data dictionary views all_tab_columns and user_tab_columns.
For example, to find the tables in the scott schema have called deptno columns:SELECT table_name FROM all_tab_columns WHERE owner = 'SCOTT' AND column_name = 'DEPTNO';
Remember that anything inside quotes is case-sensitive.
The all_tab_columns view has one row for each column in each table (or view) that you have the privileges to use.
The user_tab_columns view is a subset of all_tab_columns, containing only your own tables (and views). -
How to find a table behind the OA framework page
Hello
can any body tell me how to find the tables behind any page of OA framework in particular for screens of ALS.
ConcerningOn the tab of the page-->, click on expand all link.
Here you can find the area of the table and the VO rasthaus to it. When you've got the name of the View object.
Then click on details of the Business component references-->
In the object section View find your viewObject and click on it. Here you can find the application attached to it.
Thank you
-Anil -
How to find the size of the scheme with or without fragmentation
Hello Sir,
How to find the size of the scheme with or without fragmentation?to find all of the bytes used by a schema, you can add the bytes for the owner of the dba_segments views.
for fragmentation, I guess you want to know about the space left between the segments.
finding depends on the design and standards of your database.
Each scheme has its own storage space? If Yes, then you can take the total space used in storage and then subtract the number of the dba_segments.
-
flow of Installer for tables with source schemas and destination is different
How to set up courses of water for tables with source schemas and destination is different? But the structure of the table is the same.
Please paste a small example too.
Thank you
BalaHello
I have a concrete example of this issue, I tested in my environment. Please follow the steps below to install this on your databases.
My global_name to database source is: REP102A. WORLD
My global_name to database target is: REP102B. WORLDSource table: ORDERS. ORDER_ENTRY
Target Table: MERCHANT NAVY. ORDER_ENTRYReplication will happen as follows:
ORDERS. ORDER_ENTRY (REP102A)-> SHIPPING. ORDER_ENTRY (REP102B)Needs to follow the steps below as the one proposed at each site. You may need to make the changes required for your environment.
SCRIPT:
=======* 1. Remove the configuration of the flow of SOURCE and TARGET sites: *.
CONNECT / as SYSDBA
RUN DBMS_STREAMS_ADM. REMOVE_STREAMS_CONFIGURATION;
DROP USER CASCADE STRMADMIN;* 2. Installation STRMADMIN user and streams queued on the Source database: *.
CONNECT / as sysdba
Strmadmin CREATE USER IDENTIFIED BY strmadmin;
GRANT dba, connect, resource, aq_administrator_role to strmadmin;
ALTER SYSTEM SET aq_tm_processes = 1;
BEGIN
DBMS_STREAMS_AUTH. () GRANT_ADMIN_PRIVILEGE
dealer-online "strmadmin."
grant_privileges => TRUE);
END;
/CONNECT strmadmin/strmadmin
BEGIN
DBMS_STREAMS_ADM. () SET_UP_QUEUE
queue_table-online "streams_queue_table."
queue_name-online "streams_capture_queue."
queue_user-online "strmadmin");
END;
/* 3. Installation STRMADMIN user and streams queued to the database target: *.
CONNECT / as sysdba
Strmadmin CREATE USER IDENTIFIED BY strmadmin;
GRANT dba, connect, resource, aq_administrator_role to strmadmin;
ALTER SYSTEM SET aq_tm_processes = 1;
BEGIN
DBMS_STREAMS_AUTH. () GRANT_ADMIN_PRIVILEGE
dealer-online "strmadmin."
grant_privileges => TRUE);
END;
/CONNECT strmadmin/strmadmin
BEGIN
DBMS_STREAMS_ADM. () SET_UP_QUEUE
queue_table-online "streams_queue_table."
queue_name-online "streams_apply_queue."
queue_user-online "strmadmin");
END;
/* 4. Create ORDERS. ORDER_ENTRY Table on the Source database: *.
CREATE USER controls IDENTIFIED BY;
GRANT connect, resource TO arrested;
CONNECT orders/ordersCREATE THE ORDERS TABLE. ORDER_ENTRY
(
order_id number (8) primary key,.
ORDER_ITEM varchar2 (30),
ship_no number (8)
);* 5. Create shipping. Target ORDER_ENTRY Table on the database: *.
CREATE USER IDENTIFIED BY expedition expedition;
GRANT connect, navigation resources;
CONNECT shipping/deliveryCREATE TABLE EXPEDITION TO FRANCE. ORDER_ENTRY
(
order_id number (8) primary key,.
ORDER_ITEM varchar2 (30),
ship_no number (8)
);* 6. On the target, add the rules to apply and create a dblink from destination to source: *.
CONNECT strmadmin/strmadmin
SET SERVEROUTPUT ON
DECLARE
v_dml_rule VARCHAR2 (80);
v_ddl_rule VARCHAR2 (80);
BEGIN
DBMS_STREAMS_ADM. () ADD_TABLE_RULES
table-name => ' EXPEDITION. ORDER_ENTRY',.
streams_type-online "apply."
streams_name-online "streams_apply."
queue_name-online "strmadmin.streams_apply_queue."
include_dml to-online true.
include_ddl-online fake,
include_tagged_lcr-online fake,
source_database => ' REP102A. WORLD ',.
dml_rule_name-online v_dml_rule,
ddl_rule_name-online v_ddl_rule,
inclusion_rule-online true);
DBMS_OUTPUT. Put_line (' apply rule DML for SHIPPING.) ORDER_ENTRY => ' | v_dml_rule);
END;
/CREATE DATABASE LINK rep102a.world CONNECT TO strmadmin IDENTIFIED BY strmadmin USING 'rep102a ';
-check the link works with:
SELECT * from [email protected];BEGIN
DBMS_APPLY_ADM. () ALTER_APPLY
apply_name-online "streams_apply."
apply_user-online "strmadmin");
END;
/* 7. The source adds the rules of capture, transformation, create a database link for target, add spread rules, then prepare the tables for instantiation: *.
CONNECT strmadmin/strmadmin
SET SERVEROUTPUT ON
DECLARE
v_dml_rule VARCHAR2 (80);
v_ddl_rule VARCHAR2 (80);
BEGIN
DBMS_STREAMS_ADM. () ADD_TABLE_RULES
table-name => ' ORDERS. ORDER_ENTRY',.
streams_type-online "capture."
streams_name-online "streams_capture."
queue_name-online "strmadmin.streams_capture_queue."
include_dml to-online true.
include_ddl-online fake,
include_tagged_lcr-online fake,
source_database => ' REP102A. WORLD ',.
dml_rule_name-online v_dml_rule,
ddl_rule_name-online v_ddl_rule,
inclusion_rule-online true);
DBMS_OUTPUT. Put_line ('Capture DML rule for ORDERS.) ORDER_ENTRY => ' | v_dml_rule);
-Add the schema to rename it to change ORDERS to NAVIGATION for this rule
DBMS_STREAMS_ADM. () RENAME_SCHEMA
nom_regle-online v_dml_rule,
from_schema_name-online "ORDERS."
to_schema_name-online 'EXPEDITION. "
operation => "ADD");
END;
/CREATE DATABASE LINK rep102b.world CONNECT TO strmadmin IDENTIFIED BY strmadmin USING 'rep102b ';
-check the link works with:
SELECT * from [email protected];-post-harvest enqueues the LCR will have schema as EXPEDITION via renamed of schema processing
-then add the rule of propagation for SHIPPING. ORDER_ENTRYSET SERVEROUTPUT ON
DECLARE
v_dml_rule VARCHAR2 (80);
v_ddl_rule VARCHAR2 (80);
BEGIN
DBMS_STREAMS_ADM. () ADD_TABLE_PROPAGATION_RULES
table-name => ' EXPEDITION. ORDER_ENTRY',.
streams_name-online "streams_prop."
source_queue_name-online "strmadmin.streams_capture_queue."
destination_queue_name-online "[email protected]."
include_dml to-online true.
include_ddl-online fake,
include_tagged_lcr-online fake,
source_database => ' REP102A. WORLD ',.
dml_rule_name-online v_dml_rule,
ddl_rule_name-online v_ddl_rule,
inclusion_rule to-online true.
queue_to_queue-online fake);
DBMS_OUTPUT. Put_line ("rule DML of Propagation for SHIPPING. ORDER_ENTRY => ' | v_dml_rule);
END;
/BEGIN
DBMS_CAPTURE_ADM. () PREPARE_TABLE_INSTANTIATION
table-name => ' ORDERS. ORDER_ENTRY',.
SUPPLEMENTAL_LOGGING-online 'key');
END;
/* 8. Set the instantiation scn for ORDERS. ORDER_ENTRY on the site target and start apply: *.
-Apply on site
CONNECT strmadmin/strmadmin
SET SERVEROUTPUT ON
DECLARE
iSCN NUMBER;
BEGIN
iSCN: = DBMS_FLASHBACK. [email protected] ();
DBMS_OUTPUT. Put_line (' instantiation SCN is: ' | iSCN);
DBMS_APPLY_ADM. () SET_TABLE_INSTANTIATION_SCN
source_object_name => ' ORDERS. ORDER_ENTRY',.
source_database_name => ' REP102A. WORLD ',.
instantiation_scn-online iSCN,
apply_database_link => NULL);
COMMIT;
END;
/BEGIN
DBMS_APPLY_ADM. START_APPLY ('streams_apply');
END;
/-Check if apply is enabled
SELECT apply_name, dba_apply State;* 9. Start capturing on source: *.
CONNECT strmadmin/strmadmin
BEGIN
DBMS_CAPTURE_ADM. START_CAPTURE ('streams_capture');
END;
/* 10. Wait capture change its status of 'CAPTURER the CHANGES' and check that the status of propagation is ENABLED: *.
CONNECT strmadmin/strmadmin
SELECT capture_name, State FROM v$ streams_capture;
SELECT propagation_name, dba_propagation State;* 11. Perform inserts in ORDERS. Table ORDER_ENTRY on the source site: *.
CONNECT orders/orders
INSERT INTO orders.order_entry VALUES (23450, 'Johnny Walker', 98456);
INSERT INTO orders.order_entry VALUES (23451, "Chivas Regal", 98457);
COMMIT;* 12. On the site apply, check the DELIVERY. ORDER_ENTRY and check if the data is replicated: *.
CONNECT shipping/delivery
SELECT * FROM shipping.order_entry;* 13. Check the application errors in the queue to apply: *.
CONNECT strmadmin/strmadmin
SELECT apply_name, local_transaction_id, error_number, error_message FROM dba_apply_error;Thank you
Florent -
How to recover the table list all empty in a schema
How we get all the empty list of table in a schema. That is, the tables were that no line is presentCheck this query
select table_name from user_tables where num_rows=0 /
-
How to find out based on all INDEXES, VIEWS,... a table?
How can I find out how much and what objects dependent (index, views...) has a certain myuser444.table123 TABLE?
Peteruser559463 wrote:
How can I find out how much and what objects dependent (index, views...) has a certain myuser444.table123 TABLE?Use the DBA_DEPENDENCIES and DBA_INDEXES. For example:
select type || ' ' || owner || '.' || name from dba_dependencies where referenced_owner = 'SCOTT' and referenced_name = 'EMP' and referenced_type = 'TABLE' union all select 'INDEX ' || owner || '.' || index_name from dba_indexes where owner = 'SCOTT' and table_name = 'EMP' / TYPE||''||OWNER||'.'||NAME ---------------------------- FUNCTION SCOTT.F1 VIEW SCOTT.EMP_VW INDEX SCOTT.PK_EMP INDEX SCOTT.EMP_IDX1 SQL>
SY.
-
How to build the table with all the combinations of a source table?
Hello
I have a 2D array that contains the list of the power user-defined settings. The number of PSs (table rows) is not fixed. For example - 3 PSs:
Stage of Min Max name
PS1 3.0 3.6 0.3
PS2 0.9 1.2 0.1
PS3 1.7 1.9 0.1
I need to build, from this list, a table of all the combinations as below:
PS1 PS2 PS3
3.0 0.9 1.7
3.0 0.9 1.8
3.0 0.9 1.9
3.0 1.0 1.7
3.0 1.0 1.8
3.0 1.0 1.9
3.0 1.1 1.7
3.0 1.1 1.8
3.0 1.1 1.9
3.0 1.2-1.7
3.0 1.2-1.8
3.0 1.2-1.9
3.3 0.9 1.7
3.3 0.9 1.8
3.3 0.9 1.9
3.3 1.0 1.7
3.3 1.0 1.8
3.3 1.0 1.9
3.3 1.1 1.7
3.3 1.1 1.8
3.3 1.1 1.9
3.3 1.2 1.7
3.3 1.2 1.8
3.3 1.2 1.9
3.6 0.9 1.7
3.6 0.9 1.8
3.6 0.9 1.9
3.6 1.0 1.7
3.6 1.0 1.8
3.6 1.0 1.9
3.6 1.1 1.7
3.6 1.8 1.1
3.6 1.1 1.9
3.6 1.2 1.7
3.6 1.2 1.8
3.6 1.2 1.9
How to build this table programmatically?
(Note also that the number of rows in the source table is not fixed).
Thanks in advance!
Hi Berezka,
using a magic of automatic indexing:
-
How to create a table in a schema in the SOA database
Hello
can you please guide me how to create a table looks under custom schema available in the SOA database
Thank you
Valsaint
Hello
1. use JDeveloper to connect to your schema custom: view > Database > Database Navigator > new connection
2. set the mpdel of your table column names, types of data, constraints (primary key, not null, foreign key, etc..)
3. use this simplified tutorial to create the table according to your model of table create statement - Oracle/PLSQL: CREATE TABLE statement
4. execute the statement in the SQL of JDeveloper journal for the custom connection (point 1 above).
Let me know if you need help!
HTH,
A.
-
Hi all, I would like to know if someone has developed a script to find all tables containing the columns (fields) specific.
I'm on a migration project where I don't have access to the source of the DB, I just ask for queries and I to reflect all the tables DB containing specific data of organization.So the first step was to understand used tables and I get them, now I understand what tables have Org_id / Organization_ID and fields of the SOURCE of the LANGUAGE/LANGUAGE (source DB has much set Org and many languages also, so I need to filter the 100total 6ORG_ID and 2 languages of 8 total installed)
Can anyone help?
Thank you
Best regards
Pietro
Hello
You can see this:
Find all tables in db with the name of the column of a particular string?
Kind regards
MihaiF
-
How to find a list with all the shortcuts in EBS R12
How everything,.
Someone knows how to find all the shortcuts for R12 as CTRL + F11, F11, F4... etc?
Thanks in advance,
Bahchevanov.Someone knows how to find all the shortcuts for R12 as CTRL + F11, F11, F4... etc?
You can search all of this (help > keyboard help).
Thank you
Hussein -
How to find the age of a child and snapshot number snapshot for a virtual machine.
Hi all
How to find the age of a snapshot for a virtual machine child count and snapshot.
This code snippet should help... Assuming that you have the following entries:
VM (VC:VirtualMachine)
snapshot (VC:VirtualMachineSnapshot)
System.log("====== Snapshot details for VM: "+snapshot.config.name+" ======"); var snapshotTrees = vm.snapshot.rootSnapshotList; System.log("Snapshot Tree Count: "+snapshotTrees.length); for each (snapshotTree in snapshotTrees){ showSnapshotInfo(snapshotTree, snapshot); } function showSnapshotInfo(snapshotTree, selectedSnapshot){ if(selectedSnapshot == snapshotTree.snapshot){ System.log("===================="); System.log("Name: "+snapshotTree.name); System.log("Id: "+snapshotTree.id); System.log("Description: "+snapshotTree.description); System.log("createTime: "+snapshotTree.createTime); System.log("quiesced: "+snapshotTree.quiesced); System.log("replaySupported: "+snapshotTree.replaySupported); System.log("backupManifest: "+snapshotTree.backupManifest); System.log("snapshot id: "+snapshotTree.snapshot.id); System.log("state: "+snapshotTree.state.value); var childSnapshotList = snapshotTree.childSnapshotList; if(childSnapshotList != null){ System.log("childSnapshotList length: "+snapshotTree.childSnapshotList.length); } System.log(""); } if(snapshotTree.childSnapshotList != null){ System.log("Children found: "+snapshotTree.childSnapshotList.length); for each (childSnapshotTree in snapshotTree.childSnapshotList){ showSnapshotInfo(childSnapshotTree, selectedSnapshot); } } }
During the passage of one of my virtual machines, here is an example of output I get:
[2014-06-12 15:19:21.493] [I] Snapshot Tree Count: 1 [2014-06-12 15:19:21.493] [I] ==================== [2014-06-12 15:19:21.494] [I] Name: before upgrade to 5.0.1 [2014-06-12 15:19:21.494] [I] Id: 31 [2014-06-12 15:19:21.494] [I] Description: [2014-06-12 15:19:21.495] [I] createTime: Mon Mar 19 2012 13:48:57 GMT-0400 (EDT) [2014-06-12 15:19:21.495] [I] quiesced: false [2014-06-12 15:19:21.495] [I] replaySupported: null [2014-06-12 15:19:21.495] [I] backupManifest: null [2014-06-12 15:19:21.496] [I] snapshot id: snapshot-83 [2014-06-12 15:19:21.496] [I] state: poweredOff [2014-06-12 15:19:21.496] [I] childSnapshotList length: 1 [2014-06-12 15:19:21.496] [I] [2014-06-12 15:19:21.497] [I] ==================== [2014-06-12 15:19:21.497] [I] Name: Before 5.1 upgrade [2014-06-12 15:19:21.497] [I] Id: 36 [2014-06-12 15:19:21.497] [I] Description: [2014-06-12 15:19:21.498] [I] createTime: Fri Sep 21 2012 21:59:58 GMT-0400 (EDT) [2014-06-12 15:19:21.498] [I] quiesced: false [2014-06-12 15:19:21.498] [I] replaySupported: null [2014-06-12 15:19:21.498] [I] backupManifest: null [2014-06-12 15:19:21.499] [I] snapshot id: snapshot-84 [2014-06-12 15:19:21.499] [I] state: poweredOff [2014-06-12 15:19:21.499] [I] childSnapshotList length: 1 [2014-06-12 15:19:21.499] [I] [2014-06-12 15:19:21.500] [I] ==================== [2014-06-12 15:19:21.500] [I] Name: Before Named Instance [2014-06-12 15:19:21.500] [I] Id: 37 [2014-06-12 15:19:21.501] [I] Description: [2014-06-12 15:19:21.501] [I] createTime: Mon Nov 11 2013 13:40:46 GMT-0500 (EST) [2014-06-12 15:19:21.501] [I] quiesced: false [2014-06-12 15:19:21.501] [I] replaySupported: null [2014-06-12 15:19:21.502] [I] backupManifest: null [2014-06-12 15:19:21.502] [I] snapshot id: snapshot-236 [2014-06-12 15:19:21.502] [I] state: poweredOff [2014-06-12 15:19:21.502] [I]
-
POC: How to clean the tables dbo. ActivityInstance and dbo. ActivityInstance
Hello
I am looking for a procedure to clean the tables dbo. ActivityInstance and dbo. ActivityInstance in the OrchestratorProcess of Cisco Process Orchestrator 3.0 database
Is there a parameter must be equal to the CPO database to automatically activate an own? Y at - it a parameter setting in the order?
Concerning
Hello!
I think you are looking for to empty ActivityInstance and ActivitiyInstanceArchive in the process of the CPO DB. Have you noticed they are very rich in number of lines or?
The works of CPO way are like that...
(1) process run and store this data in the * Instance tables (ActivityInstance, ProcessInstance, etc.)
(2) once they reach a terminal State (successful, failed, etc.), they are migrated on to the * InstanceArchive tables (ActivitiyInstanceArchive, ProcessInstanceArchive, etc.)
(3) the GROOMS server process DB every night (by default at 23:00 server time) and deletes the old processes off based on your settings
So a few things here to watch...
(1) what are your settings of cleaning? You can check under Administration-> database settings. Right-click on the DB process-> properties. Click on Configuration. You want to watch the 'grooming of process Instances. By default, it's 15 days worth of data, but they may not be aggressive enough for you... so you can change out there. You can also click on the button 'Groom Now' and force a groom to arrive just here and or wait for the server is doing during the night. This will remove things from the * archive tables * ONLY * however.
(2) make sure that you check not a ton of custom process. You should always consider what you and aren't archiving in your system. If you need help determining / looking at this TAC case would be a good start and they can help or contact me and I can watch as well.
There might be a chance of grooming fails for some reason any, however, if this would be the case (and you could see to the title of operations-> audit, then you will need to open a TAC case and submit journals so support can view them and see what happens.
Finally, if you are just looking to delete all lines through SQL in these tables and understand the possible problems that come with, (again), you open a TAC case and they could provide you with queries SQL to do such. The preference would be to not to post such things here, as it's supposed to be a Cisco support activity and not something we want to people all the time. It's really something of type resort last and normally means that you have a larger ongoing problem to take a look at TAC.
-Shaun Roberts
Technical leader, Services
Maybe you are looking for
-
Saving settings Tecra M11 - fan almost always on
Hello I have a Tecra M11 (Windows7 64-bit). Toshiba Power Saver Settings V8.9.3.64 are installed. My problem is: fan is almost always turned on with maximum speed, in which case there is no load on the CPU (only 1 to 5%). It's really loud and annoyin
-
Wi - Fi calling will remain active on the iPhone 6 s
I'm having a lot of trouble getting my iPhone AT & T 6 s to work reliably with Wi - Fi calling. I have an unlimited data plan 1 original iPhone, which means that I have an old regime excluded with only 450 minutes of voice calls. Now, my dad just got
-
Upgrade to 10 from 7 and is 0xC180013 - 0 x 90002
I'm trying to upgrade to windows 10 Windows 7 and I can't. I get the 0xC180013 - 0 x 90002 error code when I try to upgrade. So I thought that I had to completely update Win7... which I couldn't for a while due to 8007370 A. Then I ran Diagnostic Win
-
How do you define an action item to appear in the menu of the action at the bottom? As the point to delete shown here: https://developer.BlackBerry.com/Cascades/documentation/Getting_started/porting/mapping.html
-
At the same time, stretching the form to fit the window would result in the form still open in full screen. That no longer works. Is there a way to make forms of full screen automatically whenever they are open? HP Pavilion e9150t Vista 64-bit