Udjuni.com

udjuni.com search:




Common SQL Data types


Now that you have identified your data entities or tables, you have to define each attribute of the tables you have identified. These definitions include the name of the attribute and the type of data that can be stored in the field. Most relational database systems have a number of data types that can be broken into the following categories: numeric , String and Date and time types

Numeric data types


Most commonly used numeric data types include:
integer or INT - normal integer can be signed or unsigned. This is some times used just as INT when defining variables.
BIGINT - The same as integer, but stores more data than a normal integer.
DECIMAL or NUMERIC(M,D) - As the name implies, this data type hold decimal numbers where M denotes the length or total number of digits and D denotes the number of digits after the decimal point.
There are a few more data types of this category. Depending on the relational database system, they may or may not have the same names.

String data types


CHAR(M) - Fixed length string with the maximum of 255 characters, denoted by the letter M.
VARCHAR(M) - Variable length string. The difference between varchar and char is with the way storage is allocated. With char the space is fixed, in other words if you defined the variable to have 20 characters, the system allocates space for 20 characters regardless of whether the value in the field is less than 20 characters long.

With varchar, although the value is defined to be 20, if the string is only 10 characters long, the system is only going to allocate 10 character space to that value. Thus cutting down on allocating unused space to variables.
BLOB or TEXT - This represents a fields with up to 65535 characters, and is usually used for large amounts of data such as images or other types of files.

Date and time data types


DATE - Represents a date value in the format YYYY-MM-DD and the values range between 1000-01-01 to 9999-12-31.
DATETIME - Features a date and time combination. For example December 12th 2009 would be recorded as 2009-12-12 00:00:00 this includes time in the format hh:mm:ss in addition to the date, where hh denotes hour, mm denotes minutes and ss denotes seconds.

In the next few postings I will explain using a step-by-step approach on how to create a database and tables. From there we will move on to data entry techniques.



RELATED ARTICLES:


Java variables and data types
A variable is defined as a named piece of memory that a java program uses to store data. Each of these storage pieces can only store data of a certain type. In other words, if you defined as variable of type integer, that variable can only hold inte

Selecting data from multiple tables
So far we have covered methods of retrieving data from single table. In real life however, you hardly get to only retrieve data from one table. In other words, to retrieve and interpret information, you normally get such information from different tables each of which will contain only information a

Updating and deleting data with SQL
In the posting “Introduction to SQL”, we covered the creation of data storage space or database and its entities. We then went a little further to cover a methods of entering data into those entities or tables and methods of retrieval. There are however, times when the data stored in

Copying data from one table to the other
here are several ways to copy or move data from one table to another. Some methods are applicable when copying data from one table to another on the same database and other methods are applicable for copying data from one database to another and even or a different server. Bellow are several methods

Greatest Common Factors (GCF)


Did not find it? Try udjuni.com search:







© 2009 UdjunI LLC. All rights reserved | Privacy policy | Tutorial Index | RSS Feed