Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid NULL columns using DEFAULT Empty String

how can I create a Column with the default value being an empty string?

thanks guys!

like image 258
GibboK Avatar asked Aug 06 '10 07:08

GibboK


2 Answers

You can read up on the subject here

CREATE TABLE dbo.Test (ID INTEGER, EmptyString VARCHAR(32) DEFAULT '')

INSERT INTO dbo.Test (ID) VALUES (1)
INSERT INTO dbo.Test (ID) VALUES (2)

SELECT * FROM dbo.Test

DROP TABLE dbo.Test
like image 196
Lieven Keersmaekers Avatar answered Oct 12 '22 06:10

Lieven Keersmaekers


Something like:

CREATE TABLE foobar (string_column VARCHAR(100) NOT NULL DEFAULT '')

like image 33
tdammers Avatar answered Oct 12 '22 06:10

tdammers