Last answered:

17 Aug 2022

Posted on:

16 Aug 2022


default value - adding multiple records with and without default value

how can i add default value if i give condition like this for multiple records

insert into companies(company_id,company_name,headquarters_phone_number)
('chan', ,'abcd')
it showing error i want default values for 2nd record and 1st one with value inserted

i have added this condition also

alter table companies
change column company_name company_name varchar(255) default 'x';

1 answers ( 0 marked as helpful)
Posted on:

17 Aug 2022


Hi Lanchan!
Thanks for reaching out.

You need to use the ALTER TABLE statement to add default values for the first and third column. If you provide a company name, you do not need to change this column to a default string. You simply provide a name and the other two columns contain a default value.

Hope this helps.

Submit an answer