1. InsertINSERT INTO customers( customers.cust_address, customers.cust_city, customers.cust_state, customers.cust_zip, customers.cust_country, customers.cust_contact, customers.cust_email ) VALUES('zhangsan','good','111','ca','dasdsa','usa',NULL) This way the insertion is successful. For safety reasons, you should write the column name each time you insert. Regardless of which Omitting Columns If the table definition permits, you can omit certain columns in an INSERT operation. The omitted columns must satisfy one of the following conditions
Improving overall performance Databases are often accessed by multiple clients, and it is If data retrieval is of primary importance (which it usually is), you can instruct INSERT INTO customers( customers.cust_address, customers.cust_city, customers.cust_state, customers.cust_zip, customers.cust_country, customers.cust_contact, customers.cust_email ) VALUES('zhangsan','good','111','ca','dasdsa','usa',NULL) ,('zhangsan','good','111','ca','dasdsa','usa',NULL) ,('zhangsan','good','111','ca','dasdsa','usa',NULL) ,('zhangsan','good','111','ca','dasdsa','usa',NULL) If you want to insert multiple rows, just add multiple This is called Suppose you want to merge a list of customers from another table into your insert into customers(xx,xx,xx) select xx,xx,xx from newcustomers That's about it. Column Names in However, the column names are not necessarily required to match. In fact, It uses the position of the columns, so the first column in The first column specified in the table columns will be used to populate the second column specified in the table columns, and so on. This is useful for importing data from tables that use different column names. 2. Update To update (modify) data in a table, use the There are two ways to use
UPDATE customers SET cust_email = '[email protected]' where cust_id = 10005; This is the update statement above. If you update multiple columns: UPDATE customers SET cust_email = '[email protected]', cust_name = 'game' where cust_id = 10005;
To continue the update even if an error occurs, use the To explain this, if you are sure to update only one row, then it is recommended to use the To delete (remove) data from a table, use the 3. Delete
Delete the contents of a table instead of the table. The Faster Deletions If you want to delete all rows from a table, don't use You can use the This is the end of this article about the details of MySQL data insertion, update and deletion. For more relevant MySQL data insertion, update and deletion content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: DIV and image horizontal and vertical centering compatible with multiple browsers
>>: Implementation of CSS linear gradient concave rectangle transition effect
The following analysis is about product design pr...
Table of contents introduction Ideas Establish ID...
Disclaimer: Since the project requires the use of...
I don’t know if you have ever encountered such a ...
When using XAML layout, sometimes in order to make...
The first thing to do is to pick a good browser. ...
Installation Environment 1. gcc installation To i...
Readonly and Disabled both prevent users from chan...
In Nginx, there are some advanced scenarios where...
Preface: During the project development, we encou...
This article example shares the specific code of ...
Dynamically implement a simple secondary menu Whe...
Table of contents 1. Problems encountered 2. Idea...
Table of contents 1. Database master-slave classi...
Linux change hostname command 1. If you only need...