建立數據庫表,進行增刪改查是咱們操做數據庫的最基礎的操做,很簡單,熟悉的請關閉,省得讓費時間。sql
一、建立表:數據庫
sql中建立數值類型字段要根據該字段值的增加狀況選擇類型:ide
tinyint 佔1個字節,長度爲 0-255spa
smallint 佔2個字節,長度爲 2^15 (-32,768) 到 2^15-1 (32,767)code
int 佔4個字節,長度爲 -2^31 (-2,147,483,648) 到 2^31-1 (2,147,483,647)blog
bigint 佔8個字節,長度爲 -2^63 (-9,223,372,036,854,775,808) 到 2^63-1 (9,223,372,036,854,775,807)it
Create Table Student( Id tinyint primary key identity(1,1), Name nvarchar(20), Age int )
二、用SQL爲表添加一列table
Alter table Student add Class nvarchar(20) go
三、修改SQL現有列的類型,好比從nvarchar改爲varcharclass
Alter table Student Alter column Name char(20) go
四、用sql語句刪除一列基礎
Alter table student Drop column class go
五、SQL Insert
Insert into Student(Name,Age) values('張三',18) Insert into Student(Name,Age) values('李四',17) Insert into Student(Name,Age) values('王五',17)
六、Sql 更新一條數據
Update Student set Age=19 where Id=1
七、刪除一條數據
八、清空數據表:
truncate table Student
九、刪除數據表
drop table Student
這些都是最基礎最基礎的操做,一個表的建立,增刪改查,清空,刪除數據,刪除表。
但願對看到你有些幫助。
歡迎拍磚!