How to insert default values in SQL table?

前端 未结 8 896
灰色年华
灰色年华 2020-11-28 06:26

I have a table like this:

create table1 (field1 int,
               field2 int default 5557,
               field3 int default 1337, 
               field4 i         


        
相关标签:
8条回答
  • 2020-11-28 07:12

    The best way is:

    insert your_table
    default values
    
    0 讨论(0)
  • 2020-11-28 07:13

    Just don't include the columns that you want to use the default value for in your insert statement. For instance:

    INSERT INTO table1 (field1, field3) VALUES (5, 10);
    

    ...will take the default values for field2 and field4, and assign 5 to field1 and 10 to field3.

    0 讨论(0)
提交回复
热议问题