0
Sql: "int default 1 not null" - how it works?
Hi, I'm learning now from my knowledge book and here's a code inside sql database creating, which I can't understand. "(...) xyz1 char (20) not null, //Okay xyz2 int default 0 not null, //Emm.. okay? xyz3 int default 1 not null, //...what? (...)" I've read that "not null" is better practise than "null", because empty memory, but I can't understand idea of "default 0 not null" and a fortiori "default 1 not null", isn't it mutually exclusive? For what is "not null" after "default 0 or 1"? Help in advance.
1 Resposta
+ 2
NULL means unknown data. It is not equal to zero.
NOT NULL constraint means, that you can't insert a row without giving a value to that column, because that column cannot contain NULL (unknown data).
But it can contain zero value.