Contacts

Alter Table operator syntax. MYSQL ALTER TABLE reference guide to add and delete column, default values

ALTER TABLE TBL_NAME ALTER_SPEC [, ALTER_SPEC ...]

aLTER_SPECIFICATION:

Add Create_Definition

or Add (Create_Definition, Create_Definition, ...)

or Add index (index_col_name, ...)

or Add Primary Key (index_col_name, ...)

or Add Unique (index_col_name, ...)

or Add Fulltext (index_col_name, ...)

or Add Foreign Key Index_Name (index_col_name, ...)

or alter col_name (Set Default Literal | Drop Default)

or Change Old_col_Name Create_Definition

or Modify Create_Definition

or drop col_name

or Drop Primary Key

or drop index index_name

or disable keys

or Enable Keys.

or rename new_tbl_name

or order by col

or Table_Options.

The ALTER TABLE statement is the ability to change the structure of the existing table. For example, you can add or delete columns, create or destroy indexes or rename columns or a table itself. You can also change the comment for the table and its type.

Alter Table operator Work time creates a temporary copy of the source table. The required change is performed on the copy, then the source table is deleted, and the new is renamed. This is done so that all updates have automatically fall into the new table, besides failed. During the fulfillmentalTer table value table is available for reading other customers. Update and write operations in this table are suspended until the new table is ready.

It should be noted that when using any other option for ALTER TABLE, otherwise, MySQL will always create a temporary table, even if the data, strictly speaking, do not need to be copied (for example, when changing the column name). For tablesMyisa, it can increase the rate of reconstruction of the index part (which is the slowest part in the process of restoring the table) by setting the variableMyisam_Sort_Buffer_SIZEn_Siza.

To use the Alter Table operator, privilegealter, insert and accounts of this table.

The IGNoore is an extension of MySQL with respect to ANSI SQL92. It manages the workAlter table full of duplicates of unique keys in the new table. If the value is specified, the process is interrupted for this copy and roll back. If it is noted, then for rows with duplicate unique keys, only the first line is used, and the rest are removed.

You can run multiple ADD, ALTER expressions, DropOchange in one commandal Table. This is an extension of MySQL with respect to ANSI SQL92, where only one expression from those mentioned in one commandal Table is allowed.

Change col_name options, Drop Col_namedrop Indext are MYSQL extensions with respect to ANSI SQL92.

The MODIFY option is an Oracle extension for the CALTER TABLE command.

The optional word column is "" white noise "" and can be omitted.

When using ALTER TABLE_Table name Rename to New_MimaBese any other MYSQL options simply renamed files corresponding to the specified table. In this case, there is no need to create a temporary table. In terms ofCreate_DefinitionDeaddDeck hosts the same syntax as forcreate table. It should be borne in mind that this syntax includes the name of the column, and not just its type.

A column can be renamed using the Change_Definition_definition_Definition_Definition_Definition_ To do this, you need to specify the old and new names of the column and its type at present. For example, to rename the BACKNTEGERIZAB, you can do the following:

mySQL\u003e ALTER TABLE T1 CHANGE A B Integer;

When changing the type of column, but not its name syntax expression changes, it requires the indication of both column names, even if they are the same. For example:

mYSQL\u003e ALTER TABLE T1 CHANGE B B B BIGINT NOT NULL;

However, starting with the version of MySQL 3.22.16A, you can also use the expression of modifying the column type changes without renaming it:

mysql\u003e alter table t1 modify b bigint not null;

When using changedifying to reduce the length of the column, in part of which an index was built (for example, an index on the first 10 column symbols), it is impossible to make a column in short than the number of indexed characters.

When you change the type of column using ChangeliModifyMysql, trying to convert data to a new type as correct as possible.

In the version of MySQL 3.22 and later, you can use FIRSTILDDD ... AfterTer_name_stolemadded the column to the specified position within the table row. By default, the column is added at the end. Starting with the version of MySQL 4.0.1, you can also use keywordsFirstIFY options.

The alter column option is a new default value for the column or deletes the old one. If the old value is deleted by default and this column can be valued value, then the new default value will be. If the column can not be, then MySQL assigns the default value. TheDrop Index Option Index. This is the expansion of MySQL with respect to ANSI SQL92. If the columns are removed from the table, these columns are also deleted from any index to which they enter as part. If all columns constituting the index are deleted, this index is also deleted.

