based on the database that was created in the previous article, we continue to create data tables. T-the syntax for SQL database creation is as follows:CREATE TABLETable name (field name 1 data type constraint, field name 1 data type constraint,...) The first is to create the Learner information table Stuinfo, here are some small details:IDENTITY(Start value, increment) is listed as the identity column, NUMERIC ( -,0) represents a 18-digit number, with a scale of 0. UseStudb--set the current database to StudbGOIF EXISTS(SELECT * fromsysobjectsWHEREName=' Stuinfo ')DROP TABLEStuinfoCREATE TABLEStuinfo/*-Create Student information sheet-*/(StunoCHAR(6) not NULL,--School Number, non-empty (required)StunameVARCHAR( -) not NULL,--name, non-empty (required)StuageINT not NULL,--age, int type defaults to 4 bytesStuid NUMERIC ( -,0),--ID NumberStuseatSMALLINT IDENTITY(1,1),--seat number, auto numberStuaddressTEXT --address, allow null, optional input)GOthen create the Student score table StumarksCREATE TABLEStumarks (ExamnoCHAR(7) not NULL,--Exam NumberStunoCHAR(6) not NULL,--School NumberWrittenexamINT not NULL,--written resultsLabexamINT not NULL --Machine Test Results)GOWhen a stuinfo table exists in the table, how do I resolve the error again? We will certainly think of the same approach to database processing. Where do we go to test it? Oh, check the Name column in the system table sysobjects (object table) of the STUDB database. OK, now our database and the table are all created. We have specified the data type for each field when we are building the table, and have made basic restrictions and distinctions about the types of values that can be inserted. So what are the data types in SQL Server? Let's take a look at the next article.
SQL Server CREATE TABLE