Database: persistent storage to optimize read and write, to ensure the validity of the data. Relational databases are based on ER model (ie solid - model), use the SQL language to operate.
Database Category: document database, service-oriented database (using mostly) (ie, mobile phones are using sqlite end document database)
Three paradigms: the column can not be split, the unique identifier, the primary key referenced
Relations and storage:
1 to 1
1 to many
Many to many
A 1 B 1 of
Several B 1 A
Several B 1 A
1 1 A to B
1 1 A to B
A 1 B Several
Relationship memory A or B
Relations exist B
New relationships exist Table C
Database file: 1 .mdf master data file (startup database containing information, and store the data) 2. The auxiliary data file i.e. log file .ldf
A database and only one master file
At least one log file
Database is divided into: a user database (user-defined) system databases (5, i.e. master, Model, tempdb, msdb, resource (not shown in the box software))
alter table student
alter column stuname char(10)//要修改的类型
Insert row (data (recording))
use student
insert stuifo values(1,'小红',2)
或
insert into stuifo values(1),('小红'),(2)
Modify the line (Data)
use student
update stuifo set stuid=1,cid=3
where stuname='小红'//条件,当姓名为小红时执行
Delete Row (data)
删除学号为1的数据
delete stuifo
where stuid=1
Empty row (data)
truncate table stuifo(含有外键不可执行)
Database - Data Types
char(n)
varchar(n)
varchar(max)
text
nchar(n)
nvarchar(n)
nvarchar(max)
ntext
bit
binary
varbinary
varbinary(max)
tinyint
smallint
int
bigint
numeric
demical(p,s)
smallmoney
money
float(n)
real
datetime
datetime2
smalldatetime
date
time
datetimeoffset
timestamp
sql_variant
uniqueidentifier
xml
cursor
table
demical (p, s): p is the number of bits, s is a decimal
N represents the data type is unicode encoding, each character occupies one byte, if not non-unicode encoding table n, representing an alphanumeric character, Chinese character occupies two bytes.
Var data type is represented as a variable length, should keep "abc", char (5) stored as "abc (rear two spaces fill bits)", varchar (5) stored as "abc" (no fill bits) .
My public numbers: Germany notes show the public number is used to summarize some study notes. My github blog: Silly Hidekiyo https://oydq.github.io