SnowConvert AI – Sybase IQ – CREATE TABLE

Descrição

Cria uma nova tabela no banco de dados atual. Você define uma lista de colunas, cada uma contendo dados de um tipo distinto. O proprietário da tabela é o emissor do comando CREATE TABLE.

Para obter mais informações, consulte a documentação de CREATE TABLE.

Sintaxe gramatical

 CREATE [ { GLOBAL | LOCAL } TEMPORARY ] TABLE
   [ IF NOT EXISTS ] [ <owner>. ]<table-name>
    ( <column-definition> [ <column-constraint> ]  
   [ , <column-definition> [ <column-constraint> ] ]
   [ , <table-constraint> ]  ) 
   |{ ENABLE | DISABLE } RLV STORE
  
   [ IN <dbspace-name> ]
   [ ON COMMIT { DELETE | PRESERVE } ROWS ]
   [ AT <location-string> ]
   [PARTITION BY 
     <range-partitioning-scheme>
     | <hash-partitioning-scheme> 
     | <composite-partitioning-scheme> ]

<column-definition> ::=
   <column-name> <data-type> 
    [ [ NOT ] NULL ] 
    [ DEFAULT <default-value> | IDENTITY ] 
    [ PARTITION | SUBPARTITION ( <partition-name> IN  <dbspace-name> [ , ... ] ) ]

<default-value> ::=
   <special-value>
   | <string>
   | <global variable>
   | [ - ] <number>
   | ( <constant-expression> )
   | <built-in-function>( <constant-expression> )
   | AUTOINCREMENT
   | CURRENT DATABASE
   | CURRENT REMOTE USER
   | NULL
   | TIMESTAMP
   | LAST USER

<special-value> ::=
   CURRENT 
   { DATE | TIME | TIMESTAMP | USER | PUBLISHER }
   | USER

<column-constraint> ::=
   IQ UNIQUE ( <integer> )
   | { [ CONSTRAINT <constraint-name> ] 
     { UNIQUE  
        | PRIMARY KEY  
        | REFERENCES <table-name> [ ( <column-name> ) ] [ ON { UPDATE | DELETE } RESTRICT ] }
      [ IN <dbspace-name> ]
      | CHECK ( <condition> )
   }

<table-constraint> ::=
    [ CONSTRAINT <constraint-name> ] 
   {  { UNIQUE | PRIMARY KEY } ( <column-name> [ ,  ] )  
     [ IN <dbspace-name> ]
     | <foreign-key-constraint>
     | CHECK ( <condition> )
   }

<foreign-key-constraint> ::=
   FOREIGN KEY [ <role-name> ] [ ( <column-name> [ , <column-name> ]  ) ] 
   REFERENCES <table-name> [ ( <column-name> [ , <column-name> ]  ) ]
   [ <actions> ] [ IN <dbspace-name> ]

<actions> ::=
   [ ON { UPDATE | DELETE } RESTRICT ]

<location-string> ::=
   { <remote-server-name>. [ <db-name> ].[ <owner> ].<object-name>
      | <remote-server-name>; [ <db-name> ]; [ <owner> ];<object-name> }

<range-partitioning-scheme> ::=
   RANGE ( <partition-key> ) ( <range-partition-decl> [,<range-partition-decl>  ] )

<partition-key> ::= <column-name>

<range-partition-declaration> ::=
    <range-partition-name> VALUES <= ( {<constant> |  MAX } ) [ IN <dbspace-name> ]

<hash-partitioning-scheme> ::=
   HASH ( <partition-key> [ , <partition-key>,  ] )

<composite-partitioning-scheme> ::=
   <hash-partitioning-scheme> SUBPARTITION BY <range-partitioning-scheme>
Copy

TEMPORARY TABLES

Descrição

No Sybase IQ GLOBAL | LOCAL TEMPORARY é usado para criar tabelas temporárias que existem somente para a sessão. Essas tabelas são específicas da sessão e são automaticamente excluídas quando a sessão termina. Elas ajudam a armazenar resultados intermediários ou dados de trabalho sem afetar o esquema permanente do banco de dados. Isso também pode ser criado apenas com a adição de # no início do nome.

Aviso

Essa sintaxe é parcialmente compatível com o Snowflake.

Sintaxe da gramática

 CREATE [ { GLOBAL | LOCAL } TEMPORARY ] TABLE 
Copy

Amostra de padrões da origem

Código de entrada:

Sybase
 CREATE LOCAL TEMPORARY TABLE TABLE01 (
    col1 INTEGER
);

