Reputation: 439
How to Enable/Disable Indexes in TERADATA Database?
I want to disable indexes and do update and then enable the indexes in Teradata.
If Enable/Disable option not available in Teradata, in the sense How can I achieve this ? If I use DROP Indexes, how can I recreate the indexes for all the tables?
Upvotes: 2
Views: 10011
Reputation: 466
Since you did not specify what kind of index you want to disable/enable, below are the approach you can follow on either cases.
DROP TABLE <OldTable>;
RENAME TABLE <NewTable> TO <OldTable>;
Above recommendation for Primary Index is only applicable if you are going to update a primary index column value. If you will update other columns (not the PI column) then you can just issue an UPDATE Statement directly.
DROP INDEX <IndexName> ON <TableName>;
CREATE INDEX <IndexName> (<ColumnList>) ON <TableName>;
Upvotes: 0
Reputation: 741
Simple answer - you can't disable and re-enable indexes in Teradata. However, there some workarounds.
Drop Index If you talking about PI (primary index) - you can't drop it. All you can do is to make a copy of a table without an index. You can drop secondary index though. Then simply create it again when you need it.
Drop-Create Table This doesn't fit all cases, but often this is the fastest way to do the work, especially if the issue you have is with PI.
BTW: it is not clear, why would you need to do that? Performance or logic or something else? That probably will affect recommendation.
Upvotes: 1
Reputation: 313
Teradata gives you a way to create a table without choosing for primary index (if you are sure of any column).
You can create table with No primary Index. Here is a sample of how to do so:
Create table <table name>
(<columnname> <datatype>,
<columnname> <datatype>)
no primary index ;
Upvotes: 3
Reputation: 21
In Teradata
you can't drop Primary index of a table
. The primary index
defines where data will reside and which AMP receives the row.
To alter the primary index
of a table you need to delete all
the records from the table ( As data is already distributed by the row hash value of the PI)
then only you can change the primary index of a table by using below command:-
Alter table table_name modify primary index index_name (column list);
Steps to achieve your goal
( temp, wrk, intermediate table)
insert the records from the original table and update the wrk table.And you are done.
Upvotes: 1
Reputation: 4017
Teradata does not have a disable index feature.
All tables have a Primary Index (PI) which is chosen by the RDBMS unless you specify one.
CREATE INDEX <index name> (<column list>) ON table name;
CREATE UNIQUE INDEX (department) ON tbl_employee;
DROP INDEX ind_dept ON tbl_employee;
DROP INDEX (department,emp_number) ON tbl_employee;
Upvotes: 2