Joke Collection Website - Bulletin headlines - How does sql sever create a table?
How does sql sever create a table?
First, visual operation.
1. Create a database
Right-click the selected database, select New Database in the dialog box that appears, and then fill in the name of the database in the New dialog box.
Create data table
Right-click a table under the database, and a new table option will appear at the top of the dialog box. The new dialog box has three columns: column name, data type and allowed null values. Here, you can add columns of the table and save Ctrl+S after adding the columns, or click Save above, fill in the name of the table and confirm the creation.
Second, using SQL statements to create
-1. Create a database
Create? Database? stuDB? -stuDB is the name of the database.
Open? Elementary? - ? By default, it belongs to the primary filegroup and can be omitted.
(
/*-Specific description of data file-*/
name='stuDB_data ',? - ? Logical name of the master data file
filename='D:\stuDB_data.mdf ',? - ? The physical path and name of the master data file.
size=5mb,? -Initial size of the main data file
maxsize= 100mb,? - ? Maximum growth of master data file
File growth = 15%- growth rate of main data file.
)
Journal? exist
(
/*-The specific description of the log file, and the meaning of each parameter is the same as above-*/
name='stuDB_log ',
filename='D:\stuDB_log.ldf ',
Size =2mb,
File growth = 1mb
)
-2. Create a data table
Use? StuDB-Use a database (create a table under the database)
Going?
What if? Exist (select? *? From where? sysobjects? Where is it? Name =' stu marks ')- Query whether the table already exists in the database.
Descending? Table? StuMarks-If the table exists, delete it; If it does not exist, don't execute this sentence.
Create? Table? stuMarks? Stumarks is the name of the table.
(
ExamNo? int? Identity (1, 1)? Elementary? Key-Column Name Data Type Constraint
Stuno? char(6)? Isn't it? Null,-Does the column name data type allow the insertion of null values?
writtenExam? int? Isn't it? Empty,
LabExam? int? Isn't it? empty
)
go to
- ? Among them, the column attribute "identity"? Indicates that the "ExamNo" column is automatically numbered. Also known as identity column alter. Table? Table name
Supplement? Constraints? Constraint name? Constraint type? Specific constraint description
Alter? Table? Table name
Descending? Constraints? Constraint name
- Related articles
- Environmental description composition of Laoshan boundary
- Five Characteristics of Outdoor Activities in Kindergarten
- What is the stem of drinking coke in winter?
- 119 Fire Day Special Publicity Program (five selected articles)
- Visit the Memorial Hall of the Victims of the Nanjing Massacre, write a 1,000-word essay for fifth grade
- What does it mean not to travel far unless necessary?
- Want to know the development history of Xingsha, Changsha, Hunan
- What are the names of positions in Japanese companies?
- What are some motivational and fashionable slogans for senior high school students?
- Asian Games Light Show Timetable 223