gpt4 book ai didi

mysql - 如何一次删除 taggregate_temp_ 表?

转载 作者:行者123 更新时间:2023-11-30 00:11:28 25 4
gpt4 key购买 nike

在我的 SQL 中,我有多个表,例如:


taggregate_temp_1364792160
taggregate_temp_1364795760
taggregate_temp_1364799360
taggregate_temp_1364802960
taggregate_temp_1364806560
taggregate_temp_1364810160
taggregate_temp_1364813760
taggregate_temp_1364817360
taggregate_temp_1364820960
taggregate_temp_1364824560
taggregate_temp_1364828160
taggregate_temp_1364831760
taggregate_temp_1364835360
taggregate_temp_1364838960
taggregate_temp_1364842560
taggregate_temp_1364846160
taggregate_temp_1364849760
taggregate_temp_1364853360

我需要立即删除所有以 taggregate_temp_ 开头的表
你能帮我一下吗?

最佳答案

此问题已由另一位用户回答:Drop all tables whose names begin with a certain string

你会想做类似的事情

USE DATABASE_NAME
GO

declare @cmd varchar(4000)
declare cmds cursor for

select 'DROP TABLE [' + Table_Name + ']'
from INFORMATION_SCHEMA.TABLES
where Table_Name like 'taggregate_temp_%'

open cmds
while 1=1
begin
fetch cmds into @cmd
if @@fetch_status != 0 break
exec(@cmd)
end
close cmds;
deallocate cmds

编辑:您在问题中没有提到 mysql,但我只是看到了标签,请查看以下主题的 mysql 示例:MySQL bulk drop table where table like?

关于mysql - 如何一次删除 taggregate_temp_ 表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24004748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com