Data Manipulation Flashcards

(25 cards)

1
Q

What is data manipulation in SQL?

A

Using commands to insert, update, or delete data inside tables — the CRUD operations.

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

What does CRUD stand for?

A

Create, Read, Update, Delete.

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

What command is used to insert data into a table?

A

INSERT INTO table_name (columns) VALUES (values);

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

What happens to columns not listed in the INSERT?

A

They receive NULL by default unless a DEFAULT value is defined.

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

Why must the values in INSERT match the column order?

A

Because the values are assigned by position, not by name.

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

How can you insert multiple rows at once?

A

List multiple sets of values, separated by commas.

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

What is the syntax for updating table values?

A

UPDATE table_name SET column1 = value1, … WHERE condition;

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

What happens if you omit the WHERE clause in UPDATE?

A

All rows in the table are updated.

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

Why is WHERE clause important in UPDATE?

A

To restrict changes only to relevant rows.

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

What is the syntax to delete rows from a table?

A

DELETE FROM table_name WHERE condition;

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

What happens if you omit WHERE in DELETE?

A

All rows in the table will be deleted.

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

Why is the WHERE clause critical in DELETE?

A

To prevent accidental deletion of all data.

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

If you want to delete all employees from ‘Sales’, what command would you use?

A

DELETE FROM employees WHERE department = ‘Sales’;

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

If you want to increase all salaries by 10%, what command would you use?

A

UPDATE employees SET salary = salary * 1.10;

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

How would you insert a new student with name and email?

A

INSERT INTO students (name, email) VALUES (‘Alice’, ‘alice@example.com’);

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

Spot the mistake: ‘INSERT table_name (col1) VALUES (val1);’

A

Missing INTO — should be INSERT INTO table_name …

17
Q

Spot the mistake: ‘UPDATE SET name = ‘Tom’ WHERE id = 2;’

A

Missing table name after UPDATE.

18
Q

Spot the mistake: ‘DELETE users WHERE age < 18;’

A

Missing FROM — should be DELETE FROM users …

19
Q

Which SQL command is used to add new data?

20
Q

Which SQL command updates existing data?

21
Q

Which SQL command removes data from a table?

22
Q

Explain why WHERE is crucial in UPDATE/DELETE operations.

A

Without WHERE, the operation affects every row — which can cause catastrophic data loss.

23
Q

Describe the role of INSERT in data manipulation.

A

It creates new rows in the specified table.

24
Q

If you run DELETE without a WHERE clause by mistake, what’s the result?

A

All records are permanently deleted from the table.

25
If you omit columns in an INSERT, what values do they take?
NULL (or DEFAULT, if defined).