W3. SQL Insert Into Flashcards

1
Q

Q: What is the purpose of the SQL INSERT INTO statement?

A

A: To insert new records into a table.

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

Q: What is one way to write the INSERT INTO statement with specified columns?

A
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Q: How do you insert values into all columns without specifying column names?

A
INSERT INTO table_name 
VALUES (value1, value2, value3, ...);

(Ensure values are in the correct order.)

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

Q: Write an example INSERT INTO statement that adds a record with specific column names in the “Customers” table.

A
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) 
VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q: What happens to an AUTO_INCREMENT column like CustomerID when a new record is inserted?

A

A: It is generated automatically without specifying a value for it.

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

Q: Can you insert data into specific columns only? Provide an example.

A

A: Yes, by specifying only those columns.

INSERT INTO Customers (CustomerName, City, Country) 
VALUES ('Cardinal', 'Stavanger', 'Norway');
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q: How do you insert multiple rows in a single INSERT INTO statement?

A

A: Use multiple sets of values, separated by commas.

INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) 
VALUES 
('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway'),
('Greasy Burger', 'Per Olsen', 'Gateveien 15', 'Sandnes', '4306', 'Norway');
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q: What must you do to separate multiple rows in a single INSERT INTO statement?

A

A: Separate each row of values with a comma.

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