0

I try to understand what null value is in SQL. See the following screenshot.

My question is: if I allow null, does it mean that it is null or not? I mean if I fill in the box (see the picture) does it mean it is null?

Click to see the screenshot

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    Just as a side note: `NULL` is really not a value - it's the **absence** of a value, really. So if a column is `NULL`, it means that there is no value defined for this column yet .... – marc_s Oct 02 '20 at 19:24
  • Thanks for your answer, but if I fill the box under "Allow Nulls", does it become Null? Hope you understand what I mean... – Oxana Petrovic Oct 02 '20 at 19:30
  • 1
    If you check the "Allow Nulls" - then you **allow** the column to be null / undefined. If you haven't checked this box, then you **require** the column to always have a non-NULL value – marc_s Oct 02 '20 at 19:31
  • 1
    Ahh I get it now!! You helped a lot! – Oxana Petrovic Oct 02 '20 at 19:32

2 Answers2

2

Setting null or not null does not change the values of anything in the data.

It simply specifies whether you can insert or update values to NULL.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

If you do not specify a value for the column that allows null value, then it becomes null after insert or update. You can also specify the default value for the column, look at my screenshot.enter image description here

  • I see, I need help with another thing. I want to prevent duplicate inserts into database, do you know an easey way? – Oxana Petrovic Oct 02 '20 at 20:16
  • Add a primary key or unique index on the column you don't want any duplicates of. – pmbAustin Oct 02 '20 at 20:17
  • But the primary key in this case is the Id, my table contains only ID and CategoryName, I dont want any dublicates of CategoryName. And since the id is the primary key I connot set the other one to primary key can I ? – Oxana Petrovic Oct 02 '20 at 20:20
  • Add a unique index to this field. https://stackoverflow.com/questions/5181877/how-can-i-create-a-unique-constraint-on-my-column-sql-server-2008-r2 – Eugene Dianov Oct 02 '20 at 20:47