user3134614
user3134614

Reputation: 160

Insert statement with single quote for Integer datatype

I have a table table1 (id integer, Name varchar, Age integer)

While inserting rows into the table I use two statements.

  1. INSERT INTO TABLE1('1','John','33'); and
  2. INSERT INTO TABLE1(1,'John',33);

Both of them work fine. In the first insert statement I have used the value between single quote for the integer datatype as well.

Can I know what can be the difference between both of the statements?

Upvotes: 4

Views: 37116

Answers (1)

Yagnesh Agola
Yagnesh Agola

Reputation: 4639

There is no difference between using single quote for Integer datatype or not.

In first case it will load db server to convert your string literal to integer data type whereas in second case it will directly store integer value to database.

Its good to used without single quote, since that would just be an extra unnecessary step for the database to convert the string literal into a numeric value and also make some little bit difference in performance when there are more records inserted at a time.

Upvotes: 7

Related Questions