CREATE GLOBAL TEMPORARY TABLE TABLE02 (
    col1 INTEGER
);

CREATE TABLE #TABLE03(
    col1 INTEGER
);
Copy
Código de saída:
Sybase
 CREATE OR REPLACE TEMPORARY TABLE TABLE01 (
    col1 INTEGER
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "03/19/2025",  "domain": "test" }}'
;

--** SSC-FDM-0009 - GLOBAL TEMPORARY TABLE FUNCTIONALITY NOT SUPPORTED. **
CREATE OR REPLACE TABLE TABLE02 (
    col1 INTEGER
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "03/19/2025",  "domain": "test" }}'
;

CREATE OR REPLACE TEMPORARY TABLE T_TABLE03 (
    col1 INTEGER
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "03/19/2025",  "domain": "test" }}'
;
Copy

IF NOT EXISTS

Descrição

Garante que a tabela seja criada somente se ela ainda não existir, evitando duplicação e erros no script SQL. (Referência de linguagem Sybase SQL).

SuccessPlaceholder

Essa sintaxe é totalmente compatível com o Snowflake.

Sintaxe da gramática

 IF NOT EXISTS
Copy

Amostra de padrões da origem

Código de entrada:

Sybase
 CREATE TABLE IF NOT EXISTS table1 (
    col1 INTEGER
);
Copy
Código de saída:
Snowflake
 CREATE TABLE IF NOT EXISTS table1 (
    col1 INTEGER
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "03/19/2024" }}';
Copy

(ENABLE | DISABLE) RLV STORE

Descrição

Controla a funcionalidade do Row-Level Versioning Store. (Referência de linguagem Sybase SQL).

Nota

Essa sintaxe não é necessária no Snowflake.

Sintaxe da gramática

 { ENABLE | DISABLE } RLV STORE
Copy

Amostra de padrões da origem

Código de entrada:

Sybase
 CREATE TABLE rlv_table
(id INT)
ENABLE RLV STORE;
Copy
Código de saída:
Snowflake
 CREATE OR REPLACE TABLE rlv_table
(
id INT
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "07/11/2025",  "domain": "no-domain-provided" }}'
;
Copy

IN DBSPACE

Descrição

Especifica o espaço DB para armazenamento de dados. (Referência de linguagem Sybase SQL).

Nota

Essa sintaxe não é necessária no Snowflake. O Snowflake lida automaticamente com o armazenamento.

Sintaxe da gramática

 IN <dbspace-name>
Copy

Amostra de padrões da origem

Código de entrada:

Sybase
 CREATE TABLE dbspace_table (
    id INT PRIMARY KEY
) 
IN my_dbspace;
Copy
Código de saída:
Snowflake
 CREATE OR REPLACE TABLE dbspace_table (
    id INT PRIMARY KEY
); 
Copy

ON COMMIT

Descrição

Especifica o comportamento da tabela temporária quando um commit é feito. (Referência de linguagem Sybase SQL)

Aviso

Essa sintaxe é parcialmente suportada.

Sintaxe da gramática

 [ ON COMMIT { DELETE | PRESERVE } ROWS ]
Copy

Amostra de padrões da origem

Código de entrada:

Sybase
 CREATE LOCAL TEMPORARY TABLE temp_employees (
    DATA VARCHAR(255)
) ON COMMIT DELETE ROWS;  

CREATE LOCAL TEMPORARY TABLE temp_projects (
    DATA VARCHAR(255)
) ON COMMIT PRESERVE ROWS; 
Copy
Código de saída:
Snowflake
 CREATE OR REPLACE TEMPORARY TABLE temp_employees (
    DATA VARCHAR(255)
)
--    --** SSC-FDM-0008 - ON COMMIT NOT SUPPORTED **
--    ON COMMIT DELETE ROWS
    COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "03/19/2025",  "domain": "test" }}'
;

CREATE OR REPLACE TEMPORARY TABLE temp_projects (
    DATA VARCHAR(255)
) ON COMMIT PRESERVE ROWS
    COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "03/19/2025",  "domain": "test" }}'
;
Copy

EWIs relacionados

SSC-FDM-0008: On Commit não suportado.

AT LOCATION

Descrição

Cria uma tabela remota (proxy). (Referência de linguagem Sybase SQL)

Perigo

Essa sintaxe não é compatível com o Snowflake.

Sintaxe da gramática

 AT <location-string>
Copy

Amostra de padrões da origem

Código de entrada:

Sybase
 CREATE TABLE t1
( 
    DATA VARCHAR(10)
)
AT 'SERVER_A.db1.joe.t1'; 
Copy
Código de saída:
Snowflake
 CREATE OR REPLACE TABLE t1
(
    DATA VARCHAR(10)
)
    !!!RESOLVE EWI!!! /*** SSC-EWI-SY0002 - UNSUPPORTED REMOTE TABLE SYNTAX ***/!!!
AT 'SERVER_A.db1.joe.t1'
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "07/11/2025",  "domain": "no-domain-provided" }}'
;
Copy

EWIs relacionados

SSC-EWI-SY0002: UNSUPPORTED REMOTE TABLE SYNTAX.

PARTITION BY

Descrição

Todas as linhas de uma partição de tabela são fisicamente colocalizadas. (Referência de linguagem Sybase SQL)

Nota

Essa sintaxe não é necessária no Snowflake.

Sintaxe da gramática

 PARTITION BY 
     <range-partitioning-scheme>
     | <hash-partitioning-scheme> 
     | <composite-partitioning-scheme>
     
<range-partitioning-scheme> ::=
   RANGE ( <partition-key> ) ( <range-partition-decl> [,<range-partition-decl>  ] )

<partition-key> ::= <column-name>

<range-partition-declaration> ::=
    <range-partition-name> VALUES <= ( {<constant> |  MAX } ) [ IN <dbspace-name> ]

<hash-partitioning-scheme> ::=
   HASH ( <partition-key> [ , <partition-key>,  ] )

<composite-partitioning-scheme> ::=
   <hash-partitioning-scheme> SUBPARTITION BY <range-partitioning-scheme>
Copy

Amostra de padrões da origem

Código de entrada:

Sybase
 -- Range Partitioning
CREATE TABLE sales (
    sale_id INT,
    sale_date DATE,
    amount DECIMAL(10, 2)
)
PARTITION BY RANGE (sale_date) (
    p1 VALUES <= ('2023-01-01'),
    p2 VALUES <= ('2024-01-01'),
    p3 VALUES <= (MAXVALUE)
);

-- Hash Partitioning
CREATE TABLE customers (
    customer_id INT,
    customer_name VARCHAR(255)
)
PARTITION BY HASH (customer_id);

-- Composite Partitioning (Hash-Range)
CREATE TABLE orders (
    order_id INT,
    customer_id INT,
    order_date DATE,
    amount DECIMAL(10,2)
)
PARTITION BY HASH (customer_id)
SUBPARTITION BY RANGE (order_date) (
    p1 VALUES <= ('2023-01-01'),
    p2 VALUES <= ('2024-01-01'),
    p3 VALUES <= (MAXVALUE)
);
Copy
Código de saída:
Snowflake
 -- Range Partitioning
CREATE OR REPLACE TABLE sales (
    sale_id INT,
    sale_date DATE,
    amount DECIMAL(10, 2)
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "07/16/2025",  "domain": "no-domain-provided" }}'
;

-- Hash Partitioning
CREATE OR REPLACE TABLE customers (
    customer_id INT,
    customer_name VARCHAR(255)
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "07/16/2025",  "domain": "no-domain-provided" }}'
;

-- Composite Partitioning (Hash-Range)
CREATE OR REPLACE TABLE orders (
    order_id INT,
    customer_id INT,
    order_date DATE,
    amount DECIMAL(10,2)
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "07/16/2025",  "domain": "no-domain-provided" }}'
;
Copy

CONSTRAINTS

Descrição

Isso garante a precisão e a confiabilidade dos dados da tabela. Se houver alguma violação entre a restrição e a ação de dados, a ação será abortada. (Referência de linguagem Sybase SQL)

Aviso

Essa sintaxe é parcialmente suportada.

Sintaxe da gramática

 <table-constraint> ::=
    [ CONSTRAINT <constraint-name> ] 
   {  { UNIQUE | PRIMARY KEY } ( <column-name> [ ,  ] )  
     [ IN <dbspace-name> ]
     | <foreign-key-constraint>
     | CHECK ( <condition> )
   }
   
<foreign-key-constraint> ::=
   FOREIGN KEY [ <role-name> ] [ ( <column-name> [ , <column-name> ]  ) ] 
   REFERENCES <table-name> [ ( <column-name> [ , <column-name> ]  ) ]
   [ <actions> ] [ IN <dbspace-name> ]

<actions> ::=
   [ ON { UPDATE | DELETE } RESTRICT ]
Copy

Amostra de padrões da origem

Código de entrada:

Sybase
 CREATE TABLE t_constraint (
    id1 INT NOT NULL,
    id2 INT PRIMARY KEY,
    age INT CHECK (age >= 18),
    email VARCHAR(255) UNIQUE,
    product_id INT REFERENCES products(id) ON DELETE RESTRICT IN SOMEPLACE,
    cod_iq VARCHAR(20) IQ UNIQUE(5),
    CONSTRAINT unq_name_email UNIQUE (name, email),
    CONSTRAINT fk_ord_line FOREIGN KEY (ord_id, line_id) REFERENCES ord_lines(ord_id,line_id)
);
Copy
Código de saída:
Snowflake
 CREATE OR REPLACE TABLE t_constraint (
    id1 INT NOT NULL,
    id2 INT PRIMARY KEY,
    age INT
            !!!RESOLVE EWI!!! /*** SSC-EWI-0035 - CHECK STATEMENT NOT SUPPORTED ***/!!!
            CHECK (age >= 18),
    email VARCHAR(255) UNIQUE,
    product_id INT REFERENCES products (id) ON DELETE RESTRICT ,
    cod_iq VARCHAR(20)
                       !!!RESOLVE EWI!!! /*** SSC-EWI-SY0003 - UNSUPPORTED IQ UNIQUE CONSTRAINT ***/!!!
 IQ UNIQUE(5),
       CONSTRAINT unq_name_email UNIQUE (name, email),
       CONSTRAINT fk_ord_line FOREIGN KEY (ord_id, line_id) REFERENCES ord_lines (ord_id, line_id)
   )
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "03/19/2025",  "domain": "test" }}'
;
Copy

EWIs relacionados

SSC-EWI-0035: CHECK STATEMENT NOT SUPPORTED.

SSC-EWI-SY0003: UNSUPPORTED IQ UNIQUE CONSTRAINT.

DEFAULT

Descrição

Define o valor padrão de uma coluna em uma tabela de criação.

Aviso

Essa sintaxe é parcialmente compatível com o Snowflake.

Sintaxe da gramática

 <default-value> ::=
   <special-value>
   | <string>
   | <global variable>
   | [ - ] <number>
   | ( <constant-expression> )
   | <built-in-function>( <constant-expression> )
   | AUTOINCREMENT
   | CURRENT DATABASE
   | CURRENT REMOTE USER
   | NULL
   | TIMESTAMP
   | LAST USER

<special-value> ::=
   CURRENT 
   { DATE | TIME | TIMESTAMP | USER | PUBLISHER }
   | USER
Copy

Amostra de padrões da origem

Código de entrada:

Sybase
 create table t_defaults
(
col1 timestamp default current utc timestamp,
col2 timestamp default current timestamp,
col3 varchar default current user,
col4 varchar default current remote user,
col5 varchar default last user,
col6 varchar default current publisher,
col7 varchar default current date,
col8 varchar default current database,
col9 varchar default current time,
col10 varchar default user,
col11 int default autoincrement,
col12 int identity,
col13 int default -10, 
col14 int default 'literal', 
col15 int default null
)
;
Copy
Código de saída:
Snowflake
 CREATE OR REPLACE TABLE t_defaults
(
    col1 timestamp default CURRENT_TIMESTAMP,
    col2 timestamp default CURRENT_TIMESTAMP,
    col3 VARCHAR default CURRENT_USER,
    col4 VARCHAR default
                         !!!RESOLVE EWI!!! /*** SSC-EWI-SY0001 - UNSUPPORTED DEFAULT VALUE CURRENT REMOTE USER IN SNOWFLAKE ***/!!! current remote user,
    col5 VARCHAR default
                         !!!RESOLVE EWI!!! /*** SSC-EWI-SY0001 - UNSUPPORTED DEFAULT VALUE LAST USER IN SNOWFLAKE ***/!!! last user,
    col6 VARCHAR default
                         !!!RESOLVE EWI!!! /*** SSC-EWI-SY0001 - UNSUPPORTED DEFAULT VALUE CURRENT PUBLISHER IN SNOWFLAKE ***/!!! current publisher,
    col7 VARCHAR default CURRENT_DATE,
    col8 VARCHAR default CURRENT_DATABASE,
    col9 VARCHAR default CURRENT_TIME,
    col10 VARCHAR DEFAULT CURRENT_USER,
    col11 INT IDENTITY ORDER,
    col12 INT IDENTITY ORDER,
    col13 INT default -10,
    col14 INT default 'literal',
    col15 INT default null
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "sybase",  "convertedOn": "03/19/2025",  "domain": "test" }}'
;
Copy