The time has passed so fast that the basic enhanced course has been completed and the database course has now started. Database creation: createdatabaseMySchoolonprimary (nameMySchool, fileNameD: ProgramFilesMicrosoftSQLServerMSSQL10.MSSQLSERVERMSSQLDATAMySchool. mdf, size10MB,
The time has passed so fast that the basic enhanced course has been completed and the database course has now started. Database creation: create database MySchool on primary (name = 'myschool ', fileName = 'd: \ Program Files \ Microsoft SQL Server \ MSSQL10.MSSQLSERVER \ MSSQL \ DATA \ MySchool. mdf ', size = 10 MB,
The time passed so fast that the basic Enhancement Course has ended. The Hong Kong server has now started the database course.
Database creation:
Create database MySchool
On primary
(
Name = 'myschool ',
FileName = 'd: \ Program Files \ Microsoft SQL Server \ MSSQL10.MSSQLSERVER \ MSSQL \ DATA \ MySchool. mdf ',
Size = 10 MB,
Filegrowth = 1 MB,
Max size = 100 MB
)
Log on
(
Name = 'myschool _ log ',
FileName = 'd: \ Program Files \ Microsoft SQL Server \ MSSQL10.MSSQLSERVER \ MSSQL \ DATA \ MySchool_log.ldf ',
Size = 3 MB,
Filegrowth = 10%
)
Table creation:
Create table Test (id int identity (1, 1) primary key, name nvarchar (10) not null, age int not null, gender char (2) not null );
Delete table:
Drop table Test;
Insert data:
Insert into Test (name, age, gender) values ('xiao Zhao ', 99, 'female ');
Query data:
Select name from Test where gender = 'male ';
Modify data:
Update Test set age = age + 5 where gender = 'femal ';
Delete data:
Delete from Test where age> 50;
The difference between delete from Test; and truncate table Test;: 1. The truncate statement is very efficient. 2. The truncate statement resets the automatic number in the table to the default value.
The following are the categories and differences of data types:
Category
Remarks and instructions
Type
Description
Binary data type
Store non-Child characters and text data
Image
Used to store images
Text Data Type
Character data includes a combination of any letters, symbols, or numbers
Char, 8000
Non-Unicode character data of a fixed length. A fixed-length string is more efficient than a variable-length string. When the data length is fixed, the fixed-length string is preferred. The Hong Kong server saves the process of calculating the length and improves the efficiency.
Varchar, 8000
Variable-length non-Unicode data
Nchar, 4000
Unicode data of a fixed length
Nvarchar, 4000
Variable-length Unicode data
Text
Varchar (max)
Store long text information (pointer, 2G)
Varchar (max), a large string type can store a lot of characters, but such data DBMS often save them to a separate space, this leads to a slow data storage and loading speed. Therefore, do not use it unless necessary for an American server.
Ntext
Nvarchar (max)
Replace Nvarchar (max)
Date and Time
Enter the date and time in single quotes
Datetime
Date and Time
Digital Data
This data only contains numbers, including positive numbers, negative numbers, and scores.
Int
Smallint
Integer
Float
Real
Number
Currency Data Type
It is used for decimal currency values. The data types of money and smallmoney are precise to one thousandth of the currency units they represent.
Money
Bit Data Type
Indicates yes/no data
Bit
Store boolean data types