Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.
-- In this video, we will
-- Use A Default Value
-- Default Value Not Working
-- Alter Column With A Default Value
-- Alter Column Datatype
-- So, keep watching and subscribe my channel
CREATE TABLE EMP(
ID NUMERIC,
NAME CHARACTER VARYING(20),
SALARY NUMERIC(10,2),
DEPTNO CHARACTER VARYING(10)
);
INSERT INTO EMP(id,name,salary,deptno)
values(1,'Akram',100.23,'10');
select * from emp;
-- Now, let's alter the table, and make Salary column default
Alter table emp alter column salary set default 50;
-- First I will show you when it works and then it won't work.
INSERT INTO EMP(id,name,deptno)
values(2,'Sohail','10');
-- This must have inserted salary as 50, which I have set default value.
-- Let's check
Select * from emp;
-- Now, I will show you when default value won't work
INSERT INTO EMP(id,name,salary,deptno)
values(3,'Knowledge 360',null,'15');
-- Here, the salary must be inserted as NULL
Select * from emp;
-- So, the conclusion is, whenever we give the default value, we do not
-- need to mention the column in the insert statement.
-- If we do so, then we have to put some value, even if it is null
-- The database will accept the null
PostgreSQL Default Value Not Working,
How To Resolve PostgreSQL Default Value Not Working,
How To Fix PostgreSQL Default Value Not Working,
Resolve PostgreSQL Default Value Not Working,
Fix PostgreSQL Default Value Not Working,
PostgreSQL Column Default Value,
pgAdmin,
Column Default Value,
PostgreSQL