If the table contains only one column, this column cannot be deleted. Instead, you can delete this table using the Drop Table command.

The Drop Primary option Key descends the primary index. If this index does not exist in this table, the first indexynique is deleted by this table. (MySQL marks the first unique key to the primary keyPrimary Key, if no other primary keyPrimary Keyne is explicitly specified). When adding IndexIliPrimary Key in the table, they are stored before the rest of the unreasonable keys so that the duplicate keys can be determined as early as possible.

Option ORDER Bypaces creating a new table with rows placed in a given order. It should be borne in mind that the created table will not save this order of strings after insertion and removal operations. In some cases, such an opportunity can facilitate the sorting operation in MySQL if the table has such an arrangement of columns that you would like to be in the future. This option is mainly useful if a certain order is known in advance, in which the strings will mostly be requested. The use of this option after a significant table conversion makes it possible to get higher performance.

When using the ALTER TABLED commands, the TablesMyisAmSe will be refused indexes in a separate package (similar torepair). Thanks to this team, TABLEFERS The presence of several indexes will work faster.

Starting with MySQL 4.0, the above opportunity can be explicitly activated. The Alter Table Team ... Disable Keys locks in MySQL updates of unnotic indexes for tablemyisam. After that, you can apply the commandal Table ... Enable keys for recreation of missing indexes. Since MySQL does this using a special algorithm that is much faster in comparison with the keys insert one by one, key locking can give a significant acceleration on large inserts arrays.

Using the mysql_info () API function, you can determine how many records were copied, as well as (when using the value) - how many records were removed due to duplication of the values \u200b\u200bof unique keys.

Expressions Foreign Key, CheckIreferences are not doing anything. They are entered only for compatibility considerations to facilitate the transfer of code from other SQL servers and launch applications that create tables with references.

Below are examples showing some cases of alter table commands. The example begins with tablet1, which is as follows:

mYSQL\u003e CREATE TABLE T1 (A INTEGER, B CHAR (10));

In order to rename the table from T1BT2:

mySQL\u003e ALTER TABLE T1 RENAME T2;

To change the type of column with IntegeranNyint NOT NULL (leaving the name of the previous one) and change the type of columnBSchar (10) by ochar (20) with renaming it CBNC:

mySQL\u003e Alter Table T2 Modify A Tinyint Not Null, Change B C Char (20);

To add a new TimeStamps column named:

mySQL\u003e ALTER TABLE T2 Add D TimeStamp;

To add an index to the DI column to make column primary key:

mYSQL\u003e ALTER TABLE T2 Add Index (D), Add Primary Key (A);

To remove column C:

mySQL\u003e Alter Table T2 Drop Column C;

To add a new numeric column AUTO_INCREMENTS named:

mySQL\u003e ALTER TABLE T2 Add C int unsigned not null auto_increment

Note that the column is sindexed, since columnsAuto_increment must be indexed; In addition, the column is subject to NOT NULL, since indexed columns cannot beNULL.

When you add the AUTO_INCREMENT assessment column, this column is automatically filled with sequential numbers (when adding records). The first sequence number can be set by executing the SET INSERT_ID \u003d # command to use the usatO_INCREMENT TOTAL \u003d #.

ALTER TABLE TBL_NAME ALTER_SPEC [, ALTER_SPEC ...] ALTER_SPECIFICATION: Add Create_Definition or Add (Create_Definition, Create_Definition, ...) or Add Index (index_col_name, ...) or Add Primary Key (index_col_name, ...) or Add Unique (index_col_name, ...) or ADD FULLTEXT (index_col_name, ...) or ADD FOREIGN KEY index_name (index_col_name, ...) or ALTER col_name (SET DEFAULT literal | DROP DEFAULT) or CHANGE old_col_name create_definition or MODIFY create_definition or DROP col_name Or Drop Primary Key or Drop Index Index_Name or Disable Keys or Enable Keys or Rename New_tbl_name or Order by Col or Table_Options

The Alter Table operator provides the ability to change the structure of the existing table. For example, you can add or delete columns, create or destroy indexes or rename columns or a table itself. You can also change the comment for the table and its type. See Section.

