on 06-13-2014 1:07 PM
Hi,
In my previous document (), I write about NVARCHAR, it can store both non-Unicode and Unicode. and VARCHAR stores only non-Unicode characters. but following script insert Unicode in VARCHAR also, if so what is difference between VARCHAR and NVARCHAR.
CREATE COLUMN TABLE NEWS ( ID INTEGER NOT NULL , NDATA NVARCHAR(500), DATA VARCHAR(500), PRIMARY KEY ("ID"));
INSERT INTO NEWS (ID, NDATA, DATA) VALUES(1,'दिल्ली भारत की राजधानी है.', 'Delhi is capital of India.');
INSERT INTO NEWS (ID, NDATA, DATA) VALUES(2,'मुंबई महाराष्ट्राची राजधानी आहे.', 'Mumbai is capital of Maharashtra.');
INSERT INTO NEWS (ID, NDATA, DATA) VALUES(3, 'Mumbai is capital of Maharashtra.', 'मुंबई महाराष्ट्राची राजधानी आहे.');
and output looks like
HI there
the difference mainly is how the size of columns are interpreted - not what data goes in or out.
The actual internal implementation data type is exactly the same (check CS_COLUMN_TYPE in TABLE_COLUMNS).
create column table vartest (vc varchar(10), nvc nvarchar(10));
insert into vartest values ('조조조조조조조조조조' ,'조조조조조조조조조조');
Started: 2014-06-13 17:32:04
Could not execute 'insert into vartest values ('조조조조조조조조조조' ,'조조조조조조조조조조')' in 38 ms 927 µs .
SAP DBTech JDBC: [274]: inserted value too large for column: Failed in "VC" column with the value '조조조조조조조조조조'
insert into vartest values ('조조조' ,'조조조조조조조조조조');
Started: 2014-06-13 17:32:43
Statement 'insert into vartest values ('조조조' ,'조조조조조조조조조조')'
successfully executed in 69 ms 241 µs (server processing time: 36 ms 103 µs) - Rows Affected: 1 ;
Although both columns are of the same "length" the interpretation for varchar and nvarchar is quite different.
- Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.