MySQL Learning notes--operations on records in a data table

Source: Internet
Author: User

The operation of the record, mainly to increase, delete, change, check

First, record insertion
Command:insert into table name (column name, column name, ...) values (value, value, ....);

The number of values should be the same as the number of columns, Value and column order, value type and column field type match

When the column name is omitted after the table name, values for all columns are given later in values

When inserting data, the string adds single quotation marks "'----character and date data should be enclosed in single quotes

Chinese garbled problem when inserting data: Set client's encoding set to GBK

Modify the MySQL configuration file to permanently change the client encoding set-----Mysql/my.ini
[MySQL]----client configuration
[MYSQLD]----Server-side configuration

Second, record deletion

Command:delete from table name where conditional statement; (Delete records that meet the criteria in the table, and delete all records in the table if the WHERE Condition statement is omitted)

Delete a table all records: truncate table name; effect and delete from table name;

Truncate and delete Use the difference?

Truncate not recoverable after deleting records, not transaction management, principle: Delete entire table first, recreate

Delete can be managed by transaction, delete data in transaction can be rolled back (rollback) recovery, principle: Delete data record on one line

Third, record changes

Command: Update table name set column name = value, column name = value where condition statement;

* No where statement, update all rows of data, equivalent to where 1;

* When a conditional statement is a comparison string, it is more precise and strict to add the binary keyword after the where.

Iv. Record Enquiry

Command:Select column name, column name, ..., column name from table name where conditional statement;

A record in the query table that satisfies the criteria, and if it is a select * from table name, all records in the table are displayed

MySQL Learning notes--operations on records in a data table

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.