If the ALTER TABLE statement is used to change the column type definition, but Describe TBL_NAME shows that the column has not changed, then mysql ignores this modification according to one of the reasons described in Section 6.5.3.1 section of the silent changes in column definitions. For example, when trying to change the Varchar column on Char MySQL will continue to use VARCHAR if this table contains other columns with variable length.

The ALTER TABLE statement during operation creates a temporary copy of the source table. The required change is performed on the copy, then the source table is deleted, and the new is renamed. This is done so that all updates have automatically fall into the new table besides failed. During the implementation of ALTER TABLE, the source table is available for reading other customers. Update and write operations in this table are suspended until the new table is ready.

It should be noted that when using any other option for Alter Table, in addition to Rename, MySQL will always create a temporary table, even if data, strictly speaking, do not need to be copied (for example, when changing the column name). We plan to fix it in the future, however, since alter table is not doing so often, we (MYSQL developers) do not consider this task priority. For MyISAM tables, you can increase the rate of recreation of the index part (which is the slowest part in the process of restoring the table) by setting the variable myisam_sort_buffer_size is quite large.

  • To use the ALTER TABLE operator, Alter, Insert and Create privileges are required for this table.
  • The IGNore option is the expansion of MySQL with respect to ANSI SQL92. It manages the work of Alter Table if there are duplicate unique keys in the new table. If the IGNore option is not specified, the process is interrupted for this copy and roll back. If Ignore is specified, then for rows with duplicate unique keys, only the first line is used, and the rest are deleted.
  • You can run several ADD, Alter, Drop and Change expressions in one alter table command. This is an extension of MySQL with respect to ANSI SQL92, where only one expression from the Alter Table mentioned in one command is allowed.
  • Change col_name options, Drop col_name and Drop Index are also MYSQL extensions relative to ANSI SQL92.
  • The MODIFY option is an Oracle extension for the alter table command.
  • The optional word column is `` white noise "" and can be omitted.
  • When using ALTER TABLE name_Table rename to new_mes, without any other MYSQL options, simply renames files corresponding to the specified table. In this case, there is no need to create a temporary table. See Section 6.5.5 Syntax Operator Rename Tabl E.
  • In the create_definition expression, the same syntax is used for Add and Change as for Create Table. It should be borne in mind that this syntax includes the name of the column, and not just its type. See Section 6.5.3 CREATE TABLE Operator Syntax.
  • A column can be renamed using the Change_Definition_definition_Definition_Definition_Definition_name. To do this, you need to specify the old and new names of the column and its type at present. For example, to rename the Integer column from A in B, you can do the following: MySQL\u003e ALTER TABLE T1 CHANGE A B Integer; When a column type is changed, but not its name, the syntax of the Change expression still requires the indication of both column names, even if they are the same. For example: MySQL\u003e ALTER TABLE T1 CHANGE B B BIGINT NOT NULL; However, starting with the version of MySQL 3.22.16A, you can also use the modify expression to change the type of column without renaming it: mysql\u003e alter table t1 modify b bigint not null;
  • When using Change or Modify in order to reduce the column length, the part of which the index is built (for example, the index on the first 10 characters of the VARCHAR column) cannot be made shorter than the number of indexed characters.
  • When you change the type of column using Change or Modify MySQL, trying to convert data to a new type as correct as possible.
  • In the version of MySQL 3.22 and later, you can use the first or add ... after the name_stolbet name to add a column to a specified position within a tabular string. By default, the column is added at the end. Starting with the version of MySQL 4.0.1, you can also use the FIRST and AfterTER keywords in the Change or Modify options.
  • The Alter Column option specifies the default value for the column or deletes the old one. If the old value is deleted by default and this column can take NULL value, the new default value will be NULL. If the column can not be NULL, then MySQL assigns the default value as described in Section 6.5.3 Create Table Operator Syntax.
  • The Drop Index option deletes the index. This is the expansion of MySQL with respect to ANSI SQL92. See Section 6.5.8 The syntax of the DROP INDEX operator.
  • If the columns are removed from the table, these columns are also deleted from any index to which they enter as part. If all columns constituting the index are deleted, this index is also deleted.
  • If the table contains only one column, this column cannot be deleted. Instead, you can delete this table using the Drop Table command.
  • The Drop Primary Key option deletes the primary index. If this index does not exist in this table, the first UNIQUE index is deleted in this table. (MySQL notes the first unique key of Unique as the primary key Primary Key, if no other primary primary key key was explicitly specified). When adding Unique Index or Primary Key to the table, they are stored in front of the rest of the unreasonable keys so that the duplicate keys can be determined as early as possible.
  • Option ORDER BY allows you to create a new table with rows placed in a given order. It should be borne in mind that the created table will not save this order of strings after insertion and removal operations. In some cases, such an opportunity can facilitate the sorting operation in MySQL if the table has such an arrangement of columns that you would like to be in the future. This option is mainly useful if a certain order is known in advance, in which the strings will mostly be requested. The use of this option after a significant table conversion makes it possible to get higher performance.
  • When using the ALTER TABLE command for MyISAM tables, all non-unique indexes are created in a separate package (like Repair). Thanks to this, the ALTER TABLE command in the presence of multiple indexes will work faster.
  • Starting with MySQL 4.0, the above opportunity can be explicitly activated. The ALTER Table Team ... Disable Keys blocks updating unnotic indexes in MySQL for Myisam tables. After that, you can apply the Alter Table ... Enable Keys command to recreate missing indexes. Since MySQL does this using a special algorithm that is much faster in comparison with the keys insert one by one, key locking can give a significant acceleration on large inserts arrays.
  • By using the MysQL_INFO () API function, you can determine how many records were copied, as well as (when using Ignore) - how many records were removed due to duplication of the values \u200b\u200bof unique keys.
  • Foreign Key, Check and References actually do nothing. They are entered only for compatibility considerations to facilitate the transfer of code from other SQL servers and launch applications that create tables with references. See Section 1.9.4 Differences MySQL from ANSI SQL92.

