Search amp; replace #39;http#39; to #39;https#39; in database(搜索amp;将数据库中的“http替换为“https)
问题描述
使用 phpmyadmin,我想运行一个查询来搜索我的整个数据库:
Using phpmyadmin, I want to run a query that will search my entire database for:
http://example.com
并替换为:
https://example.com
我的 SQL 知识有限,大概是这样的:
My SQL knowledge is limited, maybe something like:
UPDATE ?? = REPLACE(??, 'http://example.com', 'https://example.com');
数据库超过 1GB,所以我可以运行什么不会使服务器崩溃.
The database is over 1gb, so what can I run that will not crash the server.
更新:请注意,虽然在 SO 上发布了其他有关搜索和替换的答案,但它们似乎并未涵盖整个数据库.
Update: Note that while there are other answers posted here on SO that deals with search and replace, they don't seem to cover the entire database.
推荐答案
使用 REPLACE.如果字段上有索引,则 UPDATE 可以使用它们
use REPLACE. and if there is a index on the field then the UPDATE can use them
UPDATE t
set url = REPLACE(url, 'http:', 'https:')
WHERE url LIKE '%http:%';
只更改example.com
这只会找到带有 'http://example.com' 的行
this will only find row with 'http://example.com'
UPDATE t
set url = REPLACE(url, 'http:', 'https:')
WHERE url LIKE '%http://example.com%';
或者这会找到所有带有 http://的行,但只将这个 http://example.com 更改为https://example.com
or this will find all rows with http:// but only change only this http://example.com to https://example.com
UPDATE t
set url = REPLACE(url, 'http://example.com', 'https://example.com')
WHERE url LIKE '%http:%';
这篇关于搜索&将数据库中的“http"替换为“https"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:搜索&将数据库中的“http"替换为“https"
基础教程推荐
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 无法解决整理冲突 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
