Is there a shorter way to insert multiple rows in a table?

I think there is problem with your quotation mark. It doesn’t look right.
I changed it and tried the statement. It’s ok.

insert into employee (employee_id,first_name,last_name,gender,position,department_id,salary)

Any other shortcuts to learn SQL faster n better

What happens if you enter a text under an column with integer values?

A very interesting question. It seems that a column declared to accept INTEGER also takes TEXT. For example,

INSERT INTO celebs (id, name, age)
VALUES ('4', 'Taylor Swift', '26');

does not give any error. However, it seems that SQLite converts the input into a declared type: ‘26’ is converted into 26 before it is saved in the table. See their manual for more info: Datatypes In SQLite Version 3

I wonder why I am not getting the same results as you @aryanwen, if I am doing the same thing you’re doing. Any help is much appreciated. Thank you!

Just Remove, the semicolon and and comma, then the code works.

Hello there!!,
As given in the cheat sheet, we can insert values

  • In order
  • By name
    I was wondering about inserting multiple values few following in order, few by name as shown in the snap below (where I have used two statements one for by name and the other one for in order) in a single statement. Can anyone please help me with this…


why cant i continue with learning at stage 5?

@creyess I think your code should give you the same result as @aryanwen done properly. It seems like the celebs table was created with 4 rows.

Use SELECT * FROM celebs; at the end to view and see if it’s done properly.

@script7770076527 I think your code is running properly. The first row in your table is inserted using your first insert into statement. The 1 is inserted into the id column and Uknown into the name column as intended and because you didn’t specify a value for the age column, the value there remains empty. The second insert into statement correctly inputted the second and third rows as intended.

@juniorchuang Thank you for your reply. Yes I have used separate statements, 1st statement not specifying the age but by mentioning the column names, 2nd statement in order giving the values directly. I was wondering if we can insert all the values in a single statement.

@script7770076527 If you want to do it all in the single statement, since you are populating three columns anyways you can do:

INSERT INTO celebs VALUES (1, ‘Uknown’, ‘’), (2, ‘xx’, 26), (3, ‘yy’, 28);

to get the same result. If you don’t have age on the first observation I think you need to explicitly enter it as missing.

Yes, that works. Thank you.

As i am taking this course and learning to create tabels, is there a command you can make to see all tabels created?

Thank you, very helpful tips.

New INSERTs INTOs Overrides the current data from table or is it some codecademy course behavior ?