USAGE
Example
Section titled “Example”CREATE TABLE customers ( customer_id INT, customer_name VARCHAR(50), customer_city VARCHAR(50));
INSERT INTO customers (customer_id, customer_name, customer_city)VALUES (1, 'John Doe', 'New York'), (2, 'Jane Doe', 'Los Angeles'), (3, 'Mike Smith', 'Chicago');
SELECT * FROM customers;Output
Section titled “Output” customer_id | customer_name | customer_city-------------+---------------+-------------- 1 | John Doe | New York 2 | Jane Doe | Los Angeles 3 | Mike Smith | ChicagoExplanation
Section titled “Explanation”The CREATE TABLE command is used to create a new table in the database. Three fields are specified: customer_id, customer_name, and customer_city.
The INSERT INTO command is then used to populate the table customers with data.
Finally, the SELECT command is used to retrieve all data from the customers table. It outputs the rows of the table, where each row represents a unique customer with their associated ID, name, and city.
Example
Section titled “Example”SELECT FIRST_NAME, LAST_NAMEFROM EMPLOYEESWHERE SALARY > 5000;Output
Section titled “Output”| FIRST_NAME | LAST_NAME ||------------|-----------|| John | Doe || Jane | Doe |Explanation
Section titled “Explanation”The above SQL statement is extracting the column ‘FIRST_NAME’ and ‘LAST_NAME’ from the ‘EMPLOYEES’ table where the ‘SALARY’ is greater than 5000. The output table displays the result of the SQL statement.