Managing Tables

Now let’s look at how database tables are defined, altered, and dropped.

Creating a New Table

Use the CREATE TABLE command to create a new database table. A table definition consists of a number of columns and a set of table options. Each column in the table definition is given a data type and can also be given a constraint.

A column name can be up to 64 characters long and can contain any character. You must enclose the column name in quotes (“) or backticks (`) if it contains a space. A column name cannot be one of the keywords listed in Appendix F.

The data type of a column determines what values it can hold and the maximum size of a stored value. For instance, a column defined as VARCHAR(6) can contain text data up to 6 characters ...

Get Sams Teach Yourself MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.