Logo
Pattern

Discover published sets by community

Explore tens of thousands of sets crafted by our community.

Common SQL Commands

20

Flashcards

0/20

Still learning
StarStarStarStar

DROP TABLE

StarStarStarStar

Used to delete a table and its structure from the database. Example: DROP TABLE users;

StarStarStarStar

DISTINCT

StarStarStarStar

Used to remove duplicate rows from a result set. Example: SELECT DISTINCT country FROM users;

StarStarStarStar

IN

StarStarStarStar

Used to specify multiple possible values for a column. Example: SELECT * FROM users WHERE country IN ('USA', 'Canada');

StarStarStarStar

ALTER TABLE

StarStarStarStar

Used to modify an existing table's structure. Example: ALTER TABLE users ADD COLUMN email VARCHAR(100);

StarStarStarStar

TRANSACTION

StarStarStarStar

A sequence of database operations that are treated as a single logical unit. Example: BEGIN TRANSACTION; ... COMMIT;

StarStarStarStar

UPDATE

StarStarStarStar

Used to modify existing data in a table. Example: UPDATE users SET age = 26 WHERE name = 'Alice';

StarStarStarStar

INDEX

StarStarStarStar

Used to create an index on a table column to increase query performance. Example: CREATE INDEX idx_name ON users (name);

StarStarStarStar

SELECT

StarStarStarStar

Used to retrieve data from a database. Example: SELECT * FROM users;

StarStarStarStar

CREATE TABLE

StarStarStarStar

Used to create a new table in the database. Example: CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(100), age INT);

StarStarStarStar

LIMIT

StarStarStarStar

Used to specify the maximum number of records to return. Example: SELECT * FROM users LIMIT 5;

StarStarStarStar

UNION

StarStarStarStar

Used to combine the result sets of two or more SELECT statements. Example: SELECT name FROM users UNION SELECT name FROM managers;

StarStarStarStar

WHERE

StarStarStarStar

Used to filter records that satisfy a specified condition. Example: SELECT * FROM users WHERE age >= 18;

StarStarStarStar

CASE

StarStarStarStar

Used for conditional logic in SQL statements. Example: SELECT name, CASE WHEN age < 18 THEN 'minor' ELSE 'adult' END AS type FROM users;

StarStarStarStar

INSERT INTO

StarStarStarStar

Used to insert new data into a table. Example: INSERT INTO users (name, age) VALUES ('Alice', 25);

StarStarStarStar

HAVING

StarStarStarStar

Used to filter groups based on a condition, often used with GROUP BY. Example: SELECT COUNT(*), country FROM users GROUP BY country HAVING COUNT(*) > 10;

StarStarStarStar

ORDER BY

StarStarStarStar

Used to sort the result set of a query. Example: SELECT name, age FROM users ORDER BY age DESC;

StarStarStarStar

DELETE FROM

StarStarStarStar

Used to remove existing data from a table. Example: DELETE FROM users WHERE name = 'Alice';

StarStarStarStar

BETWEEN

StarStarStarStar

Used to filter the result set within a certain range. Example: SELECT * FROM users WHERE age BETWEEN 18 AND 30;

StarStarStarStar

JOIN

StarStarStarStar

Used to combine rows from two or more tables based on a related column between them. Example: SELECT * FROM orders JOIN customers ON orders.customer_id = customers.id;

StarStarStarStar

GROUP BY

StarStarStarStar

Used to arrange identical data into groups. Example: SELECT COUNT(*), country FROM users GROUP BY country;

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.