is there any chance to drop a column in a compressed table?
I checked google and it seems like its not possible at all.
to get sure im asking here.
regards
set that column to unused:
ALTER TABLE TEST SET UNUSED (column name);
ALTER TABLE TEST DROP unused columns;
Note: This statement does not actually remove the target column data or restore the disk space occupied by these columns. However, a column that is marked as unused is not displayed in queries or data dictionary views, and its name is removed so that a new column can reuse that name. All constraints, indexes, and statistics defined on the column are also removed.
If that does not work for you for some reason, you can try to move the table into a non-compressed format and then drop the column and compress again.
Related
After marking a column as unused on my compressed and partitioned table, whenever i try to do
ALTER TABLE t1 DROP UNUSED COLUMNS;
I get the error:
ORA-12996: cannot drop system-generated virtual column
What can i do?
This worked for me:
alter table t drop unused columns checkpoint 500;
The system-generated virtual column typically supports a function-based index.
Please show us the DBMS_METADATA.GET_DDL() for the table just like in this Ask Tom example.
Once the source of the column is known, dropping it may be easier (or maybe not in some unusual cases.)
I need to add functionality to the existing mib and agent code to delete all the rows of a table (i.e. clear the contents of a table).
I know how to delete a single row (using the rowstatus "destroy"), but how to delete all the rows in one go?
As You already know, the deletion of a row is a side-effect of changing the rowstatus column. You could use a special object next to the table which would clear the table itself.
NOTE: One of the rules of SNMP is avoiding redundancy. The SNMP manager can already delete the whole table content by deleting the rows one by one.
I have a table A (3 columns) in production which is around 10 million records. I wanted to add one more column to that table and also I want to make default value to 1. Is it going to impact production DB performance If add a column with default value 1 or something else. What would be best approach to this to avoid any kind of performance impact on DB? your thoughts are much appreciated!!
In Oracle 11g the process of adding a new column with a default value has been considerably optimized. If a newly added column is specified as NOT NULL, default value for that column is maintained in the data dictionary and it's no longer required for a default value of a column to be stored for all records in a table, so it's no longer required to update each record with a default value. Such an optimization considerably reduces amount of time the table is exclusively locked during the operation.
alter table <tab_name> add(<col_name> <data_type> default <def_val> not null)
Moreover, column with a default value added that way will not consume space, until you deliberately start to update that column or insert a record with a non default value for that column. So the operation of adding a new column with a default value and not null constraint specified completes pretty quick.
i think that it is better that you create a table as backup table with this syntax:
create table BackUpTable as SELECT * FROM YourTable;
alter table BackUpTable add (newColumn number(5,0)default 1);
I have one table named test which has 3 columns:
Name
id
address
After some time I know one column is not in use. I want to drop one column, let's say id .
Oracle has one feature to identify a column as unused. What is differenc between drop column vs set unused column?
When you drop a column it moves into recycle bin while when you mark a column unused it is like logically dropping it but physically preserving it.
Sometimes marking a column as unused and then using the alter table name drop unused column statement is useful because it allows the DBA to take away column access quickly and immediately. Later on, during a routine database maintenance weekend or after business hours, you can then remove the column with the alter table name drop unused column to reclaim the space.
On the other hand, marking the column unused won't free up any space and when there is an need to free up space and remove the columns that are not needed you would be better off dropping it.
It's a matter of convenience, actually...
see here
setting to "unused" is just like dropping, but will allow you to defer the actual physical deletion to a later date.
This is a help to DBA's maintenance window not for your use in general. For developer it means DROP column. that's it, no recovery later point. instead if you are in 12 c then use INVISIBLE option.
I have some large tables (millions of rows). I constantly receive files containing new rows to add in to those tables - up to 50 million rows per day. Around 0.1% of the rows I receive are duplicates of rows I have already loaded (or are duplicates within the files). I would like to prevent those rows being loaded in to the table.
I currently use SQLLoader in order to have sufficient performance to cope with my large data volume. If I take the obvious step and add a unique index on the columns which goven whether or not a row is a duplicate, SQLLoader will start to fail the entire file which contains the duplicate row - whereas I only want to prevent the duplicate row itself being loaded.
I know that in SQL Server and Sybase I can create a unique index with the 'Ignore Duplicates' property and that if I then use BCP the duplicate rows (as defined by that index) will simply not be loaded.
Is there some way to achieve the same effect in Oracle?
I do not want to remove the duplicate rows once they have been loaded - it's important to me that they should never be loaded in the first place.
What do you mean by "duplicate"? If you have a column which defines a unique row you should setup a unique constraint against that column. One typically creates a unique index on this column, which will automatically setup the constraint.
EDIT:
Yes, as commented below you should setup a "bad" file for SQL*Loader to capture invalid rows. But I think that establishing the unique index is probably a good idea from a data-integrity standpoint.
Use Oracle MERGE statement. Some explanations here.
You dint inform about what release of Oracle you have. Have a look at there for merge command.
Basically like this
---- Loop through all the rows from a record temp_emp_rec
MERGE INTO hr.employees e
USING temp_emp_rec t
ON (e.emp_ID = t.emp_ID)
WHEN MATCHED THEN
--- _You can update_
UPDATE
SET first_name = t.first_name,
last_name = t.last_name
--- _Insert into the table_
WHEN NOT MATCHED THEN
INSERT (emp_id, first_name, last_name)
VALUES (t.emp_id, t.first_name, t.last_name);
I would use integrity constraints defined on the appropriate table columns.
This page from the Oracle concepts manual gives an overview, if you also scroll down you will see what types of constraints are available.
use below option, if you will get this much error 9999999 after that your sqlldr will terminate.
OPTIONS (ERRORS=9999999, DIRECT=FALSE )
LOAD DATA
you will get duplicate records in bad file.
sqlldr user/password#schema CONTROL=file.ctl, LOG=file.log, BAD=file.bad