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"


- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- SQL 临时表问题 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01