MySQL

How to rename a table in MySQL

RENAME TABLE changes the name of a table or tables. You need CREATE and INSERT privileges for the new table and ALTER and DROP privileges for the original table.

        
    

String Data Types

Data typeDescription
CHAR(size)A string with a set length (can contain letters, numbers, and special characters). The size parameter sets the length of the column in characters. Its value can be between 0 and 255. Default is 1
VARCHAR(size)A string with different lengths (can contain letters, numbers, and special characters). The size parameter sets the maximum number of characters that can be in a column. This number can range from 0 to 65535.
BINARY(size)Same as CHAR(), but stores strings of binary bytes. The size parameter gives the length of the column in bytes. Default is 1
VARBINARY(size)The same as VARCHAR(), but stores strings of binary bytes. The size parameter says how many bytes the longest column can be.
TINYBLOBFor BLOBs (Binary Large OBjects). Length limit: 255 bytes
TINYTEXTHolds a string that can be up to 255 characters long.
TEXT(size)Holds a string that is up to 65,535 bytes long.
BLOB(size)For BLOBs (Binary Large OBjects). Up to 65,535 bytes of data can fit in it.
MEDIUMTEXTKeeps a string that is up to 16,777,215 characters long.
MEDIUMBLOBFor BLOBs (Binary Large OBjects). Up to 16,777,215 bytes of data can fit in it.
LONGTEXTString that can hold up to 4,294,967,295 characters.
LONGBLOBFor BLOBs (Binary Large OBjects). Up to 4,294,967,295 bytes of data can fit in it.
ENUM(val1, val2, val3, ...)A string object that can only have one value from a list of options. An ENUM list can have up to 65535 values. If a value is entered that is not in the list, a blank value will be entered. The order in which you enter the values is used to sort them...

How to create a table in MySQL

To make a new table, you must use the CREATE TABLE query command and give the new table a name.

Also, you start to describe the columns of that table in the brackets. The structure is made up of commas that separate the name, the type, and possibly some other properties.

See all the MySQL data types

        
    

Copy one table to another in MySQL

In some cases, you may need to copy only the data of one table to another one with the same structure. Instead of using a tool like MySQL Workbench, you can do it by running a query.