How ADO creates a modified delete table

Source: Internet
Author: User
Tags create index expression modify valid

How ADO creates a modified delete table

You can use ASP to create a modified delete table directly in your program

The SQL syntax for the table is as follows:

Creates a table: CREATE TABLE expression.

Modify a table: ALTER TABLE expression.

Deletes a table: drop table expression.

Establish an index: Use the CREATE index or ALTER table expression.

Deletes an index: DROP index expression.

The details are as follows:

CREATE Table Expression

CREATE table expression to create a new table.

The syntax is as follows:

CREATE Table New Table (new Field Name 1 field type [(length)] [not NULL] [index 1] [, new Field Name 2 field type [(length)] [not NULL] [index 2]] [, ...]] [, CONSTRAINT Multifieldindex [, ...]]

Length is character type and character length.

Index 1, index 2 constraint clause defines a single field index.

Multifieldindex defines a multiple field index.

With the CREATE table expression, if you specify not NULL for a field, the new record data content in this field must be a valid data.

The constraint clause can establish different restrictions on a single field and can also be used to establish a primary index.

You can use the CREATE index expression to establish a primary index or multiple indexes on an existing table.

Let's look at an example of using this SQL instruction in an ASP code.

For example, ASP code rs61.asp as follows, [CREATE TABLE trainee (name TEXT (10), age INT)] first set up a student's table, including the 10-bit length TEXT type name field, and the integer type age field.

After execution, when you use Access to open the Ntopsamp.mdb file, you can see the table for the newly created student.

ALTER Table Expression

ALTER TABLE expression to modify a table that has already been established.

The syntax is as follows:

ALTER Table {ADD {COLUMN field Name field type [(length)] [not NULL] [CONSTRAINT index] |

CONSTRAINT Multifieldindex} |

DROP {COLUMN field name I CONSTRAINT multiple field index name}}

Using ALTER TABLE expressions, you can change a table that already exists by taking advantage of a number of different methods:

Use Add column to add fields to the table.

Deletes a field using the Drop column. Just specify the name of the field you want to delete.

Use Add constraint to add new multiple field indexes.

Use drop constraint to delete multiple field indexes. Simply specify the name of the index immediately after the constraint.

When you add a field to a table by using Add column, you must specify the field name, the type of owning, and the type and length.

For example, the following example adds a 2 character length, a character type field named Sex to the student table:

ALTER TABLE student ADD COLUMN sex TEXT (2)

You can also define the index for this field.

If you specify not NULL for a field, the record data that is added in this field must be a valid data.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.