Below are examples showing some cases of alter table commands. The example begins with T1 Table, which is as follows:

MYSQL\u003e CREATE TABLE T1 (A INTEGER, B CHAR (10));

In order to rename the table from T1 in T2:

MySQL\u003e ALTER TABLE T1 RENAME T2;

To change the type of column with Integer on the Tinyint Not Null (leaving the name of the previous one) and change the type B column with CHAR (10) on CHAR (20) with renaming it with B on C:

MySQL\u003e Alter Table T2 Modify A Tinyint Not Null, Change B C Char (20);

To add a new TimeStamp column named D:

MySQL\u003e ALTER TABLE T2 Add D TimeStamp;

To add an index to the D column and make a column A primary key:

MYSQL\u003e ALTER TABLE T2 Add Index (D), Add Primary Key (A);

To remove column C:

MySQL\u003e Alter Table T2 Drop Column C;

To add a new numeric column AUTO_INCREMENT named C:

Mysql\u003e alter table t2 add c int unsigned not null auto_increment, add index (C);

Note that the C column is indexed, since the AUTO_INCRement columns must be indexed, in addition, the C column is declared as Not NULL, since indexed columns cannot be NULL.

When the AUTO_INCRement column is added, the values \u200b\u200bof this column are automatically filled with serial numbers (when adding records). The first sequence number can be set by executing the set insert_id \u003d # command to alter table or using the Auto_INCRement Table Options \u003d #. See Section 5.5.6 SET command syntax.

If the AUTO_INCREMENT column for MyISAM tables does not change, the sequence number remains the same. When you delete the AUTO_INCREMENT column and the subsequent addition of another AUTO_INCREMENT column will begin again from 1.

We will look at this lesson SQL how to use the command alter command to the table in the database. The ALTER command is mainly used to add, change and delete columns, to indexes and restrictions on tables in a relational database, such as in, Oracle, Sybase and SQL Server. Although Alter is not part of the CRUD classical operation, this is one of the important DDL commands. One of the most frequent use of the ALTER command in SQL is to add and remove indexes to improve the performance of SQL Select requests. In this tutorial, we will see various ways to use the alter team. Using the ALTER command, you can add, edit or change tables, views to databases. We can add a new column in the table, we can change the value of the column or we can rename the column.

10 examples of the alter command in SQL

