MySQL database added delete with new, associated data

Source: Internet
Author: User

Add data
When the primary key conflict is, choose how to Do
Insert into table (id,name,age) value ("ddd", 45)
On duplicate key update name= ' DDD ' age=45;
The default has a PRIMARY KEY constraint and will not be inserted successfully
However, you can change to perform an update operation within the INSERT syntax when you control the primary key conflict

Replace: If primary key conflicts, select Replace, if primary key does not conflict, add a record

Replace into hd_cate values (XXX,XXX,XXX);


Delete format: Delete from one,two using one join both on condition where condition (simulated foreign key technology)

Empty tables truncate TABLE;

multiple table update; update Tabel1 join table2 on conditional set content where condition


Data backup:
Mysqldump-u root-p Blog >e:/blog.sql (Backup database)
Mysqldump-u root-p Blog Hd_cate >e:/hd_cate.sql (back up the tables in the database)
Mysqldump-u root-p hd_cate table_name1 table_name >e:/hd_cate.sql (backup multiple tables)
Backup restore: Source E:/hd_cate.sql


Creating views Create View V_cate as select Id,name from Hd_cate;

The view is a village and a virtual table in the database
The view, which has no data in itself, is simply done by executing the corresponding SELECT statement to obtain the corresponding data
The view saves only one SQL statement

MySQL database added delete and new, associated data

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.