## Temporary Tables 

You can use the TEMPORARY  keyword when creating a table. A TEMPORARY  table is visible only within the current session, and is dropped automatically when the session is closed. For more information, see Section 13.1.20.2, “CREATE TEMPORARY TABLE Statement” . 

## Table Cloning and Copying 

• LIKE 

Use CREATE TABLE ... LIKE  to create an empty table based on the definition of another table, including any column attributes and indexes defined in the original table: 

CREATE TABLE new_tbl  LIKE orig_tbl ; 

For more information, see Section 13.1.20.3, “CREATE TABLE ... LIKE Statement” . 

• [AS] query_expression 

To create one table from another, add a SELECT  statement at the end of the CREATE TABLE  statement: 

CREATE TABLE new_tbl  AS SELECT * FROM orig_tbl ; 

For more information, see Section 13.1.20.4, “CREATE TABLE ... SELECT Statement” . 

• IGNORE | REPLACE 

The IGNORE  and REPLACE  options indicate how to handle rows that duplicate unique key values when copying a table using a SELECT  statement. 

For more information, see Section 13.1.20.4, “CREATE TABLE ... SELECT Statement” . 

## Column Data Types and Attributes 

There is a hard limit of 4096 columns per table, but the effective maximum may be less for a given table and depends on the factors discussed in Section 8.4.7, “Limits on Table Column Count and Row Size” . 

• data_type 

data_type  represents the data type in a column definition. For a full description of the syntax available for specifying column data types, as well as information about the properties of each type, see Chapter 11, Data Types . 

•Some attributes do not apply to all data types. AUTO_INCREMENT  applies only to integer and floating- point types. Prior to MySQL 8.0.13, DEFAULT  does not apply to the BLOB , TEXT , GEOMETRY , and JSON  types. 

•Character data types ( CHAR , VARCHAR , the TEXT  types, ENUM , SET , and any synonyms) can include CHARACTER SET  to specify the character set for the column. CHARSET  is a synonym for CHARACTER SET . A collation for the character set can be specified with the COLLATE  attribute, along with any other attributes. For details, see Chapter 10, Character Sets, Collations, Unicode . Example: 

CREATE TABLE t (c CHAR(20) CHARACTER SET utf8 COLLATE utf8_bin); 

MySQL 8.0 interprets length specifications in character column definitions in characters. Lengths for BINARY  and VARBINARY  are in bytes. 

•For CHAR , VARCHAR , BINARY , and VARBINARY  columns, indexes can be created that use only the leading part of column values, using col_name ( length )  syntax to specify an index prefix length. 

