Home Sql Mysql-example MySQL nchar



MySQL nchar
Posted on: January 24, 2009 at 12:00 AM
MySQL nchar define the datatype nchar that stores fixed-length character data.

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)

Related Tags for MySQL nchar:
sqlmysqlcdatabasestringgitdatatypecharportlocalebytesetsupportlengthsymbolscharactertablocaldefinectetodatatypebasestoresinglesymbolfixedeitmultirtelscanulpeincalasmmultibytetrcaletletteresdigitsdigaselocpptorsxesuatracmyhaandaractcodcodestrrtttssriringthbolstabhatfixfinlettersndncharodeolo


More Tutorials from this section

Ask Questions?    Discuss: MySQL nchar  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.