mysql语句如何批量去掉内容里的图片?
UPDATE table_name SET content = REGEXP_REPLACE(content, '<img[^>]*>', '') WHERE condition;
UPDATE table_name SET content = REGEXP_REPLACE(content, '<img[^>]*>', '') WHERE condition;
show databases; show tables; use mysql; 显示库里有多少表 运行命令 mysql -u 数据库用户名 -p 连接数据库 运行命令 use 数据库名 进入需要导入数据的数据库 运行命令 source /home/backup/database/1.sql 开始导入数据 很简单.好用.亲测过.. 看不懂的可以加我qq
方法1: truncate table 你的表名 //这样不但将数据全部删除,而且重新定位自增的字段 方法2: delete from 你的表名 dbcc checkident(你的表名,reseed,0) //重新定位自增的字段,让它从1开始 方法3: 如果你要保存你的数据,介绍你第三种方法,by QINYI 用phpmyadmin导出数据库,你在里面会有发现哦 编辑sql文件,将其中的自增下一个id号改好,再导入。
#coding:utf-8 #python生成sitemap,超过1万条数据自动生成新文件。 #from __future__ import division # import os,datetime import sys import pymysql.cursors reload(sys) sys.setdefaultencoding('utf-8') hosts = '域名/' dir = os.popen('mkdir /data/wwwroot/forwei/www/sitemaps') path = '/data/wwwroot/forwei/www/sitemaps/' paths = 'sitemaps/' lastmod = datetime.date.today() connection = pymysql.connect(host="127.0.0.1",user="用户名",password="密码",db="表名") sql = 'SELECT classpath FROM phome_enewsclass union select ztpath from phome_enewszt union SELECT titleurl FROM phome_ecms_news' try: with connection.cursor() as cursor: cursor.execute(sql) cnm = cursor.fetchall() pan = open('urls.txt',"w") #hu = open('mobile_url.txt',"w") for i in cnm: for item in i: if len(item) > 2: if item[0] == "/" : pan.write("域名/%s\n" % item[1:]) #hu.write("域名/%s\n" % item[1:]) else: if item[0] != "/": pan.write("域名/%s\n" % item) #hu.write("移动端/%s\n" % item) pan.close() #hu.close() cursor.close() finally: connection.close() def add_file(j,f1,hosts,paths): file_name = 'sitemap_%s.xml'%(j) f1.write("\n<sitemap>\n<loc>%s%s%s</loc>\n<lastmod>%s</lastmod>\n<priority>0.8</priority>\n</sitemap>"%(hosts,paths,file_name,lastmod)) f=open("%s%s"%(path,file_name),"w") f.write('<?xml version="1.0" encoding="utf-8"?>\n<urlset>') return f #判断总的URL数 c = 0...