The Default Value of a Record



To specify the default value in a SQL statement, when creating the column, before the semi-colon or the closing parenthesis of the last column, assign the desired value to the DEFAULT keyword. Here are examples:

    FullName VARCHAR(50),
    Address VARCHAR(80),
    City VARCHAR(40),
    State VARCHAR(40) >DEFAULT = 'NSW',
    PostalCode VARCHAR(4) DEFAULT = '2000',
    Country VARCHAR(20) DEFAULT = 'Australia'

After creating the table, the user does not have to provide a value for a column that has a default. If the user does not provide the value, the default would be used when the record is saved.

Visually Creating a Default Value

You can create a default value of a column when creating a table. To specify the default value of a column, in the top section, click the column. In the bottom section, click Default Value or Binding, type the desired value following the rules of the column's data type:

It the Data Type is Intructions
Text-based (char, varchar, text, and their variants) Enter the value in single-quotes
Numeric-based Enter the value as a number but following the rules of the data type.
For example, if you enter a value higher than 255 for a tinyint, you would receive an error
Date or Time Enter the date as either MM/DD/YYYY or YYYY/MM/DD. You can optionally include the date in single-quotes.
Enter the time following the rules set in the Control Panel (Regional Settings).
Bit Enter the value as 0 for FALSE or any other long integer value for TRUE



Home Copyright © 2007-2012 FunctionX