MySQL转换NVARCHAR()为VARCHAR()。NVARCHAR在MySQL中代表National Varchar。让我们首先创建一个表,其中“ StudentName”列之一为NVARCHAR-mysql> create table DemoTable
(
StudentName NVARCHAR(40),
StudentCountryName VARCHAR(50)
);
让我们检查表的描述-mysql> desc DemoTable;
这将产生以下输出。如下所示,在MySQL中,具有NVARCHAR类型的StudentName列会自动转换为VARCHAR-+--------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+-------------+------+-----+---------+-------+
| StudentName | varchar(40) | YES | | NULL | |
| StudentCountryName | varchar(50) | YES | | NULL | |
+--------------------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
使用插入命令在表中插入一些记录-mysql> insert into DemoTable values('Chris','US');
mysql> insert into DemoTable values('Tom','UK');
mysql> insert into DemoTable values('David','AUS');
使用select语句显示表中的所有记录-mysql> select *from DemoTable;
这将产生以下输出-+-------------+--------------------+
| StudentName | StudentCountryName |
+-------------+--------------------+
| Chris | US |
| Tom | UK |
| David | AUS |
+-------------+--------------------+
3 rows in set (0.00 sec)