Use the T_ SQL statement to fill in one or more data records at a time.

Source: Internet
Author: User

Use T_ SQL to create a database TestSchool

Create a student table TblStudent

Create Student Score Table TblScore q tScoreId (score id, primary key, automatic number), tSId (student number), tEnglish (English score), tMath (math score)
Create the instructor table TblTeacher q tTId, tTName, tTGender, tTAge, tTSalary, tTBirthday
Use the T_ SQL statement to enter one data entry at a time or multiple data entries at a time.
(
1) Insert into table (column) select column 1, column 2 union
2) Insert into table (column) select column 1, column 2 from table
3) Select column into new table name from old table
)
Copy codeThe Code is as follows:
Create database TestSchool
On primary
(
Name = 'testschool ',
Filename = 'f: \ SQL Server \ TestSchool. mdf ',
Size = 10 mb,
Filegrowth = 10,
Max size = 100 mb
)
Log on
(
Name = 'testschool _ log ',
Filename = 'f: \ SQL Server \ testschool_log.ldf'
)

Create table TblStudent
(
StudentId int identity (1, 1) primary key,
TScoreId int not null,
SName nvarchar (50) not null,
SAge int not null,
SNo numeric (), -- ID card number, 18 digits, decimal place 0
SEmail varchar (50 ),
SGender bit default (1 ),
SBirthday datetime
)

Select * from TblStudent
Truncate table TblStudent

Insert into TblStudent
Select 1, 'Liu bei ', 20, 123456789012345678, '2017 @ 163.com', 1, '2017-5-6 'union
Select 1, 'guan Yu ', 19,123456789012345671, '1sfdsf3 @ 163.com', 1, '2017-8-6 'union
Select 1, 'zhang fe', 1989, 123456789012345672, '12sfsd3 @ 163.com ', 1, '2017-5-19' union
Select 4, 'caocao', 1985 123456789012345673, '12sf3 @ 163.com ', 1, '2017-12-6' union
Select 4, 'xia houyao ', 1985 123456789012345674, '1ff23 @ 163.com', 1, '2017-3-6 'union
Select 4, 'huawei', 50, 12345678901234565, '12ff3 @ 163.com ', 1, '2017-1-16' union
Select 4, 'ji Ji ', 1989, 12345678901234565, '12f3 @ 163.com', 0, '2017-8-8'

Create table TblScore
(
TScoreId int identity (1, 1) primary key,
StudentId int not null, -- Student id, foreign key
TEnglish float,
TMath float
)

Select * from TblScore
Truncate table TblScore

Insert into TblScore
Select 1, 90, 97 union
Select 2,90, 70 union
Select 100, union
Select 4,100, 80 union
Select 5, 60, 96 union
Select 6, 0, 100 union
Select 7, 80, 60

Create table TblTeacher
(
TTId int identity (1, 1) primary key,
TTName nvarchar (50) not null,
TTGender bit default (1 ),
TTAge int,
TTSalary money,
TTBirthday datetime
)

Select * from TblTeacher

Insert into TblTeacher
Select 'shang bingqi', 10000, 1991, '2017-10-30 'union
Select 'Liu yun', 10000, 1991, '2017-11-06 'union
Select 'yu Dan ', 10000, 1992, '2017-12-30' union
Select 'zhang shaodan', 10000, 1991, '2017-6-6 'union
Select 'wang Jingjing ', 10000, 1991, '2017-6-6' union
Select 'segment linline', 10000, 1991, '2017-6-6 'union
Select 'yang qiaoqiao ', 10000, 1991, '2017-6-6'

Related Article

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.