Let's see some of the most commonly used examples of the alter command in SQL. In this section, we will look at how to use the ALTER command to add, modify and delete existing columns in the table.

Example 1: How to add a column to an existing table using Alter in SQL:

Suppose we have one table with the name of the student with the field Roll_Number, Stu_Name, Class, Subject, and we want to add another column of Marks-Obtained, how to do with teamsAlter.

ALTER TABLE STUDENT ADD MARKS_OBTAINED NUMBER (3);

When this field is added to the table, it will contain the default zero value.

Example 2: How to change an existing column using the alter command in SQL :

Suppose now we want to change the above-added Mark_obtained field from the number to the decimal type of data, we can use the column changes along with Alter with a team.

ALTER TABLE STUDENT ALTER COLUMN MARKS_OBTAINED DECIMAL (5, 2);

Example 3: How to delete an existing column from the table using the alter command in SQL:

Now, if we want to delete an existing column from the table, we use DROP along with the alter team

ALTER TABLE STUDENT DROP COLUMN MARKS_OBTAINED;

Example 4. How to delete the primary key using the ALTER command in the database :

Suppose There is a primary key named 'PK_ROLL_NUM' for the roll_number column from the Student table, and we want to give up this limit

ALTER TABLE STUDENT DROP CONSTRAINT "PK_ROLL_NUM ';

Example 5. How to add primary key restrictions using the alter command in SQL:

Now we want to add a primary key restriction in the Student Table called 'PK_ROLL_NUM' for the Roll_Number 'column. We do this

ALTER TABLE STUDENT ADD CONSTRAINT "PK_ROLL_NUM PRIMARY KEY (ROLL_NUMBER)

Example 6. How to reset the external key restriction using the alter command:

Suppose that there is an external key limitation named 'FK_ROLL_NUM' for the Roll_Number 'column from the' MARKS 'table, and we want to refuse this limit

ALTER TABLE MARKS DROP CONSTRAINT "FK_ROLL_NUM ';

Example 7: How to add an external key limit using the alter command

Now we want to add an external key restriction to the MARKS table, called 'fk_roll_num' for the roll_number column. We will do this:

ALTER TABLE MARKS ADD CONSTRAINT "FK_ROLL_NUM FOREIGN KEY (ROLL_NUMBER) REFERENCES STUDENTS (ROLL_NUMBER);

Example 8: How to add unique key restrictions using the alter command

Now, if we want to add unique The restriction key in the Student table called 'Unique_ROLL_NO' for the Roll_Number column. We will do this:

ALTER TABLE STUDENT ADD CONSTRAINT UNIQUE_ROLL_NO UNIQUE (ROLL_NUMBER);

Example 9. : How to delete a unique Constrant key using the alter command

Now, if we want to abandon a unique restriction key in the Student Table called 'Unique_roll_no' for the Roll_Number column. We will do this:

ALTER TABLE STUDENT DROP CONSTRAINT UNIQUE_ROLL_NO);

Example 10: How to add a CNCC using the alter command in SQL

The main syntax for adding a check limit in the table:

Alter Table Table_name Add Constraint MyuniqueConstraint Check (Condition);

This is all about the examples of the alter command in SQL. We have seen 10 different ways to use alter command in SQL. Alter is one of the most important during operation in any database, for example, MySQL, Oracle or SQL Server, especially from the command line. Since we often need to add, change and delete columns, indexes and restrictions in the table.

The following levels of verification restrictions can be distinguished:

  • attribute level (column),
  • country level (string),
  • relationship level (table).

In restriction of the column level, the value of only one separate column is checked, in other words, in the restriction of this type there is a reference only to one column of the table, in the definition of which this restriction contains. To bring an example of such a restriction, back to the Computer Firm scheme. In the Product table in the Type column, one of three values \u200b\u200bmay be located. We can prohibit the entry of any other information in this column using such a restriction:

    Check (Type In ("Printer", "PC", "Laptop"))

Let's make a departure to get acquainted with the alter table operator, which will allow us to change the structure of the table, without re-exciting it every time again. It is even more important that the change in the structure may be required when the table already contains data.

Using the Alter Table operator, you can add or delete columns, default values, as well as limitations.

At the moment we are interested in adding a limit on the Type column, so first we first give the operator syntax to add limitations:

    Alter table

    Add Constraint;

