關於SqlServer資料表操作

JVM的憂傷發表於2018-09-13

–修改表欄位長度
alter table Tbl_Count_User_Ref ALTER COLUMN CountName nvarchar(500);
新增欄位
alter table 表名 add 欄位名 資料型別 default 預設值
說明:資料型別如,varchar(50)
alter table BANK_SOKECT_INFO ADD DEPTNO varchar(8);

如何刪除表中欄位
ALTER table 表名 DROP column 欄位名

substring(fullName,9,100),substring(catalogCode,9,100),substring(parentCode,9,100)
mssql中擷取字串可以用left,right,substring函式。
left,是從字元左邊開始擷取,如:擷取abcdefg字串中的前三個字元:
1 select left(`abcdefg`,3);
其中3為擷取的長度。
rigth是從字元右邊開始擷取,如擷取abcdefg字串中的後三個字元:
1 select right(`abcdefg`,3);
其中3為擷取的長度。
substring,是從任意位置擷取,如擷取abcdefg字串中的第二到第四個字元:
1 select substring(`abcdefg`,2,3);
其中2為開始擷取的位數,3為擷取的長度。

相關文章