CREATE TABLE 表名
(
Column Name Data Type ,
Column Name Data Type ...
)
Use T-SQL language to view the data sheet Properties
SELECT * FROM SYS.TABLES
WHERE NAME='T_STUDENT';
自增列
•CREATE TABLE T_USERS
•(
•ID INT IDENTITY (1000,1),
•NAME NVARCHAR(20)
•);
创建自定义数据类型
CREATE TYPE 数据类型名称
FROM 数据类型 [NOT NULL]
删除自定义数据类型
DROP TYPE 数据类型名称
查看定义
EXEC SP_HELP 对象名称;
SELECT * FROM SYS.TABLES
WHERE NAME=‘对象名称’;
增加列
ALTER TABLE 表名
ADD 列名 数据类型,列名 数据类型
修改列
ALTER TABLE 表名
ALTER COLUMN 列名 数据类型
删除列
ALTER TABLE 表名
DROP COLUMN 列名,列名
删除表
DROP TABLE 表名
EXEC sp_rename 'CountProce','CountProce1'; ------重命名存储过程名; EXEC sp_rename 'fruits.f_name','f_names','COLUMN';--重命名字段名; EXEC sp_rename 'suppliers','supplier'; -----------重命名表名; 参考:https://blog.csdn.net/baidu_32731497/article/details/51523236
Reference: https://blog.csdn.net/lrtcsdn/article/details/84932113
A, char, nchar, nvachar, varchar respective differences
char: fixed length; does not include Chinese; high efficiency index; deposit a letter, also 8 bytes of memory, learning card number
nchar: fixed length, comprising Chinese
nvachar: variable length , there may Chinese
varchar: variable length, preferably with only numbers or English nchar, efficiency is not high char, varchar (10) best buy
Two, date, datetime, smalldatetime distinguishing
date: Only date 2018.12.07
datetime: date + time, 8 bytes, precision 3.33 Example: 9 December 2018 20.55.33;
effective time distant 1753/01 / 01-9999 / 12 is / 31 is
smalldatetime: date + time, 4 bytes, accuracy: minutes