Let's now add our restriction and check how it works.

    Alter Table Product

    Add Constraint CHK_TYPE CHECK (Type In ("PC", "Laptop", "Printer"));

To make sure that the restriction works as we expect, let's try to add a new type model:

    INSERT INTO PRODUCT VALUES ("A", 1122, "NOTEBOOK");

As expected, in response, we will receive an error message:

The Insert Statement Constraint "chk_type". The Conflict OccurRed in Database "Learn", Table "dbo.Product", Column "Type". The Statement Has Been Terminated.

(Conflict Insert Instructions with Check "CHK_TYPE". The conflict occurred in the "Learn" database, the "dbo.Product" table, the "Type" table. The execution of this instruction was interrupted.)

How easy it is to guess, limit the level level contains links to several columns. In this case, the restriction is checked for each row variable separately. The string can be added (or changed) if the restriction is not impaired.

As an example, let's forbid the Z manufacturer to release anything besides printers.

    Alter Table Product

    Add Constraint CHK_MAKER_Z CHECK ((Maker \u003d "Z" and Type \u003d "Printer") OR Maker "Z");

So, the restriction checks that the model in the product table must be a printer of the manufacturer Z (Maker \u003d "Z" and Type \u003d "Printer") or any other manufacturer (but not z).

If we try to add a PC model of the Z manufacturer,

Manipulating tables is one of the most common activities that administrators databases and programmers are carried out when working with base objects. This section describes in detail how to create and modify tables.

The ANSI standard is something like the smallest common denominator for all manufacturers, although not every feature of the standard version of the CREATE Table and Alter Table instructions is implemented by each manufacturer. Nevertheless, the ANSI standard is a basic form that can be used on all platforms.

In turn, the platforms offer a variety of extensions and additions to the instructions of the Create Table and Alter Table ANSI Standard.

As a rule, you need to think about the project project and the way to create it. This process is called database design. The process of analyzing the relationship of the table with its own data and other tables in the database is called normalization. We recommend programmers and database administrators to learn the principles of design and normalization before using the Create Database commands.

SQL 2003 syntax

When executing the CREATE TABLE instruction, the SQL 2003 standard in the database creates a constant or temporary table. The syntax is next.

CREATE [(Local Temporary) Global Temporary)] Table Name_Tablique (Name Longbits Type_data Attributes [, ...]) | [Walker Name with Options Options] | | (System Generated | User Generated | Derived)] [, ...]] [Definition_Table]] Name_Table Type_Dan Attributes] | SET DEFAULT_NAME NAME CALL_PO_UMOLITE] | Drop DEFAULT_name] | Quality Name Add Scope Name_Table | Drop Scope_name (restrict | Cascade)] | RESTRICT NAME (RESTRICT | CASCADE)] | |

Keywords

Temporary.

Announced a constant or temporary (Temporary) table from the local (LOCAL) or global (Global) area of \u200b\u200baction. Local temporary tables are available only from the session created them, and they are automatically deleted when the session created them is completed. Global temporary tables are available from all active sessions, but they are automatically deleted when the session created them. Do not specify temporary table names with the schema name.

(Name of Longbits Type_data Attributes [,])

A list in which one or more columns are listed through the comma, their data types and additional attributes, such as the values \u200b\u200bof NULL (NULLABILITY) values. Each table declaration should include at least one column for which you can specify:

nameStolbitsa

The name of the column is indicated. It should be an identifier allowed from the point of view of the rules of a specific SURBD. The name must be meaningful!

type_data

Binds a column with a name_name name. A specific data type. For those data types that allow you to specify their length, there is an additional parameter length, for example VARCHAR (255). The data type must be permissible in SURBD. For a complete description of the permissible data types and their options for specific manufacturers, contact Chapter 2. Attributes

Signs the specified restriction attributes with the column. For one column named, the name_name, you can specify several attributes. Commas are not required. The typical ANSI attributes include the following.

NOT NULL

The NULL values \u200b\u200bare prohibited in the column (or allowed if the NOT NULL offer is omitted). Any Insert and Update instructions that will try to place the NULL value to the column with the NOT NULL attribute will not be performed, and rollback will occur.

Default Expression

