Skip to main content

General commands

Creating a table 


 

 

View

Syntax 

Example

CREATE TABLE table_name (
    column1 datatype,datatype contraint,
    column2 datatype,
    column3 datatype,
);

Example

CREATE TABLE products (
    id INT AUTO_INCREMENT PRIMARY KEY,
    product_name VARCHAR(32),
    company_id INT,
    FOREIGN KEY (company_id) REFERENCES companies(id)
) ENGINE=InnoDB;

table creation code
SHOW CREATE TABLE `table_name`;