Home Database Mysql Tutorial 清空所有表中的数据的存储过程

清空所有表中的数据的存储过程

Jun 07, 2016 pm 06:00 PM
Clear

清空所有表中的数据的sql语句,需要的朋友可以参考下,利用了存储过程。

代码如下:
--*******************************************************
--* 清空所有表中的数据 *
--* 撒哈拉大森林 *
--* 2010-6-28 *
--*******************************************************

if exists (select * from sysobjects where type='P' and name=N'P_DeleteAllData' )
drop procedure P_DeleteAllData
go

CREATE PROCEDURE P_DeleteAllData
as
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' --禁用约束
EXEC sp_MSForEachTable 'ALTER TABLE ? DISABLE TRIGGER ALL' --禁用触发器
EXEC sp_MSForEachTable 'DELETE FROM ?' --删除所有表中的数据
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL' --启用约束
EXEC sp_MSForEachTable 'ALTER TABLE ? ENABLE TRIGGER ALL' --启用触发器
go

--执行存储过程
--exec P_DeleteAllData --执行
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to recover cleared browsing history How to recover cleared browsing history Feb 18, 2024 pm 10:05 PM

How to restore web page history after it has been cleared Date: June 10, 2022 Introduction: When we use computers or mobile phone browsers daily, we often use the browser's history to find web pages we have visited before. However, sometimes we may accidentally clear our browser history, causing us to be unable to retrieve a specific web page. In this article, I will tell you some ways to recover cleared web history. Method 1: Use the browser recovery function. Most common browsers provide the function of restoring history, such as Google

How to clear content on Weibo_Tutorial on clearing content on Weibo How to clear content on Weibo_Tutorial on clearing content on Weibo Mar 30, 2024 pm 05:51 PM

1. First open the Weibo APP and click My in the lower right corner. 2. Then enter the personal center interface and click Weibo in the upper left corner. 3. Finally, enter and delete Weibo messages one by one.

How to deal with desktop loss after KB4532693 update? How to deal with desktop loss after KB4532693 update? Dec 27, 2023 am 11:41 AM

When we use computers with the win10 operating system, sometimes if a problem occurs, we will definitely choose to update the system patch. So for the situation where the desktop clears after the KB4532693 update is installed, the editor thinks that the new patch may not be stable enough, so there is still a probability that problems will occur when using it. We can try to uninstall the patch first. Let’s take a look at the detailed steps to see how the editor did it~ What to do if the desktop is cleared after the KB4532693 update? 1. Microsoft will start pushing the Windows 10 KB4532693 security patch on February 11. 2. The system version number will be updated to 18363.657, but recently some netizens discovered , 3. Installing this update will cause new system problems, Wind

How to clear the draft box on Weibo_Tutorial on clearing the draft box on Weibo How to clear the draft box on Weibo_Tutorial on clearing the draft box on Weibo Mar 30, 2024 pm 08:31 PM

1. Open the Sina Weibo app and enter [Me] in the lower right corner. 2. After entering, you can see the draft box at the top of the page, and then click to open it. 3. After entering, long press the draft work you want to delete, and the two options of [Delete Draft] and [Clear Draft Box] will appear. 4. Click [Clear Draft Box].

How to clear the questions that have been done in the Chalk App How to clear the questions that have been done in the Chalk App How to clear the questions that have been done in the Chalk App How to clear the questions that have been done in the Chalk App Mar 12, 2024 pm 01:43 PM

How to clear the questions that have been done in the Chalk App? The Chalk App is a software that allows users to do questions directly. This software also has many video lessons and handouts. Users can choose to download the videos and handouts they need when there is wifi, so that we can You can watch it without consuming data while waiting for the bus or on the bus. Some users have done some questions on this, and then want to clear the question records. The editor below has compiled methods for clearing the question records for your reference. How to clear the completed questions in the Chalk App? The Chalk App and the web page do not provide the function of clearing the completed questions. If you want to re-do the completed questions, you need to register a new account to use it. In Chalk APP, all

How to recover files if you accidentally emptied the Recycle Bin How to recover files if you accidentally emptied the Recycle Bin Feb 21, 2024 pm 06:45 PM

How to recover files after accidentally emptying the Recycle Bin When we use files on the computer, we often encounter some unexpected situations, such as accidentally emptying the Recycle Bin, causing important files to be deleted. At this time, many people may feel panicked and wonder how to recover deleted files. But in fact, with the help of the right methods and tools, we still have a chance to recover these important files. This article will introduce you to some methods and tools to help you recover files in the Recycle Bin that you accidentally emptied. First of all, what we need to understand is that

How to clear deleted email records in QQ mailbox How to clear deleted email records in QQ mailbox Mar 20, 2024 pm 09:26 PM

As an important tool for our daily sending and receiving emails, QQ mailbox provides us with a convenient way of communication. In daily use, we usually delete read or spam emails, but simple deletion cannot completely remove them, so in order to save space and keep the mailbox tidy, it is a good habit to empty the deleted emails. So users who want to completely delete these emails should follow this article to learn more! How to clear deleted emails in QQ mailbox 1. First, click to open QQ mailbox, scroll down the page and find the deleted option. 2. Then click to enter the page and select the edit button in the upper right corner. 3. Then select Clear from the options that pop up at the bottom. 4. Finally confirm and click Clear 1

Find the player with the fewest number of zeros after emptying a binary string (by removing non-empty substrings) Find the player with the fewest number of zeros after emptying a binary string (by removing non-empty substrings) Sep 16, 2023 am 10:21 AM

In this article, we will discuss an interesting problem related to the field of string manipulation and game theory: "Empty a binary string by removing non-empty substrings and find the player with the fewest remaining zeros". This question explores the concept of using binary strings for competitive gaming. Our goal is to find the player with the fewest 0 remaining at the end of the game. We will discuss this issue, provide a C++ code implementation, and explain the concept through an example. Understanding the problem statement Two players are given a binary string and they take turns playing the game. On each turn, the player removes non-empty substrings that contain at least one "1". The game ends when the string becomes empty or there is no "1" in the string. Players unable to take action lose the game. The task is to find the final 0

See all articles