ภาษา sql เพิ่มคอลัมน์
ALTER TABLE Customers
ADD Email varchar(255);
ภาษา sql เปลี่ยนคอลัมน์ประเภท
ALTER TABLE table_name
ALTER COLUMN column_name datatype;
-- Example
ALTER TABLE product
ALTER COLUMN description VARCHAR(250);
ภาษา sql เซิร์ฟเวอร์เปลี่ยนแปลงคอลัมน์
ALTER TABLE table_name
ALTER COLUMN column_name new_data_type(size);
ภาษา sql เปลี่ยนแปลงคอลัมน์
Changes the data type of a table’s column.
Example: In the ‘users’ table, make the column ‘incept_date’ into a
‘datetime’ type.
ALTER TABLE users
ALTER COLUMN incept_date datetime;
ภาษา sql เปลี่ยนแปลงบนโต๊ะ
-- With check if field already exists
IF NOT EXISTS(SELECT 1 FROM sys.columns
WHERE Name = N'Email'
AND Object_ID = Object_ID(N'dbo.Customers'))
BEGIN
ALTER TABLE Customers
ADD Email varchar(255);
END
เปลี่ยนแปลงคอลัมน์ภาษา sql เซิร์ฟเวอร์
ALTER TABLE table_name
ALTER COLUMN column_name datatype;