SQL Deleting Tables And Records Commands And Inserting Command Flashcards
What does the command INSERT do and give example
SELECT users.name, orders.order_id FROM users
JOIN orders
ON users.user_id = orders.user_id;
(retrieves user names and their corresponding order IDs)
Example:
INSERT INTO users (name, age)
VALUES (‘John Doe’,25);
(inserts a new user with the name ‘John Doe’ and age 25)
What soes the command DELETE for recs do and give an examples
Removes data from a database table
Examples:
DELETE FROM users
WHERE age < 18;
(deletes all users younger than 18 from the ‘users’ table)
DELETE FROM users
WHERE name=”John”;
(deletes a record where the name is John)
What does tye command DROP do for a table and give example
DELETE FROM users
WHERE age < 18;
(deletes all users younger than 18 from the ‘users’ table)
DELETE FROM users
WHERE name=”John”;
(deletes a record where the name is John)
Example:
DROP TABLE users;
(deletes the ‘users’ table)