Cómo especificar restricciones de usuario y otras tablas en Teradata

Soy nuevo Teradata. I have been using Oracle for quite a bit. However, when I tried to run the following queries in Teradata, they simply did not work. How can I translate the following queries into Teradata:

select Table_name, constraint_name, constraint_type,
   r_constraint_name, Delete_rule, search_condition
 from user_constraints
  order by table_name, constraint_name;

select object_name, object_id, Object_type,
   Created, last_DDL_time, status
 from user_Objects
  order by object_name;

select table_name, column_name, data_type, data_length,
   data_precision, nullable, column_id, data_default
 from user_tab_columns
  order by table_name, column_name;

preguntado el 09 de septiembre de 13 a las 21:09

2 Respuestas

For most system views there are several versions, those ending with "X" are similar to Oracle's "user_" views, without "X" it's "all_", p.ej:

dbc.Tables: old version, deprecated since TD12 dbc.TablesX: old version, deprecated since TD12 dbc.TablesV: recommended version, all objects in all databases dbc.TablesVX: recommended version, objects where the submitting user has any access right

The different constraint types are stored in different places in Teradata.

Foreign Keys: dbc.All_ri_childrenV

Table level CHECK: dbc.Table_LevelConstraintsV

Column level CHECK: dbc.ColumnsV.ColumnConstraint

NULL: dbc.ColumnsV.Nullable

Primary Key: dbc.IndicesV.IndexType = 'K'

Unique: dbc.IndicesV.IndexType = 'U'

Pero, you might notice that not all Primary/Foreign Keys and Unique constraints are implemented in your environment to avoid additional overhead as this is already maintained by the load process (this is the same for Teradata or any other Data Warehouse).

Respondido el 11 de Septiembre de 13 a las 10:09

In teradata most metadata information is held in dbc..

objects in oracle might map to dbc.tables.

select * from dbc.tables.

para el último:

  SELECT tablename, 
         columnname,
         columntype,
         columnformat,
         columnlength,
         Nullable,
         columnid,defaultvalue
    FROM dbc.columns

I am looking to fulfill the user_constraints,will update once I find something.

Hope the above is helpful.

Respondido el 11 de Septiembre de 13 a las 13:09

+1 Thank You very much. I shall assign the bounty once it could be started. Please let me know how to handle the other ones Thanks - CHEBURASHKA

I am not sure of some of the columsn in contraint tables in oracle but this what I could come up with. select con.Name ConstraintName, constrainttype, TVMName Tablename from dbc.ConstraintNames con INNER JOIN dbc.tvm tvm On TABLEID=TVMID - kishore krv

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.