MySQL

Short Commands

Change column position

ALTER TABLE table_name MODIFY COLUMN column_last_name VARCHAR(40) AFTER column_first_name;

Count rows in a table

SELECT COUNT(*) FROM table_name;

Create a new table in the database

CREATE TABLE employees (
    id INT AUTO_INCREMENT PRIMARY KEY,
    first_name VARCHAR(50) NOT NULL,
    last_name VARCHAR(50) NOT NULL,
    email VARCHAR(100),
    hire_date DATE,
    salary DECIMAL(10, 2)
);

Insert data into an existing table in the database

INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);

Select data from an existing table in the database

SELECT * FROM table_name;

Select specific columns from an existing table in the database

SELECT column1, column2 FROM table_name;

Update data in an existing table in the database

UPDATE table_name SET column1 = value1 WHERE condition;