473,386 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to remove everything related to a user(schema)

is there a way to write a script (not stored procedure) that looks
for all the
objects (triggers, events, materialized views, indexes, stats, tables)
created
by one user and remove them all?

thanks a lot

Mar 28 '07 #1
3 13069
Hi,

you didn't mention your DB2 version.

for V8.2.2 (FP9) see:
http://www-128.ibm.com/developerwork...dm-0602rielau/

for V9 see:
http://publib.boulder.ibm.com/infoce...c/r0022036.htm
Regards
Michael
Mar 28 '07 #2
Ian
%NAME% wrote:
is there a way to write a script (not stored procedure) that looks
for all the
objects (triggers, events, materialized views, indexes, stats, tables)
created
by one user and remove them all?
Of course. Serge Rielau wrote a nice set of stored procedures to
do all of this.

http://www-128.ibm.com/developerwork...lau/index.html

If you really don't want a stored proc, you could take the logic out
of the 'dropschema' procedure. You'd want to do something along the
lines of:

-- Drop Views, MQTs, Tables (in that order)
-- Generates 'drop table' statements
select
'drop table ' || rtrim(tabschema) || '.' || tabname
from
syscat.tables
where
tabschema = 'XXX"
order by
type desc;

You'd write similar statements for functions, procedures, sequences,
triggers, datatypes.
Mar 28 '07 #3
On Mar 28, 10:03 am, Ian <ianb...@mobileaudio.comwrote:
%NAME% wrote:
is there a way to write a script (not stored procedure) that looks
for all the
objects (triggers, events, materialized views, indexes, stats, tables)
created
by one user and remove them all?

Of course. Serge Rielau wrote a nice set of stored procedures to
do all of this.

http://www-128.ibm.com/developerwork...rticle/dm-0602...

If you really don't want a stored proc, you could take the logic out
of the 'dropschema' procedure. You'd want to do something along the
lines of:

-- Drop Views, MQTs, Tables (in that order)
-- Generates 'drop table' statements
select
'drop table ' || rtrim(tabschema) || '.' || tabname
from
syscat.tables
where
tabschema = 'XXX"
order by
type desc;

You'd write similar statements for functions, procedures, sequences,
triggers, datatypes.
This is what I have used in the past...(its not exactly what you want
but modifiable)...

select
'DROP '||
CASE
WHEN TYPE IN ('H','S','T','U') THEN 'TABLE '
WHEN TYPE IN ('V','W') THEN 'VIEW '
WHEN TYPE IN ('A') THEN 'ALIAS ' END
||RTRIM(TABSCHEMA) || '.' || RTRIM(tabname) ||';'
from
syscat.tables where tabschema = '$SCHEMA' and
tabname not like 'SYS%' order by tabschema, tabname
;
select
'DROP TRIGGER '||
RTRIM(TRIGSCHEMA) || '.' || RTRIM(trigname)||';'
from
syscat.triggers
where tabschema = '$SCHEMA' order by tabschema, tabname
;
Mar 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jeff Lambert | last post by:
Using Oracle 8i on Win2k. Here's my problem: I can connect with SYS and can select from any table from schema JEFFX by prefixing tables with said schema name. eg: SELECT * FROM JEFFX.PROJ; ...
1
by: elziko | last post by:
Hi, I'm using the following code to create a user: Dim strNodeName As String = "test user" Dim NewUser As DirectoryEntry Dim AD As New DirectoryEntry("WinNT://MYCOMPUTER") 'delete user...
4
by: cmc | last post by:
I need some clarification to help me understand the DB2 strucure more. The questions are about "implicit schema" 1. This is a very interest concpet that DB2 let every user to create new schema...
0
by: steven | last post by:
Hi, I'm trying to extend my ADAM User class to handle integer data for 'attributeMapFailedPasswordAnswerCount'. It seems that I can add an attribute into ADAM, with no problems, and even see it...
6
by: Lee Harr | last post by:
I have a database where I remove the schema public. When I try to use the createlang script, it fails like this ... >createdb foo CREATE DATABASE >psql foo -c "select version()" version...
0
by: champlir | last post by:
All, The WSDL that my .Net Web Service is generating contains the following statement: <s:import namespace="http://www.w3.org/2001/XMLSchema"/> This import is not allowed by the WS-I basic...
0
by: Will | last post by:
TITLE: Microsoft SQL Server Management Studio The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138) I have an installer that is...
6
by: Amber | last post by:
do the following steps: 1:Use Manage Studio login the server with Integrated security. 2:Create a dabase named testdb; 3:Create a SQL Server login named amber ,and set it to be dbowner of...
0
by: MarkLafferty | last post by:
I am running MS SQL Server 2000. I need to programatically change a user to a different schema, but I only find the syntax for doins so in ORACLE which really doesn't help so much. Can anyone...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.