MySQL nchar

MySQL nchar define the datatype nchar that stores fixed-length character data.

MySQL nchar

MySQL nchar

     

MySQL nchar define the datatype nchar that stores fixed-length character data. The data can be a string single-byte or multibyte letters, digits and symbols supported by the code set of the database locale.

Create table:

The Tutorial illustrate an example from 'MySQL nchar'. To understand and elaborate an example we create a table 'nchar' that has the required fieldnames and datatypes respectively.

mysql> CREATE TABLE nchar (
    ->      a int,
    ->      b nchar(24),
    ->      c nchar(40)
    ->  )
    -> ;
Query OK, 0 rows affected (0.06 sec)

Query for inserting data in the table:

The Query insert into is used to add the records or rows to the table 'nchar'.

mysql> insert into nchar
    -> values
    -> (1,'G','T'),
    -> (2,'K','S');
Query OK, 2 rows affected (0.03 sec)
Records: 2  Duplicates: 0 Warnings: 0

Query for viewing data of the table:

mysql> select * from nchar;
+------+------+------+
| a    | b    | c    |
+------+------+------+
|    1 | G    | T    |
|    2 | K    | S    |
+------+------+------+
2 rows in set (0.00 sec)

Query for describing data of the table:

The Query desc is used to show the Field, Type, Null etc property of a table nchar.

mysql> desc nchar;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| a     | int(11)  | YES  |     | NULL    |       |
| b     | char(24) | YES  |     | NULL    |       |
| c     | char(40) | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.01 sec)