1. First, the table name is users and the primary key is userid. The table creation statement is as follows:
Code:
- Create Database SPDB;
- Create Table users (
- Userid int Primary Key Identity (1, 1 ),
- Username varchar (20 ),
- Passwd varchar (20 ),
- Email varchar (30 ),
- Grade INT );
2. Insert some data into the table:
Code:
- Insert into users values ('admin', 'admin', 'admin @ sohu.com ', 1)
- Insert into users values ('shunping', 'shunping', 'shunping @ sohu.com ', 1)
- Insert into users values ('tester1', 'tester1', 'tester1 @ sohu.com ', 5)
- Insert into users values ('tester2', 'tester2', 'tester2 @ sohu.com ', 5)
- Insert into users values ('tester3', 'tester3', 'tester3 @ sohu.com ', 1)
- Insert into users values ('tester4', 'tester4', 'tester4 @ sohu.com ', 6)
- Insert into users values ('tester5', 'tester5', 'tester5 @ sohu.com ', 2)
- Insert into users values ('tester6', 'tester6', 'tester6 @ sohu.com ', 1)
- Insert into users values ('tester7', 'tester7', 'tester7 @ sohu.com ', 2)
3. The following are key statements for quickly adding records:
Code:
- Insert into users (username, passwd, email, grade) Select username, passwd, email, grade from users;
4. The primary key of the table is userid and auto-incrementing.