SQL Deleting Tables And Records Commands And Inserting Command Flashcards

1
Q

What does the command INSERT do and give example

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What soes the command DELETE for recs do and give an examples

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does tye command DROP do for a table and give example

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly