Quickly add table records using SQL statements

Source: Internet
Author: User

 

1. First, the table name is users and the primary key is userid. The table creation statement is as follows:

Code:
  1. Create Database SPDB;
  2. Create Table users (
  3. Userid int Primary Key Identity (1, 1 ),
  4. Username varchar (20 ),
  5. Passwd varchar (20 ),
  6. Email varchar (30 ),
  7. Grade INT );

2. Insert some data into the table:

Code:
  1. Insert into users values ('admin', 'admin', 'admin @ sohu.com ', 1)
  2. Insert into users values ('shunping', 'shunping', 'shunping @ sohu.com ', 1)
  3. Insert into users values ('tester1', 'tester1', 'tester1 @ sohu.com ', 5)
  4. Insert into users values ('tester2', 'tester2', 'tester2 @ sohu.com ', 5)
  5. Insert into users values ('tester3', 'tester3', 'tester3 @ sohu.com ', 1)
  6. Insert into users values ('tester4', 'tester4', 'tester4 @ sohu.com ', 6)
  7. Insert into users values ('tester5', 'tester5', 'tester5 @ sohu.com ', 2)
  8. Insert into users values ('tester6', 'tester6', 'tester6 @ sohu.com ', 1)
  9. Insert into users values ('tester7', 'tester7', 'tester7 @ sohu.com ', 2)

3. The following are key statements for quickly adding records:

Code:
  1. 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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.