Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is difference between CHAR and VARCHAR2?What is the
maximum SIZE allowed for each type?

Answer Posted / esakkiraja

CHAR
-----

SQL> CREATE TABLE char_test (col1 CHAR(10));

Table created.

SQL> INSERT INTO char_test VALUES ('qwerty');

1 row created.

SQL> SELECT col1, length(col1), dump(col1) "ASCII Dump"
FROM char_test;

COL1 LENGTH(COL1) ASCII Dump
---------- ------------ ------------------------------------
------------------------
qwerty 10 Typ=96 Len=10:
113,119,101,114,116,121,32,32,32,32


VARCHAR
-------

SQL> CREATE TABLE varchar_test (col1 VARCHAR2(10));

Table created.

SQL> INSERT INTO varchar_test VALUES ('qwerty');

1 row created.

SQL> SELECT col1, length(col1), dump(col1) "ASCII Dump"
FROM varchar_test;

COL1 LENGTH(COL1) ASCII Dump
---------- ------------ ------------------------------------
------------------------
qwerty 6 Typ=1 Len=6: 113,119,101,114,116,121


VARCAHR2
----------

SQL> CREATE TABLE varchar2_test (col1 VARCHAR2(10));

Table created.

SQL> INSERT INTO varchar2_test VALUES ('qwerty');

1 row created.

SQL> SELECT col1, length(col1), dump(col1) "ASCII Dump"
FROM varchar2_test;

COL1 LENGTH(COL1) ASCII Dump
---------- ------------ ------------------------------------
------------------------
qwerty 6 Typ=1 Len=6: 113,119,101,114,116,121



VARCHAR vs. VARCHAR2
---------------------
1. VARCHAR is going to be replaced by VARCHAR2 in next
version. So, Oracle suggests the use VARCHAR2 instead of
VARCHAR while declaring datatype.

2. VARCHAR can store up to 2000 bytes of characters while
VARCHAR2 can store up to 4000 bytes of characters.

3. If we declare datatype as VARCHAR then it will occupy
space for NULL values, In case of VARCHAR2 datatype it will
not occupy any space.


CHAR vs. VARCHAR
----------------

VARCHAR is used to store variable length character strings
up to 4000 characters. But, remember CHAR is faster than
VARCHAR - some times up to 50% faster.

Is This Answer Correct ?    4 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is full join in sql?

945


What programs use sql?

947


what are tables and fields? : Sql dba

1001


How do I run a sql query in pgadmin 4?

911


What is the meaning of disabling a trigger?

1120


How to use boolean type in select statement?

1004


what is view? : Sql dba

918


explain the difference between delete , truncate and drop commands? : Sql dba

1030


What is the difference between database trigger and stored procedure?

1020


what is the difference between where clause and having clause? : Sql dba

960


How do I view a sql database?

989


How do you drop a trigger?

929


What is a sql profiler?

968


who introduced sql?

959


What has stored procedures in sql?

1002