SQL First Lecture 2

Source: Internet
Author: User

Create a database

Create DATABASE HQ0128
On primary--The default is the primary filegroup, which can be omitted
(
/*--description of the data file--*/
Name= ' Hq0128_data ',--the logical name of the master data file
Filename= ' D:\HQ0128.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= ' HQ0128 ',
Filename= ' D:\HQ0128_log.ldf ',
SIZE=2MB,
Filegrowth=1mb

Deleting a database

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

Create a Table statement

Use HQ0128
Go
if exists (select * from sysobjects where name= ' tb_sinfo ')
drop table Tb_sinfo
CREATE TABLE Tb_sinfo
(
Sidintidentity (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

indentity = self-increment increments from one start to 1 per increase

PRIMARY KEY= PRIMARY key

SQL First Lecture 2

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.