Doubt in Drop Table statement
Hi,
what will happen(internally), when we use DROP TABLE <table name>?
Could you please elaborate for the above?
Version : Oracle 9.2
For example:
If we use DML statements. It ll record the changes in redo log/archive log.
My doubt is...
i use DROP TABLE <table name>;
What operation takes place?
Will it record the changes in redo log/archive log file?
Thanks in advance
Hi,
You can start 10046 trace and see what all happens when you fire a drop table command.
Different Version and different functionalities would do additional task.
eg: Database with recyclebin on would perform different task when compared to the database with recyeclebin off.
They all would fire set of recursive SQL which would insert/update/delete the data dicitionary objects.
Since drop table command would internally fire these dmls, hence would get logged into the redo log too.
Regards
Anurag
Similar Messages
-
Generating the DROP TABLE statements in the correct order
DB Version:11.1.0.7.0
I have been given a list of 250 unwanted tables to be dropped. Because of the FK dependancy, the DROP TABLE statements has to be in the right order. ie Drop the child table first and then the parent.
Is there way to generate a script (from a given list of tables names) which will create the DROP TABLE statments in the right order?Have you tried CASCADE CONSTRAINTS?
Cheers
Ben -
Doubt in read table statement.
hi friends
i have a doubt in read statement
please suggest me which one i can use.
i have one master table
with fields like
contract contract line wbs
500060 10 XXX
500070 10 XXX
and the transaction table has
500060 10 01 01 01
500060 10 02 02 02
500070 10 01 01 01
500070 10 02 02 02
what i am doing is like
loop at master table into wamastertable
read table tranintertab into tranintertab1 with key contract=wamastertable-contract
contractline = wamastertable-contractline.
endloop.
As my read query satifies multiple lines of transaction internal table i am in a posistion to do this
but if i do like the above it is giving error that tranintertab1 is not the line type of tranintertab
please provide me ur valuable suggestions.>
janagar sundaramoorthy Nadar wrote:
>
contract contract line wbs
> 500060 10 XXX
> 500070 10 XXX
> and the transaction table has
> 500060 10 01 01 01
> 500060 10 02 02 02
> 500070 10 01 01 01
> 500070 10 02 02 02
>
>
loop at master table into wamastertable
> read table tranintertab into tranintertab1 with key contract=wamastertable-contract
> contractline = wamastertable-contractline.
> endloop.
>
Try it like this..........
loop at tranintertab into tranintertab1.
read table master table into wamastertable with key
contract = tranintertab1-contract
contractline = tranintertab1-contractline.
endloop.
Regards,
Suneel G -
DROP TABLE works through SSMS but not via T-SQL Query
Hello All,
I am trying to drop a number of tables (1,000+) in a particular database by scripting the actions in T-SQL. When I run the query I get error 3701 on every table which points to a permissions issue. However, I am able to delete tables one by one using
the tree-view in the SSMS Object Explorer.
1. I have tried starting query sessions with both the DBO of the database and the SA account to no avail. (Both had the sysadmin role when I tried.)
2. Both the DBO account and the SA account are able to drop tables using SSMS Object Explorer.
Do I need a specific GRANT of permissions to use T-SQL versus SSMS or am I missing something even more fundamental?
TIA, Simon
<code>
DECLARE @Company VARCHAR(max),
@ID VARCHAR(max),
@NAME VARCHAR(max),
@TABLE_CATALOG VARCHAR(max),
@NAV_DATABASE VARCHAR(max),
@TABLE_NAME VARCHAR(max),
@STATEMENT VARCHAR(max),
@OBJECT_NAME VARCHAR(max),
@OBJECT_NAME_BARE VARCHAR(max),
@OBJECT_TYPE VARCHAR(max);
SET @TABLE_CATALOG = 'NAV_PENTA_TEST_GAAP';
SET @NAV_DATABASE = @TABLE_CATALOG
IF @TABLE_CATALOG <> DB_NAME()
BEGIN
DECLARE @ERRORMSG VARCHAR(max);
SET @ERRORMSG = 'You are not in the correct database. You specified ' + @TABLE_CATALOG + ' but you are currently in a session for ' + db_name();
RAISERROR(@ERRORMSG, 18, 1);
RETURN;
END;
-- To hold the object names (tables) from Navision
CREATE TABLE #NavisionObjects
[CompanyName]
VARCHAR(max),
[ID] VARCHAR(max),
[Name]
VARCHAR(max),
[TABLE_NAME]
VARCHAR(max)
-- To hold the object names (tables) from SQL only
CREATE TABLE #NavisionSQLObjects
[TABLE_NAME]
VARCHAR(max)
-- Holds the list of dependent objects
CREATE TABLE #DependentObjects
[name] VARCHAR(max),
[type] VARCHAR(max)
WITH T AS (
SELECT [Company Name],[ID],[Name],[Company Name]+'$'+[Name] AS TABLE_NAME
FROM [Object]
WHERE [Name] like '%IT IS%' AND [Company Name]>''
UNION ALL
SELECT [Company Name],[ID],[Name],[Name] AS TABLE_NAME
FROM [Object]
WHERE [Name] like '%IT IS%' AND [Company Name] IN ('',' ')
INSERT INTO #NavisionObjects SELECT [Company Name],[ID],[Name],[TABLE_NAME] FROM T;
UPDATE #NavisionObjects SET TABLE_NAME = TABLE_NAME+ID WHERE ID LIKE '1%';
INSERT INTO #NavisionSQLObjects
SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = @TABLE_CATALOG AND TABLE_NAME LIKE '%IT IS%' AND TABLE_TYPE='BASE TABLE';
--SELECT * FROM #NavisionObjects where CompanyName like 'E15%' order by TABLE_NAME;
--SELECT * FROM #NavisionSQLObjects where TABLE_NAME like 'E15%' order by TABLE_NAME;
DECLARE cTables CURSOR FOR SELECT A.CompanyName,A.ID,A.[TABLE_NAME] FROM #NavisionObjects A
INNER JOIN #NavisionObjects B ON B.[TABLE_NAME]=A.[TABLE_NAME]
OPEN cTables;
FETCH NEXT FROM cTables INTO @Company,@ID,@TABLE_NAME;
WHILE (@@FETCH_STATUS = 0)
BEGIN
PRINT 'Storing dependencies for [' + @TABLE_NAME + ']';
BEGIN TRY
INSERT INTO #DependentObjects
EXEC sp_depends @TABLE_NAME;
END TRY
BEGIN CATCH
PRINT 'Could not get dependencies for table [' + @TABLE_NAME + ']';
END CATCH
FETCH NEXT FROM cTables INTO @Company,@ID,@TABLE_NAME;
END
CLOSE cTables;
Drop dependent objects first so that table drops are less likely to fail.
DECLARE cdo CURSOR FOR SELECT [Name],[Type] FROM #DependentObjects;
OPEN cdo;
FETCH NEXT FROM cdo INTO @OBJECT_NAME, @OBJECT_TYPE;
WHILE (@@FETCH_STATUS = 0)
BEGIN
BEGIN TRY
SET @OBJECT_NAME_BARE =
CASE
WHEN CHARINDEX('dbo',@OBJECT_NAME) = 1
THEN RIGHT(@OBJECT_NAME,LEN(@OBJECT_NAME)-4)
ELSE @OBJECT_NAME
END;
SET @STATEMENT = 'DROP ' + @OBJECT_TYPE + ' [' + @OBJECT_NAME_BARE + ']';
PRINT @STATEMENT;
EXEC sys.sp_sqlexec @STATEMENT;
END TRY
BEGIN CATCH
PRINT 'Could not DROP object [' + @OBJECT_NAME + '] of type ' + @OBJECT_TYPE + ', SQL Error ' + CAST(@@ERROR AS VARCHAR(max));
END CATCH
FETCH NEXT FROM cdo INTO @OBJECT_NAME, @OBJECT_TYPE;
END
CLOSE cdo;
DEALLOCATE cdo;
OPEN cTables;
FETCH NEXT FROM cTables INTO @Company,@ID,@TABLE_NAME;
WHILE (@@FETCH_STATUS = 0)
BEGIN
PRINT 'Removing [' + @TABLE_NAME + ']' ;
BEGIN TRY
SET @STATEMENT = 'TRUNCATE TABLE dbo.[' + @TABLE_NAME + ']';
PRINT @STATEMENT;
EXEC sys.sp_sqlexec @STATEMENT;
END TRY
BEGIN CATCH
PRINT 'Could not truncate table [' + @TABLE_NAME + ']';
END CATCH
BEGIN TRY
SET @STATEMENT = 'DROP TABLE dbo.[' + @TABLE_NAME + ']';
PRINT @STATEMENT;
EXEC sys.sp_sqlexec @STATEMENT;
BEGIN TRY
SET @STATEMENT = 'DELETE FROM [Object] WHERE [Company Name] = ' + CHAR(39) + @Company + CHAR(39) + ' AND [ID] = ' + CHAR(39) + @ID + CHAR(39) + ' AND [TABLE_NAME] = ' + CHAR(39) +
@TABLE_NAME + CHAR(39) ;
EXEC sys.sp_sqlexec @STATEMENT;
print @STATEMENT;
END TRY
BEGIN CATCH
PRINT 'Could not Delete Object [' + @TABLE_NAME + '], from Object table, SQL Error ' + CAST(@@ERROR AS VARCHAR(max));
END CATCH
END TRY
BEGIN CATCH
PRINT 'Could not DROP table [' + @TABLE_NAME + '], SQL Error ' + CAST(@@ERROR AS VARCHAR(max));
END CATCH
FETCH NEXT FROM cTables INTO @Company,@ID,@TABLE_NAME;
END
CLOSE cTables;
DEALLOCATE cTables;
DROP TABLE #DependentObjects;
DROP TABLE #NavisionObjects;
DROP Table #NavisionSQLObjects;
</code>3701 = ...does not exist or you don't have permission.
Most of the time it means the former. So there are probably some problems in your DROP TABLE statements. Since there is a whole lot about Navision in the script, I decline from trying to figure out what. But I encourage you to study the PRINT statements.
I think that it would be a good idea to include the schema name, in cases these tables are not in dbo after all.
Note: rather than writing:
SET @STATEMENT = 'DROP ' + @OBJECT_TYPE + ' [' + @OBJECT_NAME_BARE + ']';
write:
SET @STATEMENT = 'DROP ' + @OBJECT_TYPE + quotename(@OBJECT_NAME_BARE)
Somewhat briefer. And it works also when the object name includes a right bracket.
sp_sqlexec is undocumented, use sp_executesql instead.
Erland Sommarskog, SQL Server MVP, [email protected] -
ALTER TABLE vs DROP/CREATE statements
Hello Everyone,
I have created a script in order to update our database which includes adding new columns to a table. However, database changes and script generation must now be done using the Erwin data modeler and script generated using a compare option (within Erwin) which compares the model with the actual database.
I had a script of a few lines with a few ALTER TABLE ...ADD COLUMN statements to add the new columns.
Now, in Erwin, instead of generating 'ALTER TABLE...ADD COLUMN statements, Erwin has generated an ALTER TABLE...RENAME and CREATE TABLE statements which as a side effect will drop/re-create the table, all of it's indexes, constraints, foreign keys, etc.
Instead of a few simple "hand written" lines to run a fast script, the script is a few pages long with all of those DROP/CREATE statements, which makes the script way too much complicated and takes much longer to run.
And this, even though the Erwin option "USE ALTER TABLE ADD COLUMN" statement to create columns.
I was told that the DROP/CREATE is normal and that this is the way it should be done.
Am I out of it by thinking that it should use ALTER TABLE ADD COLUMN statements to add new columns to a table and not the DROP/CREATE methodology ? Am I missing something ? Do these new "data thinkers" know something that I am missing ?
Makes me think of the 80s when people were generating dBase application with the included application generator and were ending up with all kinds of useless and non efficient code.
Any though on this ? Am I out in the field ?
Thank you.Thank you both for your replies.
Neil,
I didn't think that adding new blank columns using the ALTER TABLE ADD COLUMN statement would make the table more fragmented than it already was to begin with.
I would have think that this kind of maintenance would take place on it's own, outside of a new deployment release.
I have always used the ALTER TABLE ADD COLUMN instead of the DROP/CREATE TABLE statements to add new columns to a table because of the simplicity, speed and lower risk involved compare to dropping a table and all of it's objects then re-create all of them and doing an import.
What do any of you do when you need to add new columns to a table ? Use the drop table and re-create or the ALTER TABLE ADD COLUMN ?
Any comments welcome.
Thanks again. -
Drop table if exists in sql statement
Oracle: 10G
Is there a way to check if table exist and then only drop table. Something like:
drop table (select table_name from user_tables where lower(table_name) = 'o2i_filing_dest')As already suggested, you could e.g. use an anonymous PL/SQL block as part of your SQL script, e.g. something like that:
set echo on
spool <your_log_file>
WHENEVER SQLERROR EXIT FAILURE
DECLARE
PROCEDURE EXEC_DONT_FAIL( P_CMD IN VARCHAR2 ) IS
e_table_or_view_does_not_exist exception;
pragma exception_init(e_table_or_view_does_not_exist, -942);
e_type_does_not_exist exception;
pragma exception_init(e_type_does_not_exist, -4043);
e_sequence_does_not_exist exception;
pragma exception_init(e_sequence_does_not_exist, -2289);
BEGIN
EXECUTE IMMEDIATE P_CMD;
EXCEPTION
WHEN e_table_or_view_does_not_exist OR e_type_does_not_exist OR e_sequence_does_not_exist THEN
NULL;
END;
BEGIN
EXEC_DONT_FAIL('drop type <type_name1> force');
EXEC_DONT_FAIL('drop view <view_name1>');
EXEC_DONT_FAIL('drop table <table_name1> purge');
EXEC_DONT_FAIL('drop sequence <seq_name1>');
END;
CREATE TABLE ...Note that the literals in angle brackets are just placeholders for demonstration purposes, you need to use your actual object names/file names there.
Of course you could also use a FOR ... LOOP in the PL/SQL block that queries e.g. USER_OBJECTS to find out which objects to drop.
That way it is ensured that only expected exceptions will be ignored but all others will raise and stop your script in that case.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/
Edited by: Randolf Geist on Sep 25, 2008 10:09 AM
Clarification regarding angle brackets added -
Hello,
I'm currently tring to drop a table using a process trigered by a button click
Icreated my button and also a "PL/SQL process" and I put
DROP TABLE &P0_TABLE_NAME. CASCADE CONSTRAINTS;
inside field "source" with ticking the checkbox "Do not validate PL/SQL code (parse PL/SQL code at runtime only)."
But when a click on the button I have the following error
ORA-06550: line 1, column 7: PLS-00103: Encountered the symbol "DROP" when expecting one of the following: begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe
Error Error while dropping table
OK
Do anyone have a clue about this ?
Debug trace is
A C C E P T: Request="Purge"
0.00: Metadata: Fetch application definition and shortcuts
0.00: alter session set nls_language="AMERICAN"
0.00: alter session set nls_territory="AMERICA"
0.00: ...NLS: Set Decimal separator="."
0.00: ...NLS: Set NLS Group separator=","
0.00: ...NLS: Set date format="DD-MON-RR"
0.00: ...Setting session time_zone to +02:00
0.00: NLS: wwv_flow.g_flow_language_derived_from=0: wwv_flow.g_browser_language=en-us
0.00: Fetch session state from database
0.01: ...Check session 2289784661666743 owner
0.01: ...Check for session expiration:
0.01: ...Metadata: Fetch Page, Computation, Process, and Branch
0.01: Session: Fetch session header information
0.01: ...Metadata: Fetch page attributes for application 121, page 2
0.01: ...Validate item page affinity.
0.03: ...Validate hidden_protected items.
0.03: ...Check authorization security schemes
0.03: Session State: Save form items and p_arg_values
0.03: ...Session State: Save "P0_TABLE_NAME" - saving same value: "STATPHI_595730051"
0.04: ...Session State: Save "P2_TABLE_NAME" - saving same value: "STATPHI_595730051"
0.04: ...Session State: Save "P2_TYPE" - saving same value: "2"
0.04: ...Session State: Save "P2_CALENDAR" - saving same value: "PA"
0.04: ...Session State: Save "P2_FILE_NAME" - saving same value: ""
0.04: Processing point: ON_SUBMIT_BEFORE_COMPUTATION
0.04: Branch point: BEFORE_COMPUTATION
0.04: Computation point: AFTER_SUBMIT
0.04: Tabs: Perform Branching for Tab Requests
0.04: Branch point: BEFORE_VALIDATION
0.04: Perform validations:
0.04: Branch point: BEFORE_PROCESSING
0.04: Processing point: AFTER_SUBMIT
0.04: Item button "P2_PURGE_TABLE" pressed process.
0.04: ...Process "DROP TABLE": PLSQL (AFTER_SUBMIT) DROP TABLE &P0_TABLE_NAME. CASCADE CONSTRAINTS;
0.06: Encountered unhandled exception in process type PLSQL
0.06: Show ERROR page...
0.06: Performing rollback...
----Hi user631592 ;-)
You can't used directly a DDL statment.
But you can use an EXECUTE IMMEDIATE in your process.
SO
BEGIN
EXECUTE IMMEDIATE ' DROP TABLE STATPHI_595730051';
END;
Regards -
Versions are Oracle 11.2.0.1.0 and SQL Developer 4.0.0.12 on Windows 7 Ultimate SP1.
Hi
I'm following the CBT Nuggets SQL Fundementals training (video #11) and cannot drop a table I have just created. The command executed and error are:
drop table newprods;
Error starting at line : 1 in command -
drop table newprods
Error report -
SQL Error: ORA-00604: error occurred at recursive SQL level 1
ORA-20000: Cannot drop object
ORA-06512: at line 2
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
As the HR user I created two tables and created a FK constraint between them. After truncating the table with this FK, I am unable to drop it. Even if I remove the FK, the error is the same. Issing the command in SQL*Plus gives the same error.
This is the first time I have created any tables since installing Oracle on this machine and is my first attempt at dropping a table. I have not created any sequences, triggers or views based on these newly created tables.
Does anyone have any ideas?
CheersC:\Oracle>sqlplus hr@orcl
SQL*Plus: Release 11.2.0.1.0 Production on Wed Sep 4 18:58:55 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> CREATE TABLE table1 (column1 VARCHAR2(20 BYTE));
Table created.
SQL> select * from table1;
no rows selected
SQL> drop table table1;
drop table table1
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20000: Cannot drop object
ORA-06512: at line 2
SQL>
Can I run a query to see if there are any triggeres on the table?
EDIT: Ok it looks like no triggers:
SQL> show user
USER is "SYS"
SQL> select * from DBA_TRIGGERS where table_name like '%table1%';
no rows selected
SQL> select * from USER_TRIGGERS where table_name like '%table1%';
no rows selected -
Drop table is not Working in SQL
Hi,
I am trying to drop table in below code in dynamic way, but facing error.
Looking for your support.
/**********************************RESET************************/
if @TypeOfUpdate='Reset'
Begin
Drop table [' + @DestinationTable + ']
exec('select * into [' + @DestinationTable + '] from openrowset(''Microsoft.ACE.OLEDB.12.0'', ''Excel 12.0;HDR=YES;Database=' + @TABLENAME + ''', ' + ''' select * from '+@SourceSheet + ''')')
PRINT 'Congratulations!!!! Database is Reset.';
END
above is part of SP code where I am getting an error if i run the below code.
EXEC [ImportExcelFile_Reset] 'C:\temp\TestFiles\OPENASNs.xlsx','Sheet1', 'test', 'Reset'
------------Error-------
(1 row(s) affected)
Msg 3701, Level 11, State 5, Procedure ImportExcelFile_Reset, Line 53
Cannot drop the table '' + @DestinationTable + '', because it does not exist or you do not have permission.
Msg 2714, Level 16, State 6, Line 1
There is already an object named 'test' in the database.
SharePoint_Consultant_EMEAYou you need a dynamic SQL statement for drop too. :)
if @TypeOfUpdate='Reset'
Begin
exec('Drop table '+ @DestinationTable+';
select * into [' + @DestinationTable + ']
from openrowset(''Microsoft.ACE.OLEDB.12.0'', ''Excel 12.0;HDR=YES;Database=' +
@TABLENAME + ''', ' + ''' select * from '+@SourceSheet + ''')')
PRINT 'Congratulations!!!! Database is Reset.';.......
Satheesh
My Blog | How to ask questions in technical forum -
Hi
i have Oracle 10g R2 i'm facing one problem, that there is a table which has been dropped it's in Recycle Bin there is many information about dropped table like Dropped time, user and etc..
But i want to know the Terminal or Machine name which the drop command was issued.
Please guide me in this regard.
NasirHi Masir,
For DDL auditing, consider a DDL trigger:
http://www.dba-oracle.com/t_ddl_triggers.htm
Using the Data Definition Language (DDL) triggers, the Oracle DBA can automatically track all changes to the database, including changes to tables, indexes, and constraints. The data from this trigger is especially useful for change control for the Oracle DBA.
DDL triggers execute every time a DDL statement is executed, and adds new entries to your new table, as shown below:
connect sys/manager
create or replace trigger
DDLTrigger
AFTER DDL ON DATABASE
BEGIN
insert into
perfstat.stats$ddl_log
user_name,
ddl_date,
ddl_type,
object_type,
owner,
object_name
VALUES
ora_login_user,
sysdate,
ora_sysevent,
ora_dict_obj_type,
ora_dict_obj_owner,
ora_dict_obj_name
END;
HTH . ..
Don Burleson -
Gather table stats taking longer for Large tables
Version : 11.2
I've noticed that gathers stats (using dbms_stats.gather_table_stats) is taking longer for large tables.
Since row count needs to be calculated, a big table's stats collection would be understandably slightly longer (Running SELECT COUNT(*) internally).
But for a non-partitioned table with 3 million rows, it took 12 minutes to collect the stats ? Apart from row count and index info what other information is gathered for gather table stats ?
Does Table size actually matter for stats collection ?Max wrote:
Version : 11.2
I've noticed that gathers stats (using dbms_stats.gather_table_stats) is taking longer for large tables.
Since row count needs to be calculated, a big table's stats collection would be understandably slightly longer (Running SELECT COUNT(*) internally).
But for a non-partitioned table with 3 million rows, it took 12 minutes to collect the stats ? Apart from row count and index info what other information is gathered for gather table stats ?
09:40:05 SQL> desc user_tables
Name Null? Type
TABLE_NAME NOT NULL VARCHAR2(30)
TABLESPACE_NAME VARCHAR2(30)
CLUSTER_NAME VARCHAR2(30)
IOT_NAME VARCHAR2(30)
STATUS VARCHAR2(8)
PCT_FREE NUMBER
PCT_USED NUMBER
INI_TRANS NUMBER
MAX_TRANS NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NUMBER
MAX_EXTENTS NUMBER
PCT_INCREASE NUMBER
FREELISTS NUMBER
FREELIST_GROUPS NUMBER
LOGGING VARCHAR2(3)
BACKED_UP VARCHAR2(1)
NUM_ROWS NUMBER
BLOCKS NUMBER
EMPTY_BLOCKS NUMBER
AVG_SPACE NUMBER
CHAIN_CNT NUMBER
AVG_ROW_LEN NUMBER
AVG_SPACE_FREELIST_BLOCKS NUMBER
NUM_FREELIST_BLOCKS NUMBER
DEGREE VARCHAR2(10)
INSTANCES VARCHAR2(10)
CACHE VARCHAR2(5)
TABLE_LOCK VARCHAR2(8)
SAMPLE_SIZE NUMBER
LAST_ANALYZED DATE
PARTITIONED VARCHAR2(3)
IOT_TYPE VARCHAR2(12)
TEMPORARY VARCHAR2(1)
SECONDARY VARCHAR2(1)
NESTED VARCHAR2(3)
BUFFER_POOL VARCHAR2(7)
FLASH_CACHE VARCHAR2(7)
CELL_FLASH_CACHE VARCHAR2(7)
ROW_MOVEMENT VARCHAR2(8)
GLOBAL_STATS VARCHAR2(3)
USER_STATS VARCHAR2(3)
DURATION VARCHAR2(15)
SKIP_CORRUPT VARCHAR2(8)
MONITORING VARCHAR2(3)
CLUSTER_OWNER VARCHAR2(30)
DEPENDENCIES VARCHAR2(8)
COMPRESSION VARCHAR2(8)
COMPRESS_FOR VARCHAR2(12)
DROPPED VARCHAR2(3)
READ_ONLY VARCHAR2(3)
SEGMENT_CREATED VARCHAR2(3)
RESULT_CACHE VARCHAR2(7)
09:40:10 SQL> >
Does Table size actually matter for stats collection ?yes
Handle: Max
Status Level: Newbie
Registered: Nov 10, 2008
Total Posts: 155
Total Questions: 80 (49 unresolved)
why so many unanswered questions? -
Hi All,
DB version:10.2.0.4
OS:Aix 6.1
I want to gather table stats for a table since the query which uses this table is running slow. Also I noticed that this table is using full table scan and it was last analyzed 2 months back.
I am planning to execute the below query for gathering the stats. The table has 50 million records.
COUNT(*)
51364617
I expect this gonna take a long time if I execute the query Like below.
EXEC DBMS_STATS.gather_table_stats('schema_name', 'table_name');
My doubts specified below.
1. can i use the estimate_percent parameter also for gathering the stats ?
2. how much percentage should I specify for the parameter estimate_percent?
3. what difference will it make if I use the estimate_percent parameter?
Thanks in advance
Edited by: user13364377 on Mar 27, 2012 1:28 PMIf you are worried about the stats gathering process running for a long time, consider gathering stats in parallel.
1. Can you use estimate_percent? Sure! Go for it.
2. What % to use? Why not let the database decide with auto_sample_size? Various "rules of thumb" have been thrown around over the years, usually around 10% to 20%.
3. What difference will it make? Very little, probably. Occasionally you might see where a small sample size makes a difference, but in general it is perfectly ok to estimate stats.
Perhaps something like this:
BEGIN
dbms_stats.gather_table_stats(ownname => user, tabname => 'MY_TABLE',
estimate_percent => dbms_stats.auto_sample_size, method_opt=>'for all columns size auto',
cascade=>true,degree=>8);
END; -
Recovering dropped table without using pointing time recovery/
Hi geeks,
Noob here.I have a question*.I want to recover the dropped table with data with out using pointing time recovery.*
for Ex:Use hasr dropped the table at 10:00 and realized that he dropped the table at 16:00hrs .So i want to fetch the data(DDL+DML) without using pointing time recovery.
So please find answers for my question.
Thank you,
Rakesh M.Welcome to the forum!
Whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
>
Noob here.I have a question*.I want to recover the dropped table with data with out using pointing time recovery.*
for Ex:Use hasr dropped the table at 10:00 and realized that he dropped the table at 16:00hrs .So i want to fetch the data(DDL+DML) without using pointing time recovery.
>
FLASHBACK TABLE myTable TO BEFORE DROP;
See the examples in the FLASHBACK TABLE section of the SQL Language doc
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9012.htm
>
Retrieving a Dropped Table: Example If you accidentally drop the pm.print_media table and want to retrieve it, then issue the following statement:
FLASHBACK TABLE print_media TO BEFORE DROP;
If another print_media table has been created in the pm schema, then use the RENAME TO clause to rename the retrieved table:
FLASHBACK TABLE print_media TO BEFORE DROP RENAME TO print_media_old;
If you know that the employees table has been dropped multiple times, and you want to retrieve the oldest version, then query the USER_RECYLEBIN table to determine the system-generated name, and then use that name in the FLASHBACK TABLE statement. (System-generated names in your database will differ from those shown here.)
SELECT object_name, droptime FROM user_recyclebin
WHERE original_name = 'PRINT_MEDIA';
OBJECT_NAME DROPTIME
RB$$45703$TABLE$0 2003-06-03:15:26:39
RB$$45704$TABLE$0 2003-06-12:12:27:27
RB$$45705$TABLE$0 2003-07-08:09:28:01 -
Table is been dropped and i want o recover it.
Database is running in archive log mode and i had valid full database rman backup too.
flashback is disabled.
database version -10g
Please let me know the steps i can follow to recover the dropped table.Hello,
If your RECYCLEBIN is activated you may Flashback Drop your Table.
So you may check your RECYCLEBIN by using the following query:
select object_name, original_name from user_recyclebin;If you can see your Table (original_name) so you may execute the statement below:
flashback table <table_name> to before drop;Else, you'll need a Backup or a dump to restore your Table.
For instance, by duplicating your database elsewhere and get back the Table by DataPump (expdp/impdp).
Hope this help.
Best regards,
Jean-Valentin
Edited by: Lubiez Jean-Valentin on Feb 3, 2010 10:13 PM -
Drop table for multiple tables
Hi All,
I want to drop multiple tables in one drop statement.
Can it be possible?
Thanks in advance!!
SAHi,
CASCADE CONSTRAINTS must be taken into account. E.g.,
set pages 0
spool c:\windows\temp\drop.sql
select 'DROP TABLE '||TABLE_NAME || ' CASCADE CONSTRAINTS;' from user_tables WHERE table_name like 'ZTEST%';
spool off
@c:\windows\temp\drop.sqlHere is a test case:
SQL> set echo off
SQL> create table ztest1 (ff NUMBER PRIMARY KEY);
Table created
SQL> insert into ztest1 select 1 from dual;
1 row inserted
SQL> create table ztest2 (gg NUMBER, constraint gg_fk foreign key (gg) references ztest1(ff));
Table created
SQL> insert into ztest2 select 1 from dual;
1 row inserted
SQL> drop table ztest1;
drop table ztest1
ORA-02449: unique/primary keys in table referenced by foreign keys
SQL>
SQL> set pages 0
SQL> spool c:\windows\temp\drop.sql
Started spooling to c:\windows\temp\drop.sql
SQL> select 'DROP TABLE '||TABLE_NAME || ' CASCADE CONSTRAINTS;' from user_tables WHERE table_name like 'ZTEST%';
DROP TABLE ZTEST1 CASCADE CONSTRAINTS;
DROP TABLE ZTEST2 CASCADE CONSTRAINTS;
SQL> spool off
Stopped spooling to c:\windows\temp\drop.sql
SQL> @c:\windows\temp\drop.sql
SQL> DROP TABLE ZTEST1 CASCADE CONSTRAINTS;
Table dropped
SQL> DROP TABLE ZTEST2 CASCADE CONSTRAINTS;
Table dropped
SQL>
Maybe you are looking for
-
XSLT-Mapping for Genesys in combination with IC Webclient
Hi, Im not sure if this is the correct area of the SDN but I dont know better I have the following problem: In the Account Identification Profile I can define an ApplicationID and an XSLT-File to transform my SOAP-request accordingly to search a Busi
-
I am trying to purchase and download Mountain Lion from the App Store. I have all the requirements met, but I get an error message saying my computer is not compatible. What's up and how do I fix it? Here are 2 screen captures of my system specs:
-
2.0.2 Not in iTunes Help!
I can't wait till 2.1 I just updated a couple of Apps and my iPhone crashed so I have to restore AGAIN! and I go to click restore in iTunes and I get this http://i193.photobucket.com/albums/z256/OSXnerd/Picture1-4.png " Software for this iPhone is no
-
Untangling Mavericks from iCloud
I recently updated our Macs from Snow Leopard (10.6.8) to Mavericks (10.9.x). We had skipped Lion and Mountain Lion due to their heavy iCloud entanglement. iCloud syncing is a handy tool for on-the-go metropolitans with high bandwidth, symmetrical in
-
How do I get rid of all the music on my phone?
I want to put music on my phone, but ITunes is saying I have music already on it. How do I get rid of the blue music bar so I can put music I want on it without going over the GB limit?