Preserving Trailing Spaces in String Columns : LENGTH « String « SQL / MySQL






Preserving Trailing Spaces in String Columns

       
mysql>
mysql> CREATE TABLE t (c VARCHAR(255));
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t (c) VALUES('abc ');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT c, LENGTH(c) FROM t;
+------+-----------+
| c    | LENGTH(c) |
+------+-----------+
| abc  |         4 |
+------+-----------+
1 row in set (0.00 sec)

mysql>
mysql>
mysql> DROP TABLE t;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>
mysql> CREATE TABLE t (c TEXT);
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO t (c) VALUES('abc ');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT c, LENGTH(c) FROM t;
+------+-----------+
| c    | LENGTH(c) |
+------+-----------+
| abc  |         4 |
+------+-----------+
1 row in set (0.00 sec)

mysql>
mysql> drop table t;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
    
    
    
  








Related examples in the same category

1.LENGTH Function
2.LENGTH(RTRIM(SPACE(8)))
3.LENGTH(CONCAT(CAST(100000 AS CHAR(6)),'000'))
4.Length of trimmed varchar value
5.The length of the shortest verse in the King James Version, that's easy to find
6.Get cases name and length in the production dept
7.Determine how many bytes are necessary for storing the data.
8.Lists names from the names table with the longest names first