sql基础
1、mysql基础命令
查看数据库:show databases;
查看数据库中的表:show tables;
显示表结构:description或者DESC users;
查看记录:select user,password from users where user_id=1;
2、 information_schema
-
TABLE_SCHEMA:数据库名
-
TABLE_NAME:表名
2.1 TABLES表
显示所有信息:select * from information_schema ;
查询数据库:select DISTINCT TABLE_SCHEMA from information_schema.TABLES ;
查询数据库和数据表:select TABLE_SCHEMA ,GROUP_CONCAT(TABLE_NAME) from information_schema.tables group by TABLE_SCHEMA \G
显示数据表:select TABLE_NAME from information_schema.tables where TABLE_SCHEMA='dvwa' ;
2.2 columns表
column_name:字段名
查询所有列:select * from information_schema.columns\G
查询某个库的某个表:select column_name from information_schema.columns where TABLE_SCHEMA ='dvwa' and TABLE_NAME ='users';
查询某个表:select column_name from information_schema.columns where TABLE_NAME ='SCHEMA_PRIVILEGES';
显示数据库的信息:select first_name,last_name from users where user_id =1 union select version(),database()
select first_name,last_name from users where user_id =1 union select user(),database();