1 Reply Latest reply on Feb 25, 2016 8:47 AM by Ramesh Reddy

    How to differentiate between table and view in get schema method ?

    Nishant Agrawal Novice

      Hi ,

       

      When we call below getSchema method of teiid admin.

      admin.getSchema(vdbName, vdbVersion, modelName, allowedTypes, typeNamePattern);

       

      It returns string in below format :

       

      CREATE FOREIGN TABLE "demo.certificate" (

        cert_id long NOT NULL AUTO_INCREMENT OPTIONS (ANNOTATION '', NAMEINSOURCE '`cert_id`', NATIVE_TYPE 'INT UNSIGNED'),

        cert_name string(45) NOT NULL OPTIONS (ANNOTATION '', NAMEINSOURCE '`cert_name`', NATIVE_TYPE 'VARCHAR'),

        emp_id long OPTIONS (ANNOTATION '', NAMEINSOURCE '`emp_id`', NATIVE_TYPE 'INT UNSIGNED'),

        CONSTRAINT "PRIMARY" PRIMARY KEY(cert_id),

        CONSTRAINT FK_certificate_1 FOREIGN KEY(emp_id) REFERENCES aakash_test.employee (emp_id)

      ) OPTIONS (ANNOTATION '', NAMEINSOURCE '`demo`.`certificate`', UPDATABLE TRUE);

       

      CREATE FOREIGN TABLE "demo.employee" (

        emp_id long NOT NULL AUTO_INCREMENT OPTIONS (ANNOTATION '', NAMEINSOURCE '`emp_id`', NATIVE_TYPE 'INT UNSIGNED'),

        emp_fname string(45) OPTIONS (ANNOTATION '', NAMEINSOURCE '`emp_fname`', NATIVE_TYPE 'VARCHAR'),

        emp_lname string(45) OPTIONS (ANNOTATION '', NAMEINSOURCE '`emp_lname`', NATIVE_TYPE 'VARCHAR'),

        salary long DEFAULT '0' OPTIONS (ANNOTATION '', NAMEINSOURCE '`salary`', NATIVE_TYPE 'INT UNSIGNED'),

        address string(45) OPTIONS (ANNOTATION '', NAMEINSOURCE '`address`', NATIVE_TYPE 'VARCHAR'),

        CONSTRAINT "PRIMARY" PRIMARY KEY(emp_id),

        CONSTRAINT uc_empID UNIQUE(emp_id, emp_fname)

      ) OPTIONS (ANNOTATION '', NAMEINSOURCE '`demo`.`employee`', UPDATABLE TRUE);

       

      CREATE FOREIGN TABLE "demo.test" (

        emp_fname string(45) OPTIONS (ANNOTATION '', NAMEINSOURCE '`emp_fname`', NATIVE_TYPE 'VARCHAR'),

        emp_lname string(45) OPTIONS (ANNOTATION '', NAMEINSOURCE '`emp_lname`', NATIVE_TYPE 'VARCHAR'),

        address string(45) OPTIONS (ANNOTATION '', NAMEINSOURCE '`address`', NATIVE_TYPE 'VARCHAR'),

        cert_name string(45) NOT NULL OPTIONS (ANNOTATION '', NAMEINSOURCE '`cert_name`', NATIVE_TYPE 'VARCHAR')

      ) OPTIONS (ANNOTATION '', NAMEINSOURCE '`demo`.`test`', UPDATABLE TRUE);

       

      So how can we differentiate between table and view ?

      Note : Here 'certificate' and 'employee' are tables and I have created 'test' as view using those two tables.

       

      Please help. Thanks