Frequently used MySQL commands to change the table structure of some SQL statements, including adding, deleting, modifying fields, adjusting the order of the fields.To add a field:ALTER TABLE ' User_movement_log ' Add column Gatew
At first, I thought it was my own character length problem, and after shortening it was still a problem. The original is because the Chinese code.Workaround: Modify the DEFAULT_CHARACTER_SET=GBK in the My.ini file;# CLIENT section#----------------------------------------------------------------------# # The following options would be read by MySQL client applications.# Note This only client applications shipped by MyS QL is guaranteed# to read ThisSec
When multiple timestamp are present in a table and one is set to Current_timestamp, you often encounter#1293-incorrect table definition; There can is only onetimestamp column with Current_timestamp in DEFAULT or on UpdateclauseThe reason is that when you set the timestamp to on Updatecurrent_timestamp, the other timestamp fields need to explicitly set the default
Increment (the column is auto incremented if rows are inserted) automatically increasesBin:binary (if DT is a blob or similar, this indicates is binary data, rather than text) binaryun:unsigned (for-integer types, see docs: "10.2.) Numeric Types ")-Zf:zero fill (rather a display related flag, see docs: "10.2. Numeric Types ")The following page appearsNext, add data to the built-in tb_student table.Right-cl
If you want to add columns to the table, use the following syntax:
ALTER TABLE table_nameADD column_name datatypeTo delete a column from a table, use the following syntax:
ALTER
and modification operations on the TABLE will be delayed until the new TABLE is generated. After a new table is generated, the update and modification information is automatically transferred to the new table.
Note: If you use an option other than RENAME when executing alter
Tags: ISS start key Time POS GPO Fun nbsp bodyWhen MySQL builds a table, you need to add two time columns to record the creation and modification time of the current record, respectively. Good. The following is the build table statement:[SQL]View PlainCopy
DROP TABLE IF
To add columns to a table, use the following syntax:
Alter table table_nameADD column_name datatypeTo delete columns in a table, use the following syntax:
Alter table table_nameDrop
overhead, while the frequent movement, paging operations caused a lot of fragmentation, the lack of compact index structure, the subsequent forced by optimize Table to rebuild the tables and refine the fill page. In summary, if the data write order of the InnoDB table is consistent with the leaf node order of the B + Tree index, then the access efficiency is the highest, that is, the following conditions
Because of the recent project, there is such a demand, is the database of two data interchange, after a long time to finish, here to write a simple example, made a record.
1. Create tables and records for testing
CREATE TABLE ' product ' (
' id ' int ' unsigned NOT NULL auto_increment COMMENT ' products ID ',
' name ' varchar () NOT NULL COMMENT ' Product name ',
' Original_price ' decimal (5,2) unsigned not NULL COMMENT ' original price '
Add, delete, modify, and query bitsCN.com of table fields in Mysql
Add, delete, modify, and query table fields in Mysql
Add, modify (modify type), delete, and sort
In MySQL, the show syntax is used to obtain detailed information about the table column and the entire database, allowing you to conveniently view detailed information about the database.
In MySQL, the show syntax is used to obtain detailed information about the table
Today, with MySQL Workbench, the following error occurred while updating the data:15:52:39 Update wp_posts Set post_content = replace (post_content, '/water ', ') Error code:1175. You is using Safe update mode and you tried to update a table without a WHERE is uses a KEY column to disable safe mode , toggle the option in Preferences, SQL Editor and reconnect. 0.0
Mysql tables are sorted by multiple columns to obtain the first or next entry of a specified value. how can we make it simple? mysql, table name: tblsale, there are two fields, date and index, to determine a sales order (n orders in a day are identified by index). the records in the table are not necessarily discharged
Tags: you key error option Col NEC post error code Mys1 IntroductionWhen the where statement is missing from the update field, MySQL prompts for the error code:Error code:1175. You is using Safe update mode and you tried to update a table without a WHERE is uses a KEY column to disable safe mode , toggle the option in Preferences, SQL Queries and reconnect. 0.000
MySQL uses a digital auxiliary table to implement complex columns and change rows. One day, a netizen In the QQ circle sent a help message:
PropID name Amount3 ingot 22 ledou 3
Whether an SQL statement can be used as an output is to copy the number of Amount records:
PropID name3 Yuanbao 3 Yuanbao 2 ledou 2 ledou 2 ledou
After studying the problem, I had to change my mind when I used the ordinary group
The following article describes how to add, delete, and modify fields and adjust the order of fields in MySQL, the following describes how to add, delete, and modify fields and adjust the order of fields in MySQL.
MySQL changes the table
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.