Request in steps in deleting all the tables data in an user schema.
Hi Gurus,
Could some one please provide me the steps involved in deleting all the tables data in an user(schema)
thanks in advance
write a script as below
sys@11GDEMO> select 'truncate table '||owner||'.'||table_name||';' from dba_tables where owner='SCOTT';
'TRUNCATETABLE'||OWNER||'.'||TABLE_NAME||';'
truncate table SCOTT.DEPT;
truncate table SCOTT.EMP;
truncate table SCOTT.BONUS;
truncate table SCOTT.SALGRADE;
truncate table SCOTT.EMPBACKUP;
truncate table SCOTT.T_NAME;
truncate table SCOTT.D_TEMP_STSC;
Example:
sys@11GDEMO> truncate table SCOTT.T_NAME;
Table truncated.
sys@11GDEMO>
Similar Messages
-
Is there a way to view all the table names in a certain schema?
Is there a way to view all the table names in a certain schema?
SELECT table_name FROM user_tablesThat won't do much good given this piece of information:
i am trying to finish a lab for school but i don't know what tables are in my
professor's schema. The appropriate solution is
SELECT table_name
FROM all_tables
WHERE owner = 'PROFESSOR_YAFFLE'
/This will show the names of the tables which Prof. Yaffle has granted to us.
Cheers, APC -
Script to generate all the tables and objects in a schema
how to write a script to generate all the tables and objects in a schema.
with toad the no of tables generated is not matching when i check from schema .Dear Sidhant,
Try this script:
set termout off
set feedback off
set serveroutput on size 100000
spool ddl_schema.sql
begin
dbms_output.put_line('--');
dbms_output.put_line('-- DROP TABLES --');
dbms_output.put_line('--');
for rt in (select tname from tab order by tname) loop
dbms_output.put_line('DROP TABLE '||rt.tname||' CASCADE CONSTRAINTS;');
end loop;
end;
declare
v_tname varchar2(30);
v_cname char(32);
v_type char(20);
v_null varchar2(10);
v_maxcol number;
v_virg varchar2(1);
begin
dbms_output.put_line('--');
dbms_output.put_line('-- CREATE TABLES --');
dbms_output.put_line('--');
for rt in (select table_name from user_tables order by 1) loop
v_tname:=rt.table_name;
v_virg:=',';
dbms_output.put_line('CREATE TABLE '||v_tname||' (');
for rc in (select table_name,column_name,data_type,data_length,
data_precision,data_scale,nullable,column_id
from user_tab_columns tc
where tc.table_name=rt.table_name
order by table_name,column_id) loop
v_cname:=rc.column_name;
if rc.data_type='VARCHAR2' then
v_type:='VARCHAR2('||rc.data_length||')';
elsif rc.data_type='NUMBER' and rc.data_precision is null and
rc.data_scale=0 then
v_type:='INTEGER';
elsif rc.data_type='NUMBER' and rc.data_precision is null and
rc.data_scale is null then
v_type:='NUMBER';
elsif rc.data_type='NUMBER' and rc.data_scale='0' then
v_type:='NUMBER('||rc.data_precision||')';
elsif rc.data_type='NUMBER' and rc.data_scale<>'0' then
v_type:='NUMBER('||rc.data_precision||','||rc.data_scale||')';
elsif rc.data_type='CHAR' then
v_type:='CHAR('||rc.data_length||')';
else v_type:=rc.data_type;
end if;
if rc.nullable='Y' then
v_null:='NULL';
else
v_null:='NOT NULL';
end if;
select max(column_id)
into v_maxcol
from user_tab_columns c
where c.table_name=rt.table_name;
if rc.column_id=v_maxcol then
v_virg:='';
end if;
dbms_output.put_line (v_cname||v_type||v_null||v_virg);
end loop;
dbms_output.put_line(');');
end loop;
end;
declare
v_virg varchar2(1);
v_maxcol number;
begin
dbms_output.put_line('--');
dbms_output.put_line('-- PRIMARY KEYS --');
dbms_output.put_line('--');
for rcn in (select table_name,constraint_name
from user_constraints
where constraint_type='P'
order by table_name) loop
dbms_output.put_line ('ALTER TABLE '||rcn.table_name||' ADD (');
dbms_output.put_line ('CONSTRAINT '||rcn.constraint_name);
dbms_output.put_line ('PRIMARY KEY (');
v_virg:=',';
for rcl in (select column_name,position
from user_cons_columns cl
where cl.constraint_name=rcn.constraint_name
order by position) loop
select max(position)
into v_maxcol
from user_cons_columns c
where c.constraint_name=rcn.constraint_name;
if rcl.position=v_maxcol then
v_virg:='';
end if;
dbms_output.put_line (rcl.column_name||v_virg);
end loop;
dbms_output.put_line(')');
dbms_output.put_line('USING INDEX );');
end loop;
end;
declare
v_virg varchar2(1);
v_maxcol number;
v_tname varchar2(30);
begin
dbms_output.put_line('--');
dbms_output.put_line('-- FOREIGN KEYS --');
dbms_output.put_line('--');
for rcn in (select table_name,constraint_name,r_constraint_name
from user_constraints
where constraint_type='R'
order by table_name) loop
dbms_output.put_line ('ALTER TABLE '||rcn.table_name||' ADD (');
dbms_output.put_line ('CONSTRAINT '||rcn.constraint_name);
dbms_output.put_line ('FOREIGN KEY (');
v_virg:=',';
for rcl in (select column_name,position
from user_cons_columns cl
where cl.constraint_name=rcn.constraint_name
order by position) loop
select max(position)
into v_maxcol
from user_cons_columns c
where c.constraint_name=rcn.constraint_name;
if rcl.position=v_maxcol then
v_virg:='';
end if;
dbms_output.put_line (rcl.column_name||v_virg);
end loop;
select table_name
into v_tname
from user_constraints c
where c.constraint_name=rcn.r_constraint_name;
dbms_output.put_line(') REFERENCES '||v_tname||' (');
select max(position)
into v_maxcol
from user_cons_columns c
where c.constraint_name=rcn.r_constraint_name;
v_virg:=',';
select max(position)
into v_maxcol
from user_cons_columns c
where c.constraint_name=rcn.r_constraint_name;
for rcr in (select column_name,position
from user_cons_columns cl
where rcn.r_constraint_name=cl.constraint_name
order by position) loop
if rcr.position=v_maxcol then
v_virg:='';
end if;
dbms_output.put_line (rcr.column_name||v_virg);
end loop;
dbms_output.put_line(') );');
end loop;
end;
begin
dbms_output.put_line('--');
dbms_output.put_line('-- DROP SEQUENCES --');
dbms_output.put_line('--');
for rs in (select sequence_name
from user_sequences
where sequence_name like 'SQ%'
order by sequence_name) loop
dbms_output.put_line('DROP SEQUENCE '||rs.sequence_name||';');
end loop;
dbms_output.put_line('--');
dbms_output.put_line('-- CREATE SEQUENCES --');
dbms_output.put_line('--');
for rs in (select sequence_name
from user_sequences
where sequence_name like 'SQ%'
order by sequence_name) loop
dbms_output.put_line('CREATE SEQUENCE '||rs.sequence_name||' NOCYCLE;');
end loop;
end;
declare
v_virg varchar2(1);
v_maxcol number;
begin
dbms_output.put_line('--');
dbms_output.put_line('-- INDEXES --');
dbms_output.put_line('--');
for rid in (select index_name, table_name
from user_indexes
where index_name not in (select constraint_name from user_constraints)
and index_type<>'LOB'
order by index_name) loop
v_virg:=',';
dbms_output.put_line('CREATE INDEX '||rid.index_name||' ON '||rid.table_name||' (');
for rcl in (select column_name,column_position
from user_ind_columns cl
where cl.index_name=rid.index_name
order by column_position) loop
select max(column_position)
into v_maxcol
from user_ind_columns c
where c.index_name=rid.index_name;
if rcl.column_position=v_maxcol then
v_virg:='';
end if;
dbms_output.put_line (rcl.column_name||v_virg);
end loop;
dbms_output.put_line(');');
end loop;
end;
spool off
set feedback on
set termout on Best Regards,
Francisco Munoz Alvarez
www.oraclenz.com -
How to delete all the PSA data in one go
Hello Guys,
I want to clear all the data from all the PSA tables at one shot, how can i do this??
I have tried following things:
1) I have gone to PSA root node and right click and then clicked on delete PSA data, but its showing me all the datasources and when i am executing that, it is deleting one by one(that i means i need to select individual datasource, which i do not want).
2) Above specified step runs RSPSADEL1 in background , so i doubt whether it deletes psa data only or complete Table?
3)I got the info from other posts that there is a fm which is RSATREE_PSA_DELETE_BATCH, but i need to make myself clear whether this fm deletes only data or complete Table?
I am using sap-bw 3.5.
Regards,
DollyHi,
there is one easy way to delete data from PSA .You can create a process chain have one delete data from PSA step where you need to give PSA table name and request older than (no of days before which you want to delete data ).
Execute it and it will delete all the data before specified no of days .You can add multiple PSA tables here and can delete whole data in one go .
Regards,
Jaya -
How do i find out the tables (data)effected in a schema after a particular time stamp
how do i find out the tables (data not structure)effected in a schema after a particular time stamp?
pls email in [email protected]You can't do that. That would be a real security risc.
/KAj -
How to bind table data to datatable component and show all the table data??
I bind table to datatable component !
The datatable has four rows,
but the datatable alway show the first row data in its four rows,why??do you mean at design time or at runtime?
at design time, the datatable uses generic fields to
show if data type is numeric, text, date, etc...
If this is at runtime,
- what driver are you using?
- how did you bind the data to the table?
- what is the resulting code in the Java backing file?
hth,
-Alexis -
Cmd for exp and importing all the table data's in a specified schema
i need to export table data without exporting the defenition how can i do this
Why do you have such a requirement?
Are you worried about import failures if the object already exists on the database? -
Delete all the database table content
Hello Friends,
I have a z table with 5 fields (all the key fields) and I want to delete all the table content and load fresh content from internal table.
I tried using syntax 'delete ztable' but sy-subrc value is coming as 4, means no table content is getting deleted.
Please suggest me any alternative way to delete all the database table content.
Thanks in advance,
ShreekantHi,
try using
delete from ztable.
This will delete all records from your ztable. After this command u can fill your ztable from itab by the following command
select *
from std table
into corresponding fields of itab.
insert ztable from table itab.
Hopefully this will solve your problem.
Regards,
Ibrar -
To drop all the tables in a database
hi,
I have 25000 tables in a database.I want ot delete all the tables and then i have to import the dump.For deleting all the tables what query has to be given.
Thanks in advance,
R.RatheeshThe code would be
BEGIN
FOR c IN (SELECT owner,
table_name
FROM all_tables
WHERE owner IN ('YOUR_OWNER1', 'YOUR_OWNER2_ETC'))
LOOP
EXECUTE IMMEDIATE 'drop table '
|| c.owner
|| '.'
|| c.table_name
|| ' cascade constraints';
END LOOP;
END;
the user ,tablespaces ,datafiles has to be recreatedbut still dropping the user would be the simplest option
you don't have to recreate tablespaces and datafiles for that. -
Script for dropping all the tables
Hello:
Can somebody share with me a script that will delete all the tables in a schema?
Thanks.I think what Justin was getting at is this: we cannot drop tables that are referenced by foreign keys. So before we can drop all tables weed to drop all referencing constraints. Which makes this script even more dangerous - you may wish to abort if other schemas reference the "droppee".
Let's be careful out there!
Cheers, APC
declare
cursor fks is
select owner,table_name, constraint_name
from all_constraints
where r_owner='&&schema_to_delete'
and constraint_type = 'R';
cursor tables is
select owner,table_name
from all_tables
where owner='&&schema_to_delete';
begin
for b in fks
loop
dbms_output.put_line( 'drop fk constraint '||b.owner||'.'||b.table_name||'.'||b.constraint_name);
execute immediate 'alter table '||b.owner||'.'||b.table_name||' drop constraint '||b.constraint_name;
end loop;
for c in tables
loop
dbms_output.put_line( 'drop table '||c.owner||'.'||c.table_name);
execute immediate 'drop table '||c.owner||'.'||c.table_name;
end loop;
end;
/ -
Is there a way to delete all the messages for a user in CUC 8.6 ?
With Unity it was possible as an administrator, to delete all the messages in a user's mailbox, directly from the server (Windows). Now, with Unity Connection (8.6.1) is there a way to do the same ? When I'm logged as an administrator, I can see, for every user, the number of messages and the size (Mailbox menu) that they have in their mailbox, but what I want to do is to be able to delete all the messages for a specific user... Is it possible with CUC 8.6.1 ?
Hi there,
The best way with Unity Connection is with the use of this excellent tool from
the great suite of Unity Tools (** "reset" feature);
Unity Connection Bulk User Delete
For resetting users you have the option of emptying the mailbox, resetting greetings, deleting voice names, resetting passwords, removing private lists and a number of other options you may choose. For installations where the user base “changes over” frequently such as schools this may be a nicer option. This option is also allowed for CoRes installations since it does not involve the removal of user objects from the Connection database.
http://www.ciscounitytools.com/Applications/CxN/BulkUserDelete/BulkUserDelete.html
Cheers!
Rob -
so i sighned into someone elses device with the current icloud account and i sighned out. Some of the icloud data from the other device is now on mine. All i want to know is how to delete all the icloud data in my current icloud account from the other icloud account
Hello ,
I had the same problem and i have done everything manually.
It's a shame that Apple doesn't put a "Reset to factory Settings" button or simply "Delete all data from iCloud.com". That way, it would be much simpler for everyone including myself.
Winston Churchill is right unfortunately . Happy deleting !
Kind Regards,
Moonburn -
Hi All
I have nearly 70 procedures in my database.
I want to get all the distinct table names used in the 70 procedures.
Is it possible?
Note:
All the table names are prefixed by schema name like DEVSRC.table_name.
Please advice
Thanks
JoJohney wrote:
Hi VT
One doubt.
This query will give the table names of only select stmt used in the procedure
or
List of table names that are with in any DML operations inside the procedure?
Thanks
JoIt will give all the table either used in select or in any DML..
You can also check by creating a temp proc
SQL> drop procedure proc_test;
Procedure dropped.
SQL> select name, referenced_name, dependency_type from user_dependencies
2 where type = 'PROCEDURE' and referenced_type = 'TABLE' and name='PROC_TEST';
no rows selected
SQL> create or replace
2 PROCEDURE proc_test
3 IS
4 v_ID number;
5 v_PRID number;
6 v_PRLID number;
7 v_DATERECEIVED date;
8 Cursor C1 is
9 select * from table_c;
10 BEGIN
11 open c1;
12 LOOP
13 FETCH c1 INTO v_ID,v_PRID,v_PRLID,v_DATERECEIVED;
14 EXIT WHEN c1%NOTFOUND;
15 insert into table_b values(v_ID,v_PRID,v_PRLID,v_DATERECEIVED);
16 Commit;
17 END LOOP;
18 CLOSE C1;
19 END;
20 /
Procedure created.
SQL> select name, referenced_name, dependency_type from user_dependencies
2 where type = 'PROCEDURE' and referenced_type = 'TABLE' and name='PROC_TEST';
NAME
REFERENCED_NAME DEPE
PROC_TEST
TABLE_B HARD
PROC_TEST
TABLE_C HARD
SQL> Regards
Umesh -
Hello,
just to explain quikly how my situation is I bought an IPhone and connected it to my regular computer, a few weeks after that i bought an macbook because my old computer was having problems with all kinds of things. recently my old computer "died" and now i cant add any music to my IPhone unless i connect it to my macbook but it's saying it will delete everything on the IPhone and use this library but does it also delete all the application data? for a quik example. Angry birds do you lose your progress on it?
thank you for helping, BlackhounterIf you are saying that you didn't back up your old computer ever, especially when you knew it was failing, then you are out of luck; you cannot restore a backup that doesn't exist. However, you can probably save some of your content from the iPhone as follows:
Connect your iPhone to your new computer, but do not sync
Authorize iTunes on the new computer to your iTunes account
Go to the iTunes File menu and choose "Transfer purchases"
Click on the phone's name in iTunes and then click on the Info tab on the right
Set up apps on your computer to sync contact, notes and calendar to
Make sure there is at least one of each in the apps you have selected
Sync
You will still lose any non-iTunes music and videos, and any photos in the photo album (but you will not lose the camera roll). -
How to clear the table data at the time of leaving fromt the page
Hi all,
I have requirement to clear all the table data on the page. For that i have written code like
public void clearRunCalcPage(){
System.out.println("Inside clearRunCalcPage");
this.getCmProcessView().executeEmptyRowSet();
this.getCmProcessFiveRecordsView().executeEmptyRowSet();
But for clearing i don't have any button and i don't have next button also, based on menu navigation i will move from 1 page to another. Here my problem is where can i put this login, i tried with the constructor of the page but that time i am getting errors when i came to the page.
Can any one suggest me.Call a backing bean method on click of the next page and place the below code in the backing bean
ViewCriteria vc = myView.getViewCriteria("criteriaName");
vc.setProperty(ViewCriteriaHints.CRITERIA_AUTO_EXECUTE, false);Morgan.
Maybe you are looking for
-
When i try to send email from my ipad i get the message The recipient "£)()&&£)" was rejected by the server. This has only just started to happen and I don't know why. Please can someone help. I have tried lots of things now and cannot solve it.
-
~9 year old HP Officejet Pro 8500a, will it work on Windows 8?
Fantastic printer, and still very much working, unfortunately the computer it was attached to not so much. Can find converters for the 25pin printer port socket to USB, but need to know if it will function on Windows 8 (or even 7) if the correct driv
-
How do you open a pdf file and go to a specific page? I want to use a pdf file as a help system. In my application I want to open the direction manual which is pdf and go to a specific page. How do I do this? Tim
-
Mission Control new spaces wallpapers
I set up the iPhoto gallery for wallpaper. It changes every half an hour. What I really like is the new feature - every newly created space in Mission Control comes out with different wallpaper. Useful and great. And have a tiny bug: in Mission Contr
-
Edit tag in "Contact" results in crash
System: iOS 8.1.3 Device: iPhone 5S Description: I tried to edit the tag of phone number of contacts. In the contact, I edited someone then stroked a tag of phone number, here came the list of tags, including the default tags and my customized tags.