查库:select schema_name from information_schema.schemata;
查表:select table_name from information_schema.tables where table_schema='security';
查列:select column_name from information_schema.columns where table_name='users';
查字段:select username,password from security.users;
基本函数
left() 函数
left(a,b) 从左侧截取a的前b位,正确返回1,错误返回0
mysql> select left(database(),3)='s'; // 截取前三位,但是右边就只有一位
+------------------------+
| left(database(),3)='s' |
+------------------------+
| 0 | // 错误
+------------------------+
1 row in set (0.00 sec)
mysql> select left(database(),3)='sec';
+--------------------------+
| left(database(),3)='sec' |
+--------------------------+
| 1 |
+--------------------------+
1 row in set (0.00 sec)
mysql> select left(database(),1)='s';
+------------------------+
| left(database(),1)='s' |
+------------------------+
| 1 |
+------------------------+
1 row in set (0.00 sec)