Define and use varchar : Varchar : Data Type SQL / MySQL


SQL / MySQL » Data Type » Varchar »

 

Define and use varchar



/*
mysql> Drop table Product;

mysql> CREATE TABLE Product
    -> (
    ->    ID SMALLINT NOT NULL PRIMARY KEY,
    ->    Color VARCHAR(15) NOT NULL
    -> );
Query OK, 0 rows affected (0.07 sec)

mysql> INSERT INTO Product VALUES (101, 'Red'),
    ->                                  (102, 'red'),
    ->                                  (103, 'RED'),
    ->                                  (104, 'REd'),
    ->                                  (105, 'reD'),
    ->                                  (106, 'Blue'),
    ->                                  (107, 'blue'),
    ->                                  (108, 'BLUE'),
    ->                                  (109, 'BLue'),
    ->                                  (110, 'blUE');
Query OK, 10 rows affected (0.01 sec)
Records: 10  Duplicates: 0  Warnings: 0

mysql> select * from Product;
+-----+-------+
| ID  | Color |
+-----+-------+
| 101 | Red   |
| 102 | red   |
| 103 | RED   |
| 104 | REd   |
| 105 | reD   |
| 106 | Blue  |
| 107 | blue  |
| 108 | BLUE  |
| 109 | BLue  |
| 110 | blUE  |
+-----+-------+
10 rows in set (0.00 sec)


*/

Drop table Product;

CREATE TABLE Product
(
   ID SMALLINT NOT NULL PRIMARY KEY,
   Color VARCHAR(15NOT NULL
);


INSERT INTO Product VALUES (101'Red'), 
                                 (102'red'), 
                                 (103'RED'), 
                                 (104'REd'), 
                                 (105'reD'),
                                 (106'Blue'), 
                                 (107'blue'), 
                                 (108'BLUE'), 
                                 (109'BLue'), 
                                 (110'blUE');
select from Product;
           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

SQL / MySQL

 Navioo Data Type
» Varchar