Wednesday, June 12, 2013

SQL Queries in DBMS: A beginner’s guide

Leave a Comment Follow us on twitter
SQL Queries are very important part of Database Management System (DBMS). Structured Query Language is a language which led user to interact with Database Management System (DBMS). To handle and manage the database one should know about these SQL Queries. Here we are going to discuss some of the very basic and important SQL Queries which are going to help thought your life whether you are going to be a Database Administrator (DBA) or pursue a career in Database etc.

Data types used in Structured Query Language (SQL)




Most commonly the data types used in SQL are char, varchar, varchar2, number, date and long. Let’s see each of them one by one.
 
  • char: As the name implies char represents character string of maximum 255 characters. However user can specify its own limit for the variable. Syntax is variable_name char(number of characters).

E.g. country char(20)

This states that user can enter any country name having maximum of 20 characters. If the name of country contains less than 20 characters then the rest of the size will be filled with the spaces.

  • varchar: This data type is very similar to char and perform the same function as of char data type.  The difference is that varchar can take the character string of maximum 4000 characters. Unlike the char data type, varchar doesn’t pad inserted value with spaces. Syntax is variable_name varchar(number of characters).

  • varchar2: varchar2 is the advance version of varchar. There is no difference between the two, however experts says using varchar2 is better than varchar. I don’t know what the reason is.

  • number: This data type is used to store the numbers. Syntax is variable_name number(size),  where size is the maximum length of data.

E.g. addition number(4);
  • long: long data type accepts the character string maximum of 2 Giga Bytes. In normal practice we don’t use long data type.

So, these are the data types that are mostly used while performing the SQL Queries.

0 comments:

Post a Comment