Freitag, 16. November 2012

Checking a column definition in Oracle

Sometimes it is useful to check, if a specific column of a specific table has the required definition. Oracle exports the structure of all tables in the table all_tab_columns. Here is an example to check if a table PERSON exists with a column FIRSTNAME being of the type VARCHAR2 holding 100 bytes:
select count(*) from all_tab_columns 
  table_name = 'PERSON' and
  column_name = 'FIRSTNAME' and
  data_type = 'VARCHAR2' and
  data_length = 100;

Keine Kommentare: