Программирование >>  Руководство по sql 

1 ... 86 87 88 [ 89 ] 90 91 92 ... 105


Создание и удаление объектов базы данных

Объектами базы данных являются индексы, таблицы и курсоры. В следующей таблице сравниваются соответствующие операторы DROP и CREATE. Кроме того, здесь же приводится синтаксис оператора ALTER TABLE. Синтаксис операторов CREATE TABLE приведен в максимально полной форме, синтаксис оператора ALTER TABLE - в несколько сокращенном виде.

Sybase SOL Server

Sybase SOL Anywhere

Microsoft SQL Server

Informix

Oracle

CREATE TABLE table

CREATE 1 GLOBAL TEMPO-RARY] TABLE

CREATE TABLE table

CREATE TABLE table

CREATE TABLE table

table

column datatype

column datatype

column datatype

column datatype

column datatype

[DEFAULT

[NOT NULL] [DEFAULT

[NULL NOT NULL IDEN-TITY [(seed, incre-

[DEFAULT

[DEFAULT (expr)]

{expr 1 user NULL)]

{string 1 number

ment) ]]

(literal 1 NULL CURRENT

[IDENTITY 1 NULL NOT

AUTOINCREMENT CUR-

[DATETIME]

USER 1 TODAY

NULL]

RENT DATE 1 CURRENT

1 SITENAME

OBSERVER)]

CONSTRAINT constraint]

TIME 1 CURRENT TIHESTAMP

[CONSTRAINT constraint]

(NOT NULL]

[[NOT] NULL]

1 NULL 1 USERR) ]

{DEFAULT

{({ UNIQUE i PRIMARY KEY)

[CONSTRAINT constraint]

{expr 1 user NULL)

[USING INDEX

(FOR column]

[PCTFREE int]

{{UNIQUE 1 PRIMARY KEY)

{UNIQUE

[INITRANS int]

[CLUSTERED 1 NONCLUS-TERED]

PRIHERY KEY

1 PRIMERY KEY

{UNIQUE 1 PRIMARY KEY

[MAXTRANS int]

[KIHT {FILLFACTOR

[CLUSTERED 1 NONCLUS-TERED] (column)

1 REFERENCES table [(col-

[TABLESPACE tablespace]

MAX ROWS PER PAGE}=

[ON segment)

umn)]

[STORAGE storage)и

1 CHECK (condition))

1 REFERENCES table [(col-

[ON segment)

REFERENCES table [(col-

[FOREIGN KEY (column)]

[CONSTRAINT constraint]

umn) ]

1 REFERENCES table ((col-

umn) ]

REFERENCES table [(column)]

)...

[ON DELETE CASCADE]

umn))

[ON {UPDATE 1 DELETE

CHECK

1 CHECK (condition)])

{CASCADE 1 SET NULL

NOT FOR REPLICATION]

[EXCEPTIONS INTO table]

DEFAULT 1 RESTRICT)]

expr))

[DISABLE]

1 CHECK (condition)) ]...

CHECK (condition)) ...

]...

[,next column definition

[,next column definition

[next constraint definition

[,next coluiim definition

,next column definition

[next constraint definitio

[,next column definition

]...]...

[next constraint definition]...)...

[ next constraint definition ]...]...

П]...]...

[next constraint definition]...]...

[CONSTRAINT constraint)

{UNIQUE (column [, col-

PRIMARY KEY

[UNIQUE (column [, column

[CONSTRAINT consrtaint]

{{UNIQUE PRIMARY KEY)

umn]...)

[CLUSTERED NONCLUS-TERED J (column [,

l-..)

[ [NOT] NULL]

[CLUSTERED NONCLUS-TERED]

PRIMARY KEY (column [,

column]...)

1 PRIMARY KEY (column [,

{({ UNIQUE 1 PRIMARY KEY)

(column [, column]...)

column]...)

ON segment)

column]...)

[USING INDEX

[WIHT {FILLFACTOR

, CHECK (condition)

UNIQUE [CLUSTERED

1 FOREIGN KEY (column

[PCTFREE int]

MAX ROWS PER PAGE)=

[NOT NULL)

NONCLUSTERED] (column [,

[, column].

.) REFERENCES

[INITRANS int)

FOREIGN KEY [roleJ [(col-

column]...) [ON segment)

table (column [,

(MAXTRANS int]



Sybase SOL Server

Sybase SOL Anywhere

Microsoft SOL Server

Informix

Oracle

(ON segment]

umn (, column]...)] REFER-

[FOREIGN KEY (column , column]...)]

column]...)

[TABLESPACE tablespace]

I FOREIGN KEY (соХшпп

ENCES table [(column [, col-

REFERENCES

CHECK (condition))

STORAGE storage]]]

, column]...) REFERENCES

umn]...)] {0N {UPDATE 1

table [column , column]...]

[CONSTRAINT constraint]

FOREIGN KEY (column [,

table 1(со1ш1т (, col-

DELETE] {CASCADE SET

CHECK

column]) REFERENCES table

umn]...)]

NULL 1 SET DEFAULT

NOT FOR REPLICATION]

(column [, column])

CHECK (condition))

RESTRICT) ]

(expr))

[ON DELETE CASCADE]

]...

CHECK ON COMMIT])] ...

[CHECK (condition))) [EXCEPTIONS INTO table]

IN dbspace]

ON segment)

DISABLE]

(WITH

ON COMMIT DELETE

storage option]

m ROWS PER PAGE =X]

ROWS 1 ON COMMIT PRE-

CLUSTER cluster (column [,

ON segment]

SERVE ROWS]

column]...)]

[INITRANS int]

ALTER TABLE table

ALTER TABLE table

ALTER TABLE table

ALTER TABLE {table syn-

ALTER TABLE table

WITH NOCHECK]

onym)

{ADD column datatype

{ADD column definition

(ADD column definition

{ADD column definition

{[ADD ({column element

DEFAULT default

column constraint ]...

column constraint]...

[column constraint]...

table constraint)

definition]

ADD table-constraint

, next column definition

, next column definition

, { column element 1

identity NULL]

MODIFY column definition

column constraint]...]...

column constraint]...]...

table constraint)]...)]

column constraint ]...

NODIFY column DEFAULT

ADD table constraint

DROP column [, col-

MODIFY (column element [,

, next column definition

default value

, table constraint]...

umn]...

column element]...)]

column constraint ]...]...

MODIFY column [NOT]

DROP CONSTRAINT

HODIFY column

DROP drop]...

ADD table constraint

NULL

constraint [, constraint (...)

{datatype [NOT NULL]

[PCTFREE int]

DROP CONSTRAINT con-

MODIFY column CHECK

DEFAULT de-

(PCTUSED int]

straint

condition)

fault definition

INITRANS int]

REPLACE column DEFAULT

DELETE column

CONSTRAIN

[MAXTRANS int]

new default definition

DELETE CHECK

constraint definition)

[STORAGE storage]

PARTITION)

DELETE UNIQUE (column [,

ADD CONSTRAINT

ALLOCATE EXTENT [([SIZE

column]...)

constraint definition

int [KM]]

DELETE PRIMARY KEY

CONSTRAINT constraint]

DATAFILE file]

DELETE FOREIGN KEY role

DROP CONSTRAINT

INSTANCE int]

RENAME table

constraint)

ENABLE enable

RENAME column TO column)

DISABLE disable]

[NOCACHE 1 CACHE]

[PARALLEL PARALLEL

DEGREE n] [INSTANCES n]]

DROP TABLE table [, ta-

DROP TABLE table

DROP TABLE table [, table]...

DROP TABLE {table syno-

DROP TABLE table

ble]...

nym)

[CASCADE CONSTRAINTS]

CREATE [UNIQUE]

CREATE [UNIQUE]

CREATE [UNIQUE]

CREATE [ UNIQUE DIS-

CREATE [ UNIQUE ]

CLUSTERED

CLUSTERED

TINCT)

INDEX index

NONCLOSTERED]

NONCLUSTERED]

[CLUSTER]

INDEX index

INDEX index

INDEX index

INDEX index



Sybase SQL Server

Sybase SQL Anywhere

Microsoft SQL Server

Informix

Oracle

ON table

(column [, column]...) [WITH

{DEFAULT FILLFACTOR PERCENT 1 MAX ROWS PER PAGE)=x, IGNORE DUP KEY, SORTED DATA, [IGNORE DUP ROW 1 ALLOW DUP ROW)

[ON segment] 1

ON table

(column [ASC 1 DESC]

[, column [ASC 1 DESC]]...)

[IN dbspace]

ON table

(column [, column]...) [WITH

FILLFACTOR -X, IGNORE DUP KEY, {SORTED DATA SORTED DATA REORG), {IGNORE DUP ROW 1 ALLOW DUP ROW) (ON segment] I

ON { table 1 synonym) (column [ASC 1 DESC] 1, column [ASC 1 DESC))...)

ON table

(column [ASC 1 DESC]

[, column [ASC 1 DESC]]...)

[CLUSTER cluster)

INITRANS int]

[MAXTRANS int]

[PCTFREE int]

[STORAGE storage]

[TABLESPACE tablespace]

[NOSORTl

[NOPARALLEL PARALLEL [DEGREE n] [INSTANCES n]] [UNRECOVERABLE RECOVERABLE]

DROP INDEX index [, index]...

DROP INDEX index

DROP INDEX index 1, index)...

DROP INDEX index

DROP INDEX index

CREATE VIEW view

[(column [, column]...)]

AS select subset [WITH CHECK OPTION]

CREATE VIEW view

[(column [, column]...)]

AS select subset [WITH CHECK OPTION]

CREATE VIEW view

[(column [, column]...)] [WITH ENCRYPTION] AS select subset [WITH CHECK OPTION]

CREATE VIEW view

[(column [, column]...)]

AS select subset [WITH CHECK OPTION]

CREATE [OR REPLACE] [FORCE 1 NOFORCE] VIEW view

[(column [, column]...)]

AS select subset [WITH CHECK OPTION [CONSTRAINT constraint]]

DROP VIEW view [, view]...

DROP VIEW view

DROP VIEW view 1, view]...

DROP VIEW view

DROP VIEW view

МАНИПУЛЯЦИИ с ДАННЫМИ

Для манипуляций с данными используются команды SELECT, INSERT и UPDATE.

Sybase SQL Server

Sybase SQL Anywhere

Microsoft SQL Server

Informix

Oracle

SELECT [ALL 1 DISTINCT]

SELECT [ALL DISTINCT)

SELECT [ALL DISTINCT]

SELECT [ALL 1 DISTINCT

SELECT [ALL DISTINCT)

select list

select list

select list

UNIQUE] select list

select list

[INTO new table]

[INTO variable list]

[INTO new table]

[INTO variable list]

[INTO variable list]

FROM [table [alias]

FROM [table [alias]

FROM table [alias]

FROM {table 1 synonym) [ [AS]

FROM [table [alias])

[(INDEX index [PREFETCH

[, table (alias)

(({INDEX = {name id)

alias]

[, table [alias]]...

size] [LRU 1 MRU])]

{CROSS JOIN

NOLOCK 1 HOLDLOCK

[, [OUTER) {table 1 synonym)

[HOLDLOCK 1 NOHOLD-

[NATURAL 1 KEY] JOIN

UPDLOCK 1 TABLOCK

[[AS] alias]...]

LOCK] [SHARED)

[NATURAL KEY] INNER

PAGLOCK 1 TABLOCKX

(.table faliasj

LOIS

FASTFIRSTROW}...)]



1 ... 86 87 88 [ 89 ] 90 91 92 ... 105

© 2006 - 2024 pmbk.ru. Генерация страницы: 0
При копировании материалов приветствуются ссылки.
Яндекс.Метрика