MySQL DatabaseLesson 49Free preview
MySQL Create Table
This lesson is part of MySQL · All levels
Summary
A new table is created with the CREATE TABLE command followed by the definition of each column and its data type. MySQL provides data types such as INT, VARCHAR, DECIMAL, DATE, and TEXT that are selected according to the type of data stored. Adding IF NOT EXISTS makes the safe command run multiple times when creating the scheme.
Key points
- CREATE TABLE name_table (column type_data,...) creates a new table
- Select the data type according to the content: INT for integers, VARCHAR for text, DECIMAL for money, DATE for date
- DECIMAL(10,2) means a maximum of 10 digits with 2 decimal digits
- If NOT EXIST prevents error when the table already exists
- Specify NOT NULL, DEFAULT, PRIMARY KEY, and other constraints since the beginning of the definition
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.