The column will use the value of the expression if the Insert or Update instruction does not enter any value. The expression must be permissible for the data type of the column; For example, in the Integer type column, no letter symbols cannot be used. An expression may be a string or numeric literal, but you can also specify a custom or system function. The SQL 2003 standard allows you to use the following system functions in the default offer: NULL, User, CurrentJSER, Session_user, Systemjjser, Current_Path, Current_D and those, CurrentJime, Localtime, CurrentJimeStamp, Localtjmestamp, Array or Array.

Collate_name_name

The collation used is determined, that is, the sorting order in the corresponding column. The name of the comparison depends on the platform. If the matching name is not defined, the default mapping of the character set to be used in the column is accepted. References Are Checked Parameter Determines whether references will be checked in the REF column defined with the action area option (SCOPE). An additional offer on Delete determines whether the values \u200b\u200bwill be in the records referenced by the remote entry, to be installed in NULL or a restriction will be imposed on the operation.

Constraint Limit Name [Type Reference [Restriction]]

The parameter assigns a restriction column and if you wish the name of the restriction. Types of restrictions are discussed in chapter 2. Since the restriction is associated with a specific column, in the declaration of restrictions it is assumed that this column in this restriction will be the only one. After the table is created, the restriction will be considered to limit the table level.

nameStolbitsa

The column is determined with special options such as the action area option (Scope), the default value option (default), limiting the column level or the Collate offer. In many implementations, the WITH OPTIONS proposal is limited to the creation of object (typed) tables.

Like name_Table

The new table is created with the same column definitions as in the existing table name_Table.

Refis System: System Generated | User Generated Derived]

The object identifier column (OBJECT Identifier, OID) in object (typed) tables is determined. The object identifier is necessary for a table that is the root in the hierarchy of the tables. In accordance with this parameter, the REF column can be generated by the system automatically (System Generated), manually specify the user when entering the string (User Generated) or to be created based on another Ref column. The parameter requires to turn on the_strol_name column. References attribute.

Constraint Limit Type [Limit Name] [, ...]

The table is assigned one or more restrictions. This parameter is noticeably different from the limitations of the column level, since it is assumed that the limitations of the column level apply only to the column with which they are connected. In the case of restrictions of the table level, there is a possibility to connect with a restriction of several columns. For example, in the Sales Table you may need to declare a unique restriction on the store_id clutch key, order_id and order_date. This can be done only by limiting the table level. For a detailed discussion of restrictions, refer to chapter 2.

Of Name [Definition_Table]

It is announced that the table is based on the finished user type. In this situation, the table can have only one column for each attribute of the structured type plus an additional column defined in the REF IS proposal. The Ref data type is described in detail in the section "CREATE / ALTER TURE" section. This proposal is incompatible with the Like proposition name. Where:

Under SuperTeck [Definition / Table]

An immediate supertable is declared for the current table in the same scheme (if exists). If you wish, you can specify a complete definition_table for the supertable, filling it with columns, restrictions, and the like.

ON COMMIT (PRESERVE ROWS DELETE ROWS]

ON COMMIT PRESERVE ROWS SETs a temporary table data strings when executing the COMMIT instruction. The ON COMMIT DELETE RO WS offer removes all lines of data in the temporary table when executing the COMMIT instruction.

Add name_stolbet type_data attributes

A column with an appropriate data type and attributes is added to the table.

Alter_stolbet_name Set Default Value

The default value is added to the column (if it does not exist) or varies with the existing value.

Alter Drop Default_stolb

The default value is completely removed from the specified column.

Alter_stolbet name add scope name_Table

The specified column adds an area of \u200b\u200baction (SCOPE). The scope is a link to the user data type.

Alter Drop Scope Drop Scope

The scope is removed from the specified column. RESTRICT and CASCADE offers are explained at the end of this list.

DROP COLUMN_stolbet name

The specified column is removed from the table. RESTRICT and CASCADE offers are explained at the end of this list.

Add Tabular_Camination

The table adds a restriction with the specified name and characteristics.

DROP CONSTRAINT Limit Name

The existing limit is removed from the table.

RESTRICT.

When you specify this proposal, SURBD cancels the command if objects depending on this object are in the database.

When you specify this proposal, SURBD removes all other objects depending on this object.



Did you like the article? Share it