Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default value for a text column

Tags:

mysql

I have a column in my table having data type as TEXT.

How can I give it a default NULL value, so that when there is not entry in the column it doesn't consume memory.

I was reading a similar question on a forum where they said column should be allowed for null values; I did that but it doesn't work..

like image 912
Shaun Avatar asked Mar 09 '11 08:03

Shaun


People also ask

What is the default value of text data type?

For numeric types, the default is 0 , with the exception that for integer or floating-point types declared with the AUTO_INCREMENT attribute, the default is the next value in the sequence. For date and time types other than TIMESTAMP , the default is the appropriate “zero” value for the type.

What is the default value of a column?

Default values can be NULL, or they can be a value that matches the data type of the column (number, text, date, for example).

How do I set a default column value?

In Object Explorer, right-click the table with columns for which you want to change the scale and select Design. Select the column for which you want to specify a default value. In the Column Properties tab, enter the new default value in the Default Value or Binding property.

What is a default value for a column of a table in SQL?

SQL Server Default Value A column can be given a default value using the DEFAULT keyword. The DEFAULT keyword provides a default value to a column when the SQL Server INSERT INTO statement does not provide a specific value. The default value can be a literal value, an expression, or a SQL Function, such as GETDATE().


1 Answers

TEXT does not support default values of anything but NULL. As such, it's implicitly DEFAULT NULL, so you should not need to change anything.

like image 98
BoltClock Avatar answered Sep 25 '22 06:09

BoltClock