-- h:\xconnect\TableGeneration\XCTableGen.con
--
-- Generated for Oracle 8 on Fri Aug 09  14:39:38 2002 by Server Generator 2.1.24.3.0

SET ECHO ON
SPOOL XCTableGen.con.OUT

undefine tbl_owner
define tbl_owner = &1

-- PROMPT Creating Primary Key on 'XC_SITES'
ALTER TABLE &&tbl_owner..XC_SITES
 ADD CONSTRAINT STE_PK PRIMARY KEY
  (STATION_ID);

-- PROMPT Creating Check Constraints on 'XC_SITES'
ALTER TABLE &&tbl_owner..XC_SITES
 ADD CONSTRAINT AVCON_5863_ENABL_000 CHECK (ENABLED IN ('Y', 'N'))
 ADD CONSTRAINT AVCON_5863_TIME__000 CHECK (GMT_OFFSET
IN (0, -12, 11, -11, 12, 1, -10, 2, -9, 3, -8, 4, -7, 5, -6, 6, -5,
7, -4, 8, -3, 9, -2, 10, -1));

-- PROMPT Creating Primary Key on 'XC_SITESENSORS'
ALTER TABLE &&tbl_owner..XC_SITESENSORS
 ADD CONSTRAINT SITSEN_PK PRIMARY KEY
  (SENSORNAME
  ,STE_STATION_ID);

-- PROMPT Creating Check Constraints on 'XC_SITESENSORS'
ALTER TABLE &&tbl_owner..XC_SITESENSORS
 ADD CONSTRAINT CON_DATA_TABLE CHECK (DATA_TABLE
IN ('XC_DATA7', 'XC_DATA8', 'XC_DATA9', 'XC_DATA10', 'XC_DATA11',
'XC_DATA1', 'XC_DATA2', 'XC_DATA12', 'XC_DATA3', 'XC_DATA4',
'XC_DATA5', 'XC_DATA6', 'XC_TXTDATA1'))


-- PROMPT Creating Foreign Keys on 'XC_SITESENSORS'
ALTER TABLE &&tbl_owner..XC_SITESENSORS ADD CONSTRAINT
 SITSEN_STE_FK FOREIGN KEY
  (STE_STATION_ID) REFERENCES &&tbl_owner..XC_SITES
  (STATION_ID);


-- PROMPT Creating Primary Key on 'XC_DATA1'
ALTER TABLE &&tbl_owner..XC_DATA1
 ADD CONSTRAINT DAT1_PK PRIMARY KEY
  (TIME_TAG
  ,SOURCE
  ,STATION_ID
  ,SENSORNAME);


-- PROMPT Creating Primary Key on 'XC_GOESQC'
ALTER TABLE &&tbl_owner..XC_GOESQC
 ADD CONSTRAINT GOESQC_PK PRIMARY KEY
  (NESDIS_ID
  ,TIME_TAG
  ,SOURCE);

-- PROMPT Creating Primary Key on 'XC_RTUQC'
ALTER TABLE &&tbl_owner..XC_RTUQC
ADD CONSTRAINT RTUQC_PK PRIMARY KEY
 (
    STATION_ID,
    TIME_TAG,
    RX_TX
 );

-- PROMPT Creating Primary Key on 'XC_TXTDATA1'
ALTER TABLE &&tbl_owner..XC_TXTDATA1
 ADD CONSTRAINT TXD1_PK PRIMARY KEY
  (TIME_TAG
  ,SOURCE
  ,STATION_ID
  ,SENSORNAME);

-- PROMPT Creating Primary Key on 'XC_PPLIST'
ALTER TABLE &&tbl_owner..XC_PPLIST
 ADD CONSTRAINT PPLIST_PK PRIMARY KEY
  (STATION_ID
  ,SENSORNAME
  ,DATA_LABEL
  ,FUNCTION_NAME
 );

-- PROMPT Creating Primary Key on 'XC_PPDATA1'
ALTER TABLE &&tbl_owner..XC_PPDATA1
 ADD CONSTRAINT PPDAT1_PK PRIMARY KEY
  (STATION_ID
  ,SENSORNAME
  ,DATA_LABEL
  ,FUNCTION_NAME
  ,TIME_TAG
  ,TIME_PERIOD);

-- PROMPT Creating Primary Key on 'XC_LOG'
ALTER TABLE &&tbl_owner..XC_LOG
 ADD CONSTRAINT LOG_PK PRIMARY KEY (TIME_TAG, SOURCE);
-- PROMPT Creating Primary Key on 'XC_USERS'
ALTER TABLE &&tbl_owner..XC_USERS
 ADD CONSTRAINT USERS_PK PRIMARY KEY (USER_NAME);
-- PROMPT Creating Primary Key on 'XC_TEMPLATES'
ALTER TABLE &&tbl_owner..XC_TEMPLATES
 ADD CONSTRAINT TEMPLATES_PK PRIMARY KEY (TEMPLATE_NAME);
-- PROMPT Creating Primary Key on 'XC_RECORDIDS'
ALTER TABLE &&tbl_owner..XC_RECORDIDS
 ADD CONSTRAINT RECORDIDS_PK PRIMARY KEY (STE_STATION_ID , RECORD_ID);
-- PROMPT Creating Primary Key on 'XC_SITESENSORSDECODE'
ALTER TABLE &&tbl_owner..XC_SITESENSORSDECODE
 ADD CONSTRAINT SITESENSORSDECODE_PK PRIMARY KEY (TOPIC, SENSOR, STATION, SEQNUM);
-- PROMPT Creating Primary Key on 'XC_POLLGROUPS'
ALTER TABLE &&tbl_owner..XC_POLLGROUPS
 ADD CONSTRAINT POLLGROUPS_PK PRIMARY KEY (GROUP_NUM);

-- PROMPT Creating Primary Key on 'XC_LASTVALUES'
ALTER TABLE &&tbl_owner..XC_LASTVALUES
 ADD CONSTRAINT DAT1_PK PRIMARY KEY (STATION_ID, SENSORNAME);


SPOOL OFF
