SQL Cookbook: Inserting, updating, and deleting

Source: Internet
Author: User
Tags dname

1. Copy rows from one table to another

1  into dept_east (Deptno, Dname, loc) 2 Select deptno, dname, loc 3  from Dept 4 where inch ('New York'Boston')

2. Duplicate table structure

Changing the Where condition can also copy part of the data

1 mysql>createtableas2-     Select  *from  film3,     where1 = 0\g

3. Block insertions to a few columns

Create a view that displays only the columns that the user is allowed to access

4. Delete all records from the table

Delete Does not take where to

5, the meaning of group by is equivalent to selecting columns with the same column values for merging, generally with the aggregate function

1 Select  from Group  by  having Count (*>=2

SQL Cookbook: Inserting, updating, and deleting

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.