1. Using the T-SQL statement to create the data table authors, enter the following statement.
CREATE TABLE Authors
{
auth_id int PRIMARY key,--data table primary key
Auth_name VARCHAR () not null unique,--author name, cannot be empty
Auth_gender tinyint not NULL DEFAULT (1)--author Sex: male (1), female (0)
};
2. Add a new field with the name Auth_note in the Authors table, the field data type is varchar (100), the null value is allowed, and the input statement is as follows.
ALTER TABLE Authors
ADD auth_note VARCHAR (+) NULL
3. In the authors table, modify the field named Auth_phone, change the data type to varchar (15), and enter the following statement.
ALTER TABLE Authors
ALTER COLUMN Auth_phone VARCHAR (15)
GO
4. Delete the Auth_phone field in the Authors table and enter the following statement.
ALTER TABE Authors
DROP COLUMN Auth_phone
5. Define the table table_emp and set the e_id field in the table as the primary key column, and enter the following statement.
CREATE TABLE Table_emp
(
e_id CHAR (PRIMARY KEY),
E_name VARCHAR (+) not NULL,
E_deptid INT,
E_phone VARCHAR (CONSTRAINT) Uq_phone UNIQUE
);
6. Delete the primary KEY constraints and uniqueness constraints in the member table, and the T-SQL statements are as follows.
ALTER TABLE Member
DROP CONSTRAINT Pk_member,uq_firstname
7. Delete the authors table from the test database and enter the following statement.
Use Test
GO
DROP TABLE Authors
SQL from zero to quick mastery of "basic statement"