SQL Beginner Tutorial Study (v)

Source: Internet
Author: User
Tags create index

The 1.DEFAULT constraint is used to insert a default value into a column.

CREATE TABLE Orders
(
Id_o int not NULL,
OrderNo int not NULL,
id_p int,
OrderDate date DEFAULT GETDATE ()
)

2. Create a DEFAULT constraint for the "City" column if the table already exists

ALTER TABLE Persons
ALTER COLUMN City SET DEFAULT ' Sandnes '

Revoke

ALTER TABLE Persons
ALTER COLUMN City DROP DEFAULT

3.CREATE INDEX Instance

This session creates a simple index, named "Personindex," in the LastName column of the person table:

If you want to index more than one column, you can list the names of these columns in parentheses, separated by commas:

CREATE INDEX personindexon person (LastName, FirstName)
4. Add a column
ALTER TABLE Personsalter COLUMN Birthday Year

Note that the data type of the "Birthday" column is year, which can hold 2-bit or 4-bit formats .



SQL Beginner Tutorial Study (v)

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.