MySQL Functions
mysql> select cos(0);
+--------+
| cos(0) |
+--------+
| 1 |
+--------+
1 row in set (0.00 sec)
mysql> select user();
+------------------+
| user() |
+------------------+
| yzhang@localhost |
+------------------+
1 row in set (0.00 sec)
mysql> select current_date();
+----------------+
| current_date() |
+----------------+
| 2014-09-25 |
+----------------+
1 row in set (0.00 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2014-09-25 16:53:04 |
+---------------------+
1 row in set (0.00 sec)
mysql> select database();
+------------+
| database() |
+------------+
| ZHANG |
+------------+
1 row in set (0.00 sec)
mysql> select hex(30)
-> ;
+---------+
| hex(30) |
+---------+
| 1E |
+---------+
1 row in set (0.00 sec)
mysql> select bin(30)
-> ;
+---------+
| bin(30) |
+---------+
| 11110 |
+---------+
1 row in set (0.00 sec)
mysql> select password('csc1310');
+-------------------------------------------+
| password('csc1310') |
+-------------------------------------------+
| *8D1BC0FA3627E999F121F9B874E674452EBAB099 |
+-------------------------------------------+
1 row in set (0.00 sec)
mysql> select PI();
+----------+
| PI() |
+----------+
| 3.141593 |
+----------+
1 row in set (0.00 sec)
mysql> select POW(2, 3);
+-----------+
| POW(2, 3) |
+-----------+
| 8 |
+-----------+
1 row in set (0.00 sec)
mysql> select RAND();
+--------------------+
| RAND() |
+--------------------+
| 0.6599327397159606 |
+--------------------+
1 row in set (0.00 sec)
mysql> select RAND(3);
+--------------------+
| RAND(3) |
+--------------------+
| 0.9057697559760601 |
+--------------------+
1 row in set (0.00 sec)
mysql> select RAND(3);
+--------------------+
| RAND(3) |
+--------------------+
| 0.9057697559760601 |
+--------------------+
1 row in set (0.00 sec)
mysql> select last_insert_id();
+------------------+
| last_insert_id() |
+------------------+
| 0 |
+------------------+
1 row in set (0.01 sec)
Data Types
TINYINT
SMALLINT
INT
BIGINT
DECIMAL(9, 2) //1239.78
FLOAT
DOUBLE
CHAR(size)//right padding with spaces
LONGTEXT(size)
TEXT 0-65,535
VARCHAR(size)
DATE 2001-12-21
DATETIME YYYY- MM- DD hh: mm: ss ( 2001- 01- 01 01: 00: 00)
TIME
TIMESTAMP
YYYY- MM- DD hh: mm: ss ( 2001- 01- 01 01: 00: 00)