清空数据库所有数据

USE [数据库名]
DECLARE @Table VARCHAR(100)
DECLARE myCursor CURSOR FOR SELECT t.name FROM sys.tables t
OPEN myCursor
FETCH NEXT FROM myCursor INTO @Table
WHILE @@FETCH_STATUS=0
BEGIN
  
 EXEC(‘TRUNCATE TABLE ‘+@Table+‘‘)
 
 
 FETCH NEXT FROM myCursor INTO @Table
END
CLOSE myCursor
DEALLOCATE myCursor

适用情况:数据库表之间没有什么约束

有约束的没有测试

清空数据库所有数据,布布扣,bubuko.com

清空数据库所有数据

上一篇:oracle asm service can not find disks which are configured available when restart server


下一篇:Oracle 11G R2 RAC中的scan ip 的用途和基本原理