Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a column with the name "default"

My setup: Rails 2.3.10, Ruby 1.8.7

I would like to add a database table column with the name "default", is that allowed or is it a reserved word in Ruby, Rails, sqlite, postgresql...?

like image 985
Bob Avatar asked Feb 22 '11 00:02

Bob


People also ask

How do I add a default column in SQL Server?

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.

What is a default column?

Certain columns and data types have predefined or assigned default values. For example, default column values for the various data types are as follows: NULL. 0 Used for small integer, integer, decimal, single-precision floating point, double-precision floating point, and decimal floating point data type.

How do you name a default constraint?

In SQL Server, the default constraint names start with specific prefixes: PK , UQ , CK , or FK . The default name for a PRIMARY KEY constraint starts with ' PK ', followed by underscores (' __ '), the table name, more underscores (' __ '), and a hexadecimal sequence number generated by SQL Server.


1 Answers

Here is the list of reserved words that don't play friendly as table columns in Rails http://oldwiki.rubyonrails.org/rails/pages/ReservedWords

If you're using mysql, DEFAULT is a reserved word according to: http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

like image 131
noli Avatar answered Sep 25 '22 23:09

noli