20150504 the creation and deletion of SQL database in tables

Source: Internet
Author: User

I. Creating a database statement

Create DATABASE name
On primary--The default is the primary filegroup, which can be omitted
(
/*--description of the data file--*/
Name= name ' Hq0128_data ',--the logical name of the main data file
Filename= ' d:\ database name. mdf ',--the physical name of the master data file
SIZE=5MB,--Initial size of master data file
MAXSIZE=100MB,--Maximum value of master data file growth
filegrowth=15%--the growth rate of the master data file
)
Log on
(
/*--the specific description of the log file, the meaning of each parameter ibid.--*/
Name= ' database name ',
Filename= ' d:\ database name _log.ldf ',
SIZE=2MB,
Filegrowth=1mb
)

Second, delete the database statement

Use master--set the current database to master for access to the sysdatabases table
Go
if exists (SELECT * from sysdatabases where name= ' database name ')
Drop database name
Go

Iii. Creating a Table statement

Use database name
Go
if exists (SELECT * from sysobjects where name= ' database name ')
DROP table Name
CREATE TABLE Table name
(
SidintIdentity(primary) key,//Set Primary key
sname varchar () NOT NULL,
Xingbiebitnot NULL,
Dianhua varchar (NOT NULL)
)
Go

-Where the column attribute "identity (start value, increment)" means "Sid" is automatically numbered, also known as the identity column

1. Add a data statement to the table

Insert into table name (column name, ...). Values (column value, .....) )

2. Delete data from the table

Delete from table name where conditional expression

3. Modify the data in the table

Update table name set table name = "expression" Where condition expression

4. Query statements

Select (.../* Query for what */) from (.../* from what */) where (.../* what conditions */)

Iv. Deleting a table statement

DROP table Name

20150504 the creation and deletion of SQL database in tables

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.