Python MySQLLesson 114Free preview
MySQL Create Table
This lesson is part of Python · All levels
Summary
This lesson explains how to create tables in MySQL using the CREATE TABLE command from Python. You'll know the INT and VARCHAR data types, as well as constraints like the PRIMARY KEY, NOT NULL, and AUTO_INCREMENT. The correct column structure determines the quality of the data stored later.
Key points
- CREATE TABLE is followed by the table name and a complete column list with its data type and constraints.
- INT for integers, VARCHAR(n) for text with variable length, and FLOAT for decimal numbers.
- The primary key guarantees each line has a unique identity, often combined with an AUTO_INCREMENT.
- NOT NULL rejects the row that does not fill the column, whereas DEFAULT gives the intrinsic value.
- If NOT EXISTS makes the secure command run repeatedly without causing error.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.