Skip to content
Advertisement

How to set default value in sql so that is displays in db

What important in A table is there are three values of type column: New, Activated, Archive.

And I set default value 0 to size column of A table and after insert command

I expected following result in A table:

Query

Table A result

id b_id type size
1 101 New 10
2 101 Activated 0
3 101 Archive 0

But, it does not work. So how to reach that ?

Advertisement

Answer

You are inserting just one row, so this will not automatically create three rows.

If you want three rows, including two with a default size value:

If you wanted to automatically duplicate the inserted row for the two other statuses, you could consider something like:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement