Drop tables from USERS tablesapce
Hello,
I am newbie to Oracle
1) I want to DROP all tables we created except from those that begins with QNT letters. I tried
BEGIN
FOR T IN (SELECT TABLE_NAME FROM USER_TABLES)
LOOP
EXECUTE IMMEDIATE ('DROP TABLE MyUserName.' || T.TABLE_NAME);
END LOOP;
END;
but I get error
ORA-00933: SQL command not properly ended
or when changing line 4
EXECUTE IMMEDIATE ('DROP TABLE ' || T.TABLE_NAME);
I get
ORA-00903: Invalid table name
What's the problem? How Can I ignore QNTxxxx tables?
2) In addition, I get error when log in to Oracle Schema Manager (though, I log in successfully to SQL WorkSheet)
MGR-02150: an unrecognized database version was encountered.
why?
The server app is 10g, and my computer client app is 8.0.5
Your help will be appreciated,
Ori
note: I made little change: 'Q' instead of 'QNT'
On sql plus i got error
ERROR at line 1:
ORA-06550: line 2, column 0:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
:= . ( @ % ;
And on sql worksheet the result is:
SQLWKS> DECLARE v_sql VARCHAR2(50);
2> BEGIN FOR t IN ( SELECT table_name FROM user_tables WHERE SUBSTR(table_name,1,1) <> 'Q' ) LOOP v_sql := 'drop table ' || t.table_name;
3> EXECUTE IMMEDIATE v_sql;
4> END LOOP;
5> EXCEPTION WHEN OTHERS THEN RAISE_APPLICATION_ERROR ( -20000 , 'Error executing command:' || CHR(10) || v_sql , TRUE );
6> END;
7>
ORA-20000: Error executing command:
drop table Table1
ORA-06512: at line 5
ORA-00942: table or view does not exist
Similar Messages
-
Need to create a procedure whic h search and drop tables from the db.
Dear Gurus,
I need to create a procedure, which first checks the tables and then drop those tables if find in the database. For example, I have 5 tables, then my procedure should first checks the existence , then drop all those 5 tables from the database. Actually, I have to attach this procedure to report buildeer, so please keep in mind the above mentioned scenario. Your input will be highly appriciated.
hare krishna
AlokDropping 5 tables each time user hits the report!!! (According to my understanding)
I would like to share my experience. My group developed many complex reports, we used oracle jobs to run the complex queries time to time, according to our business requirements and stored the result in a final table. Just for viewing at front end level, we used a simple select statement.
-aijaz -
What is the version of grant alter table, drop table to user in Oracle 10g?
Hi,
Oracle support "grant alter table and drop table" before, but I get the "invalid privilege" error in Oracle 10g. Oracle 10g have the "DROP ANY TABLE" and "Alter any table". Is these two means can drop and alter tables belonging to other users? How do I grant the total control (CRUD) of tables in the owner's schema to the owner in Oracle10g?
Thanks,
JiangCREATE TABLE privilege grants complete control on owner's tables :
SYS@db102 SQL> create user test01 identified by test01;
User created.
SYS@db102 SQL> grant create session, create table to test01;
Grant succeeded.
SYS@db102 SQL> alter user test01 quota unlimited on users;
User altered.
SYS@db102 SQL> conn test01/test01
Connected.
TEST01@db102 SQL> create table test(a number);
Table created.
TEST01@db102 SQL> alter table test add(b varchar2(100));
Table altered.
TEST01@db102 SQL> drop table test purge;
Table dropped.
TEST01@db102 SQL> -
Hi all,
How can delete 100 tables and clean all catalog?
with select * from cat I found 100 tables and i need drop
one by one drop table1, drop table 2...drop table100 using SQL command line.
Is any complete delete (drop) all options in apex 3.1?
Thanks all,I was typing this :
declare
begin
select table_name bulk collect into tab_table_name from cat where table_name like 'B%';
for i in 1..tab_table_name.count
loop
begin
execute immediate 'drop table '||tab_table_name(i);
exception
when others then
dbms_output.put_line('Error while dropping table '||tab_table_name(i)||' due to '||sqlerrm);
end;
end loop;
exception
when others then
dbms_output.put_line(sqlerrm);
end;
I have this message:
Error while dropping table BIN$Obn6Hki7qvfgQESYCLUEeQ==$0 due to ORA-00933: SQL command not properly ended
Error while dropping table BIN$Obn7FW+Jn9vgQESYCLV3xw==$0 due to ORA-00933: SQL command not properly ended
Error while dropping table BIN$ObqWpufAzn3gQESYCLVFAA==$0 due to ORA-00933: SQL command not properly ended
Error while dropping table BIN$Obs+3SfHO+TgQESYCLViSw==$0 due to ORA-00933: SQL command not properly ended
Error while dropping table BIN$Obs09yg3PA3gQESYCLVBqg==$0 due to ORA-00933: SQL command not properly ended -
This is my code that I want to excecute using ORAOLEDB driver in Excel. It executes fine from Rapid/SQL but it will not run in Excel and I am not finding any docuemntation on much of anything to do with oraOLEDB.
Declare
PROCEDURE DropTable (tbl IN VARCHAR2) AS
in_Exists int;
BEGIN
select count(*) into in_Exists from all_tables where UPPER(table_name) = upper(tbl);
IF in_exists > 0 THEN
EXECUTE IMMEDIATE ('DROP TABLE ' || upper(tbl) || ' CASCADE CONSTRAINTS PURGE');
COMMIT;
END IF;
END;
BEGIN
DropTable('tmpEMP');
DropTable('NOMSEmplExtract');
DropTable('NOMSEmplRegionDX');
DropTable('NOMSEmplRegionSubG');
DropTable('NOMSEmplState');
END;877648 wrote:
My goal for all this is.
To run a main set of quiries to get the data formated the way I want, then for serveral worksheets I will do quries off the main query to get the specific data. So using Temp tables may not always be the way I need to go.
The error when running the Main query is this (I think this may be because it does not return data, but not sure).
"The Query did not run, or the database table could not be opened.
Check the database server or contract your database administrator. Make sure the external database is available and hasn't been moved or reorganized, then try the operation again."Well, that's not much information to go on. :-/
a) Running queries off a main query is tantamount to a query loop and sounds like it'll be slow. If you really can't do it all in a single query then fair enough, but always aim to incorporate everything in a 1 hit query if you can so that all the work is done in the SQL engine, which is the best place for processing data.
b) The fact the "query did not run", I'm guessing is referring to you calling that procedure you've shown us? (If not show us what it is doing at the time). If that procedure is not running you need to determine why not, so perhaps add some debug messages (log them to a table or something with an autonomous transaction procedure) and see how far it gets. It could be something as simple as needing explicitly granted permissions on those tables rather than relying on role based grants. It could also be to do with dependencies, because dropping tables at run time can render other things "invalid", which is why Oracle provides Global Temporary Tables so you don't have to create and drop tables at run time. -
Unable to Drop table from a corrupted Data Block
while exporting tables i got message data block corrupted 7481. and while i was trying to drop the table, found SQL Recursive Error.
Pls Help me. i am on the way to recreate my database..
Thanks
RinsonIs 7481 the block number?. Block corruption can be diagnosed using the CLI (Command Line Interface) dbv (database verify). You can also diagnose it by looking for the corresponding error message in the alert.log.
Trying to recover data from a corrupt block is only possible using rman. Otherwise, the only thing you can do is to mark the block as corrupt using DBMS_REPAIR, rebuild the table and try to rescue data by recapturing it. -
How to hide a record in table from users of different sessions ?
Hi,
I am having a table say 'EMPLOYEE' with 10 records in it and users X and Y.
X fetched a row from his session, assume 5th record for perfoming update operation .
Until X commits his transaction , this 5th record should not viewable to user Y evenwith
"SELECT * FROM EMPLOYEE" statement .
How it is possible with oracle ?
Thanx in advance.
Regards,
Hariharan STLook at this example please
SQL> create user test1 identified by test1;
User created.
SQL> grant dba to test1;
Grant succeeded.
SQL> conn test1/test1
Connected.
SQL> create table test1_id (id number);
Table created.
SQL> begin
2 for i in 1..5 loop
3 insert into test1_id values(i);
4 end loop;
5 commit;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> select * from test1_id;
ID
1
2
3
4
5
SQL> disc
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.5.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> conn / as sysdba
Connected.
SQL> create user x identified by x;
User created.
SQL> grant dba to x;
Grant succeeded.
SQL> create user y identified by y;
User created.
SQL> grant dba to y;
Grant succeeded.
SQL> conn x/x
Connected.
SQL> update test1.test1_id set id=1;
5 rows updated.
SQL>
And now connected by X user, from another session I'm connecting with Y user and issue:
SQL> conn y/y
Connected.
SQL> select * from test1.test1_id;
ID
1
2
3
4
5
SQL>- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com -
Hi,
Can you help me with this?
I wrote this
{declare
cursor c1 is
select *
from
all_objects
where lower(owner) like 'scott'
and lower(object_type)='table';
i varchar2(50);
begin
for i in c1
loop
execute immediate 'create table '||i.object_name|| ' as select *
from ' ||i.object_name;
end loop;
close c1;
end;
and I have the following errors:
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at line 12
Thank youCould you please show output of your generated code using dbms_output.put_line command?
declare
cursor c1 is
select *
from
all_objects
where lower(owner) like 'scott'
and lower(object_type)='table';
i varchar2(50);
begin
for i in c1
loop
dbms_output.put_line('create table '||i.object_name|| ' as select *
from ' ||i.object_name);
end loop;
close c1;
end;
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com -
Labview database problem: Create a database table from user defined fields
I am trying to create a new table in an access database opened by an ODBC connection from information entered a table stored in the database, but every time I try to create the table, the Labview Database connectivity toolkit VI for creating a table throws a cryptic error
"Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC Microsoft Access Driver] Syntax error in field definition. in NI_Database_API.lvlib:Conn Execute.vi->NI_Database_API.lvlibB Tools Create Table.vi->DatabaseCreateHeaders.vi"
I think this is becuase I am trying to re-create the database column variable type, but I am not sure what I am doing wrong. Everything seems to be fine as the data types go, and everything works as long as I use a constant to create the database columns. I even tried putting all of the information into the format labview defined, changed that to a variant, and redefined it as the labview database column type.
I have attached a simplified VI and a picture of what I am trying to
do, but I would appreciate any help I can get. Hopefully I won't have
pulled out all of my hair by the time some one replies!
Solved!
Go to Solution.
Attachments:
DatabaseUserDefinedTable.vi 14 KB
UserDefinedColumns.JPG 48 KBHi everyone. I am new to the database tool kit using labview. I am using labview 9.0f2 on Windows Xp. I am required to create a database (task is to create a table and to insert values into the table using Microsoft access 2007). I am trying to learn using the Create Database table.vi found with the software. I understand that need to create an access file and also had a mdl file which is name after it.(I had created them). Looking at the example given, I would like to add a few more variables, to be exact 6 more variables(therefore i would have 6 colum in my access file rite?). From the "connection information" the help information shows that it contain an 1D array of DB tools colum. ctl and also a cluster of 4 elements. the link to the access file, LabVIEW.udl shows that it restrict the colum in the access file.eg it has only stringcol,intcol,doublecol. I need to add more colum but cant add just like tt.
qn1: How to i add insert more varibles into the database so that it will apprears in access.
qn2: I cant drag and insert the "connection information" just to have more input. how do i do it?
qn3: where can i edit the info so that i can add more cluster into the access? when i drag out the input turn greyish. -
Problem accessing sys table from user's schema
Hi,
I had a store procedure whose owner is say user1.Inside of that store procedure i am executing the following select query.
select * from sys.all_coloumns where owner = 'USER1';
This is resulting me "no data found".
When i am executing the same select query from SQL*plus it is giving me the proper output.
I think this is happening because of less systeme privileges/role assigned to schema USER1.
Can you please suggest which priviledges i need to grant, so that my proc. will work fine.User1 needs select rights on sys.all_columns directly.
Not via the DBA role. -
Drop table to specific account.
Hello All,
I am using 11.2.0.3.0 on linux box. I have a requirement to given drop tables privilege to specific account. for example , I need to give ability to user c to drop tables from user A and user B schema. I know, "drop any table" would do the trick. but , is there anyway around? I mean, by creating trigger or some other methods.
thanks a lot for all the help in advance.937853 wrote:
Hello All,
I am using 11.2.0.3.0 on linux box. I have a requirement to given drop tables privilege to specific account. for example , I need to give ability to user c to drop tables from user A and user B schema. I know, "drop any table" would do the trick. but , is there anyway around? I mean, by creating trigger or some other methods.
thanks a lot for all the help in advance.I am not sure that you can give users to drop tables in other schemas . Only the creator has the privilege of teh drop table and the other option is drop any table . So you may want to tell us that why you want to do this?
Aman.... -
Import a table from FULLDB dump
Oracle 8i / Windows2000 server.
When i tried to import a table from a fulldb dump in a cloned databse.
i tried to drop the same name table from user.
NO authority to drop the table error
when i tried to rename the table
NO authority to rename the table error.
How to import a table from fulldb dump in the cloned databse.?
[email protected]Hi..
Can you post the ORA error that you are getting....
Anand -
Best way to recover from "drop user; drop table space"
Hello,
I am practicing several different RMAN recovery senarios on oracle 11g windows 2003.
The senario that I am stuck on is.
drop user MYUSER cascade;
drop table space MYUSER including contents and datafiles;
Originally, I was trying to do this with RMAM. From further reading, it seems that RMAN fit for this type of recovery.
What is the best approach to recover from this?
thanks for any tips.DBPITR did not bring backup my tablespaces.
break database
drop user PWRPLANT CASCADE
drop role PWRPLANT_ROLE_USER
drop role PWRPLANT_ROLE_DEV
drop role PWRPLANT_ROLE_ADMIN
alter tablespace PWRPLANT_IDX offline
alter tablespace PWRPLANT offline
drop tablespace PWRPLANT_IDX INCLUDING CONTENTS AND DATAFILES
drop tablespace PWRPLANT INCLUDING CONTENTS AND DATAFILES
recover with BDITR
RMAN> run {set until sequence 56; restore database; recover database;}
executing command: SET until clause
using target database control file instead of recovery catalog
Starting restore at 28-APR-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=317 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to I:\ORACLE\ORADATA\PWRGAME\SYSTEM
01.DBF
channel ORA_DISK_1: restoring datafile 00002 to I:\ORACLE\ORADATA\PWRGAME\SYSAUX
01.DBF
channel ORA_DISK_1: restoring datafile 00003 to I:\ORACLE\ORADATA\PWRGAME\UNDOTB
S01.DBF
channel ORA_DISK_1: restoring datafile 00004 to I:\ORACLE\ORADATA\PWRGAME\USERS0
1.DBF
channel ORA_DISK_1: reading from backup piece I:\ORACLE\FLASH_RECOVERY_AREA\PWRG
AME\BACKUPSET\2011_04_28\O1_MF_NNNDF_DATABASE_FULL_BACKUP_6VMMSSXV_.BKP
channel ORA_DISK_1: piece handle=I:\ORACLE\FLASH_RECOVERY_AREA\PWRGAME\BACKUPSET
\2011_04_28\O1_MF_NNNDF_DATABASE_FULL_BACKUP_6VMMSSXV_.BKP tag=DATABASE_FULL_BAC
KUP
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:07:06
Finished restore at 28-APR-11
Starting recover at 28-APR-11
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 55 is already on disk as file I:\ORACLE\
PRODUCT\11.1.0\DB_1\RDBMS\ARC00055_0748950531.001
archived log file name=I:\ORACLE\PRODUCT\11.1.0\DB_1\RDBMS\ARC00055_0748950531.0
01 thread=1 sequence=55
media recovery complete, elapsed time: 00:00:02
Finished recover at 28-APR-11
Did I miss something? -
Want to drop non-system table from system tablespace
My system tablespace was having some user tables , so I moved those tables to user tablespace. Now that tables are showing in both the tablespaces ex. RET_OFF is showing in system as well as users tablespace I want to drop it from system tablespace only . Can I do it . plz help
Hi Florian , plz check the below details . I am working on Oracle 11g on Windows platform.
SQL> alter table REF_VAT_OFF move tablespace vatsoft;
Table altered.
SQL> select owner, table_name, tablespace_name
2 from dba_tables
3 where table_name='REF_VAT_OFF';
OWNER TABLE_NAME TABLESPACE_NAME
KNVATCEN REF_VAT_OFF SYSTEM
OWNER TABLE_NAME TABLESPACE_NAME
KNVAT REF_VAT_OFF VATSOFT -
TABLE, PACKAGE, USER가 DROP되지 않을 때의 조치 방법(ORA-1000)
제품 : ORACLE SERVER
작성날짜 : 2004-11-09
TABLE, PACKAGE, USER가 DROP되지 않을 때의 조치 방법(ORA-1000)
============================================================
다음 자료는 dropping an object (table, package, users) 시에
ora-1000 또는 internal error 가 발생하며 drop 되지 않을 때의 조치
방법입니다.
internal 자료로서 엔지니어가 직접 알려주는 것이 좋다고 remark 되어 있는
자료입니다.
요약>
drop package 시에 ora-1000 은 다음 자료 처럼 drop 하려는 object 와
dependency 는 남아있지만 invalid object(no interdependant objects
즉, children which are also parents) 가 존재할 때 발생합니다.
따라서, drop 하려는 object 의 dependency 를 조회하여 invalid object
와의 dependency 를 dependency$ 에서 지워줍니다.
주의!>
다음 작업을 수행 도중 dependency$ 의 row 를 삭제하기 전에는 반드시 cold
backup 을 해 주십시오.
<table, package, user 를 drop 할 때 Ora-1000(ORA-604) 이 발생하는 문제 조치
방법 >
Object 를 drop 할 때 ORA-1000 과 같은 에러가 발생하여, open_cursors
를 1000 이상으로 늘여도 계속 에러가 발생할 때는 다음과 같이 원인을
찾아 제거 합니다.
1. drop 하려는 object 의 parent dependency 를 찾는다.
svrmgr> connect internal;
select lpad(' ',2*(level-1))||p_obj#,d_obj#
from sys.dependency$
where p_obj#=(select a.obj# from sys.obj$ a, sys.user$ b
where a.owner#=b.user#
and a.name='PROCEDURE1' and b.name='SCOTT')
connect by prior d_obj#=p_obj#;
2. drop 하려는 object 의 child dependency 를 찾는다.
select lpad(' ',2*(level-1))||p_obj#,d_obj#
from dependency$
where d_obj#=(select a.obj# from obj$ a, user$ b
where a.owner#=b.user#
and a.name='PROCEDURE1' and b.name='SCOTT')
connect by prior p_obj#=d_obj#;
3. 위에서 조회된 모든 object 가 dba_objects 에 존재하지 않거나 status 가
invalid 인 것을 찾는다.
select * from dba_objects where object_id=xxx;
4. 1 의 조회 결과와 2 의 조회 결과에 의해 동시에 발견된 object id 가
있는지 확인한다.
5. 위의 3 의 조회 결과 object 가 존재하지 않거나 invalid 인 것 ,
4 의 결과 동시에 발견된 object id 가 있다면 cold backup 을 먼저 받아둔다
6. valid 한 backup 이 있다면, sys user 로 접속하여 이들 row 를 다음과 같이
delete 한다.
다음을 먼저 select 한 다음, valid 한 backup 이 있는지 확인한 다음
delete 해야 한다.
즉, 두개의 object 가 서로를 의존하고 있는 것이므로, 두개의 row 를 삭제한다.
다른 row 가 delete 되지 않도록 먼저 query 해 본다.
예) procedure (contact) -> package (dbwww) 그리고 package (dbwww) ->
procedure (contact) 인 경우
1)select * from dependency$
where d_obj#=(select object_id from dba_objects
where owner='....'
and object_type='PROCEDURE'
and object_name='CONTACT')
and p_obj#=(select object_id from dba_objects
where owner='....'
and object_type='PACKAGE;
and object_name='DBWWW')
and d_owner#=(select user_id from dba_users
where username='...');
2)select * from dependency$
where d_obj#=(select object_id from dba_objects
where owner='....'
and object_type='PACKAGE'
and object_name='DBWWW')
and p_obj#=(select object_id from dba_objects
where owner='....'
and object_type='PROCEDURE';
and object_name='CONTACT')
and d_owner#=(select user_id from dba_users
where username='...');
3) alter system flush shared_pool;
4) delete from dependency$
where 위의 1),2) 같음;
Maybe you are looking for
-
Fill a text file from java code
Hello, I've written a java code to insert some informations in a database and I also want to save the same informations in text files (.txt). Thanks you for your suggestions or your advice of a tutorial that can help me to perform successfully this t
-
Hi All, I am using Oracle 11g and I am trying to delete some records from database using some GUI. In that case I am getting following error: java.lang.Exception: org.hibernate.AssertionFailure: scrollable result sets are not enabled. When I restart
-
How do I prompt user to enter a non-printing email upon form open
I have a form that doesn't include an email field, but I need to obtain an email in order to send a PDF receipt once the user submits the form to Forms Central. Is there a script that will allow me to do this?
-
I just started using this again and getting blue screen often
Tecra M2V-S330 Running Windows XP Service Pak 2 I just started using this notebook again as my wife took my new one over. It works alright but I keep getting blue screen and it shuts down. I have to restart it all the time. I cant read the blue scr
-
Is it advisable to release PR at header level
Hi SAP Experts, Is it advisable to release PR at header level? If yes, then what can be the drawback. And can you advise me any setting with which cancellation of PR & PO can be avoidable. Thanks & Regards, Anisha Sinha