SQL批量修改表名

SELECT NAME FROM SYS. ALL_OBJECTS WHERE TYPE= 'U' ORDER BY MODIFY_DATE DESC --查询所有表名
SELECT NAME FROM SYS. ALL_OBJECTS WHERE TYPE= 'U'
AND name LIKE  '%\_0%' escape '\' AND name NOT LIKE '%_OLD'
ORDER BY MODIFY_DATE DESC
 
 
DECLARE @COUNT INT
)
)
) FROM SYS . ALL_OBJECTS WHERE TYPE= 'U' AND name LIKE '%_FOREX_%' --查询循环次数
BEGIN
       SELECT @NAME = name FROM SYS. ALL_OBJECTS WHERE TYPE= 'U' AND name LIKE '%_FOREX_%' --查询旧表名
       SELECT @RENAME = REPLACE( name ,'_FOREX_' , '_WH_' ) FROM SYS .ALL_OBJECTS WHERE TYPE = 'U' AND name LIKE '%_FOREX_%'  --查询新表名
       EXEC sp_rename @NAME, @RENAME; --修改表名
;
END
  
上一篇:PHP中的 !== 与 !=


下一篇:[LeetCode]Palindrome Partitioning 找出所有可能的组合回文