<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>drop table &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/drop-table/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Tue, 03 Apr 2018 20:28:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>PostgreSQL: How to drop all Tables?</title>
		<link>https://www.dbrnd.com/2018/04/postgresql-how-to-drop-all-tables/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 04 Apr 2018 16:16:36 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[DROP ALL TABLES]]></category>
		<category><![CDATA[drop table]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7328</guid>

					<description><![CDATA[How to drop all tables in PostgreSQL? Recently, One of the SQL Server users asked me this question for PostgreSQL. Because in the SQL Server we can do this kind of bulk DDL operations using sp_MSforeachtable. SQL Server: Use sp_MSforeachtable to apply a T-SQL command to every table of current Database In the PostgreSQL, no [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-how-to-drop-all-tables%2F&amp;linkname=PostgreSQL%3A%20How%20to%20drop%20all%20Tables%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-how-to-drop-all-tables%2F&amp;linkname=PostgreSQL%3A%20How%20to%20drop%20all%20Tables%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-how-to-drop-all-tables%2F&amp;linkname=PostgreSQL%3A%20How%20to%20drop%20all%20Tables%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-how-to-drop-all-tables%2F&amp;linkname=PostgreSQL%3A%20How%20to%20drop%20all%20Tables%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-how-to-drop-all-tables%2F&amp;linkname=PostgreSQL%3A%20How%20to%20drop%20all%20Tables%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-how-to-drop-all-tables%2F&amp;linkname=PostgreSQL%3A%20How%20to%20drop%20all%20Tables%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-how-to-drop-all-tables%2F&#038;title=PostgreSQL%3A%20How%20to%20drop%20all%20Tables%3F" data-a2a-url="https://www.dbrnd.com/2018/04/postgresql-how-to-drop-all-tables/" data-a2a-title="PostgreSQL: How to drop all Tables?"></a></p><p>How to drop all tables in PostgreSQL?<br />
Recently, One of the SQL Server users asked me this question for PostgreSQL.</p>
<p>Because in the SQL Server we can do this kind of bulk DDL operations using sp_MSforeachtable. </p>
<blockquote class="wp-embedded-content" data-secret="4cckJWl8k1"><p><a href="https://www.dbrnd.com/2017/09/sql-server-use-sp_msforeachtable-to-apply-a-t-sql-command-to-every-table-of-current-database/">SQL Server: Use sp_MSforeachtable to apply a T-SQL command to every table of current Database</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2017/09/sql-server-use-sp_msforeachtable-to-apply-a-t-sql-command-to-every-table-of-current-database/embed/#?secret=4cckJWl8k1" data-secret="4cckJWl8k1" width="600" height="338" title="&#8220;SQL Server: Use sp_MSforeachtable to apply a T-SQL command to every table of current Database&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>In the PostgreSQL, no such functionality is available. But I am sharing two options for dropping all tables of schema or database of PostgreSQL. </p>
<p><strong>If you want to drop all tables of a schema, simply drop the schema.</strong></p>
<pre class="crayon-plain-tag">DROP SCHEMA schema_name CASCADE;</pre> </p>
<p><strong>Use pg_tables and prepare DROP TABLE script:</strong><br />
In the below script, you can modify the table/schema filter. Once you execute the below script, you can get a result of generated DROP SCRIPT which you can execute for dropping tables. </p>
<pre class="crayon-plain-tag">select 'drop table if exists "' || tablename || '" cascade;' 
from pg_tables
where schemaname = 'public';</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server 2016: Drop table operation failed on table because it is not supported operation on system-versioned temporal tables</title>
		<link>https://www.dbrnd.com/2018/03/sql-server-2016-drop-table-operation-failed-on-table-because-it-is-not-supported-operation-on-system-versioned-temporal-tables/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 06 Mar 2018 16:16:09 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[drop table]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server 2014]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[System-versioned]]></category>
		<category><![CDATA[system-versioned temporal table]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4272</guid>

					<description><![CDATA[In the previous post, I shared basic about SQL Server 2016 System-versioned temporal tables and how you can create it. In the previous post, I created a tbl_Studetns table and now for testing, I am going to drop it here. [crayon-6ab55d952f886165027756/] But unfortunately, I got the below error. [crayon-6ab55d952f888666883578/] The reason is, it is a [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-2016-drop-table-operation-failed-on-table-because-it-is-not-supported-operation-on-system-versioned-temporal-tables%2F&amp;linkname=SQL%20Server%202016%3A%20Drop%20table%20operation%20failed%20on%20table%20because%20it%20is%20not%20supported%20operation%20on%20system-versioned%20temporal%20tables" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-2016-drop-table-operation-failed-on-table-because-it-is-not-supported-operation-on-system-versioned-temporal-tables%2F&amp;linkname=SQL%20Server%202016%3A%20Drop%20table%20operation%20failed%20on%20table%20because%20it%20is%20not%20supported%20operation%20on%20system-versioned%20temporal%20tables" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-2016-drop-table-operation-failed-on-table-because-it-is-not-supported-operation-on-system-versioned-temporal-tables%2F&amp;linkname=SQL%20Server%202016%3A%20Drop%20table%20operation%20failed%20on%20table%20because%20it%20is%20not%20supported%20operation%20on%20system-versioned%20temporal%20tables" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-2016-drop-table-operation-failed-on-table-because-it-is-not-supported-operation-on-system-versioned-temporal-tables%2F&amp;linkname=SQL%20Server%202016%3A%20Drop%20table%20operation%20failed%20on%20table%20because%20it%20is%20not%20supported%20operation%20on%20system-versioned%20temporal%20tables" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-2016-drop-table-operation-failed-on-table-because-it-is-not-supported-operation-on-system-versioned-temporal-tables%2F&amp;linkname=SQL%20Server%202016%3A%20Drop%20table%20operation%20failed%20on%20table%20because%20it%20is%20not%20supported%20operation%20on%20system-versioned%20temporal%20tables" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-2016-drop-table-operation-failed-on-table-because-it-is-not-supported-operation-on-system-versioned-temporal-tables%2F&amp;linkname=SQL%20Server%202016%3A%20Drop%20table%20operation%20failed%20on%20table%20because%20it%20is%20not%20supported%20operation%20on%20system-versioned%20temporal%20tables" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fsql-server-2016-drop-table-operation-failed-on-table-because-it-is-not-supported-operation-on-system-versioned-temporal-tables%2F&#038;title=SQL%20Server%202016%3A%20Drop%20table%20operation%20failed%20on%20table%20because%20it%20is%20not%20supported%20operation%20on%20system-versioned%20temporal%20tables" data-a2a-url="https://www.dbrnd.com/2018/03/sql-server-2016-drop-table-operation-failed-on-table-because-it-is-not-supported-operation-on-system-versioned-temporal-tables/" data-a2a-title="SQL Server 2016: Drop table operation failed on table because it is not supported operation on system-versioned temporal tables"></a></p><p>In the previous post, I shared basic about SQL Server 2016 System-versioned temporal tables and how you can create it. </p>
<p>In the previous post, I created a tbl_Studetns table and now for testing, I am going to drop it here. </p>
<pre class="crayon-plain-tag">DROP TABLE tbl_Students
GO</pre> </p>
<p>But unfortunately, I got the below error.</p>
<pre class="crayon-plain-tag">Msg 13552, Level 16, State 1, Line 1
Drop table operation failed on table 'RND.dbo.tbl_Students' because it is not supported operation on system-versioned temporal tables.</pre> </p>
<p>The reason is, it is a system-versioned table and its dependent object is tbl_StudentsHistory table. </p>
<p>The solution is to disable system-versioned on that table by executing following statement.</p>
<pre class="crayon-plain-tag">ALTER TABLE dbo.tbl_Students SET (SYSTEM_VERSIONING = OFF)</pre> </p>
<p>Now, you can drop the tbl_Students table. </p>
<p><strong>Please note:</strong><br />
We disabled the System-versioned so it will not drop a tbl_StudentsHistory table. If you want to tbl_StudentsHistory, you can use drop command to drop it. </p>
<pre class="crayon-plain-tag">DROP TABLE tbl_StudentsHistory
GO</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Script to Drop a Table from all Databases</title>
		<link>https://www.dbrnd.com/2018/02/sql-server-script-to-drop-a-table-from-all-databases/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 23 Feb 2018 16:16:47 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[drop table]]></category>
		<category><![CDATA[sp_MSforeachdb]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7135</guid>

					<description><![CDATA[In this post, I am sharing a script for dropping a table from all databases of SQL Server. We are creating different versions of the database in our environment. Recently, I found some test/temp tables which are replicated in all versions databases. In this case, you can use below script and drop those tables from [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fsql-server-script-to-drop-a-table-from-all-databases%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20Drop%20a%20Table%20from%20all%20Databases" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fsql-server-script-to-drop-a-table-from-all-databases%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20Drop%20a%20Table%20from%20all%20Databases" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fsql-server-script-to-drop-a-table-from-all-databases%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20Drop%20a%20Table%20from%20all%20Databases" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fsql-server-script-to-drop-a-table-from-all-databases%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20Drop%20a%20Table%20from%20all%20Databases" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fsql-server-script-to-drop-a-table-from-all-databases%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20Drop%20a%20Table%20from%20all%20Databases" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fsql-server-script-to-drop-a-table-from-all-databases%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20Drop%20a%20Table%20from%20all%20Databases" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fsql-server-script-to-drop-a-table-from-all-databases%2F&#038;title=SQL%20Server%3A%20Script%20to%20Drop%20a%20Table%20from%20all%20Databases" data-a2a-url="https://www.dbrnd.com/2018/02/sql-server-script-to-drop-a-table-from-all-databases/" data-a2a-title="SQL Server: Script to Drop a Table from all Databases"></a></p><p>In this post, I am sharing a script for dropping a table from all databases of SQL Server. </p>
<p>We are creating different versions of the database in our environment. Recently, I found some test/temp tables which are replicated in all versions databases. </p>
<p>In this case, you can use below script and drop those tables from all the databases. As per your requirement, you can add more option in a dynamic query. </p>
<p><strong>Use sp_MSforeachdb, and execute a command in all databases:</strong></p>
<pre class="crayon-plain-tag">exec sp_MSforeachdb
'use [?]
drop table table_name'</pre> </p>
<blockquote class="wp-embedded-content" data-secret="mPSCVlcu7Q"><p><a href="https://www.dbrnd.com/2016/12/sql-server-who-dropped-a-table-and-which-table-has-been-dropped/">SQL Server: Who dropped a Table and Which Table has been dropped</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/12/sql-server-who-dropped-a-table-and-which-table-has-been-dropped/embed/#?secret=mPSCVlcu7Q" data-secret="mPSCVlcu7Q" width="600" height="338" title="&#8220;SQL Server: Who dropped a Table and Which Table has been dropped&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote class="wp-embedded-content" data-secret="u0VWljOJ2q"><p><a href="https://www.dbrnd.com/2017/05/sql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog/">SQL Server: Who dropped a table, find out from Transaction Log</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2017/05/sql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog/embed/#?secret=u0VWljOJ2q" data-secret="u0VWljOJ2q" width="600" height="338" title="&#8220;SQL Server: Who dropped a table, find out from Transaction Log&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PostgreSQL: Log the DROP TABLE Statement</title>
		<link>https://www.dbrnd.com/2017/12/postgresql-log-the-drop-table-statement/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 30 Dec 2017 16:16:15 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[drop table]]></category>
		<category><![CDATA[log_line_prefix]]></category>
		<category><![CDATA[log_statement]]></category>
		<category><![CDATA[logging_collector]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6850</guid>

					<description><![CDATA[How to log the DROP TABLE Statement in the log file of PostgreSQL? Above is a common question/suggestion by the PostgreSQL DBA. We should log all the type of statements like DDL, DML. But DDL is most important than DML logging. For logging the DDL statement into log files, we should change the following parameters [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-log-the-drop-table-statement%2F&amp;linkname=PostgreSQL%3A%20Log%20the%20DROP%20TABLE%20Statement" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-log-the-drop-table-statement%2F&amp;linkname=PostgreSQL%3A%20Log%20the%20DROP%20TABLE%20Statement" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-log-the-drop-table-statement%2F&amp;linkname=PostgreSQL%3A%20Log%20the%20DROP%20TABLE%20Statement" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-log-the-drop-table-statement%2F&amp;linkname=PostgreSQL%3A%20Log%20the%20DROP%20TABLE%20Statement" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-log-the-drop-table-statement%2F&amp;linkname=PostgreSQL%3A%20Log%20the%20DROP%20TABLE%20Statement" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-log-the-drop-table-statement%2F&amp;linkname=PostgreSQL%3A%20Log%20the%20DROP%20TABLE%20Statement" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F12%2Fpostgresql-log-the-drop-table-statement%2F&#038;title=PostgreSQL%3A%20Log%20the%20DROP%20TABLE%20Statement" data-a2a-url="https://www.dbrnd.com/2017/12/postgresql-log-the-drop-table-statement/" data-a2a-title="PostgreSQL: Log the DROP TABLE Statement"></a></p><p><strong>How to log the DROP TABLE Statement in the log file of PostgreSQL?</strong></p>
<p>Above is a common question/suggestion by the PostgreSQL DBA. We should log all the type of statements like DDL, DML. But DDL is most important than DML logging. </p>
<p>For logging the DDL statement into log files, we should change the following parameters in the postgresql.conf file. </p>
<blockquote><p>log_statement=&#8217;ddl&#8217;<br />
log_line_prefix = ‘%t %c %u ‘ (time, sessionid, user)<br />
logging_collector = ON</p></blockquote>
<p><strong>For example:</strong><br />
I dropped a tbl_student table. Now, I can see below the line in my log file.</p>
<pre class="crayon-plain-tag">2017-12-08 16:23:12 CET LOG:  statement: DROP TABLE tbl_student;</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Who dropped a table, find out from Transaction Log</title>
		<link>https://www.dbrnd.com/2017/05/sql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 24 May 2017 16:16:56 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[drop table]]></category>
		<category><![CDATA[fn_dblog()]]></category>
		<category><![CDATA[object security]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[transaction log]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5288</guid>

					<description><![CDATA[<div><img width="600" height="600" src="https://www.dbrnd.com/wp-content/uploads/2017/05/DropTableDatabase.png" class="attachment-post-image size-post-image wp-post-image" alt="DropTableDatabase" decoding="async" loading="lazy" srcset="https://www.dbrnd.com/wp-content/uploads/2017/05/DropTableDatabase.png 600w, https://www.dbrnd.com/wp-content/uploads/2017/05/DropTableDatabase-150x150.png 150w, https://www.dbrnd.com/wp-content/uploads/2017/05/DropTableDatabase-300x300.png 300w, https://www.dbrnd.com/wp-content/uploads/2017/05/DropTableDatabase-65x65.png 65w" sizes="auto, (max-width: 600px) 100vw, 600px" /></div>In this post, I am sharing few steps to find out the transactions history for drop commands which executed in SQL Server. There are many features for auditing and check the logging in SQL Server, but you can also directly read the transaction log and can get the necessary details. Please check the below full [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="600" height="600" src="https://www.dbrnd.com/wp-content/uploads/2017/05/DropTableDatabase.png" class="attachment-post-image size-post-image wp-post-image" alt="DropTableDatabase" decoding="async" loading="lazy" srcset="https://www.dbrnd.com/wp-content/uploads/2017/05/DropTableDatabase.png 600w, https://www.dbrnd.com/wp-content/uploads/2017/05/DropTableDatabase-150x150.png 150w, https://www.dbrnd.com/wp-content/uploads/2017/05/DropTableDatabase-300x300.png 300w, https://www.dbrnd.com/wp-content/uploads/2017/05/DropTableDatabase-65x65.png 65w" sizes="auto, (max-width: 600px) 100vw, 600px" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fsql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20table%2C%20find%20out%20from%20Transaction%20Log" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fsql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20table%2C%20find%20out%20from%20Transaction%20Log" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fsql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20table%2C%20find%20out%20from%20Transaction%20Log" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fsql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20table%2C%20find%20out%20from%20Transaction%20Log" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fsql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20table%2C%20find%20out%20from%20Transaction%20Log" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fsql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20table%2C%20find%20out%20from%20Transaction%20Log" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fsql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog%2F&#038;title=SQL%20Server%3A%20Who%20dropped%20a%20table%2C%20find%20out%20from%20Transaction%20Log" data-a2a-url="https://www.dbrnd.com/2017/05/sql-server-who-dropped-a-table-find-out-from-transaction-log-fn_dblog/" data-a2a-title="SQL Server: Who dropped a table, find out from Transaction Log"></a></p><p>In this post, I am sharing few steps to find out the transactions history for drop commands which executed in SQL Server.</p>
<p>There are many features for auditing and check the logging in SQL Server, but you can also directly read the transaction log and can get the necessary details.</p>
<p><strong>Please check the below full demonstration of this:</strong></p>
<p><strong>Create a sample database and use it:</strong><br />
<pre class="crayon-plain-tag">CREATE DATABASE Drop_Test
GO
USE Drop_Test
GO</pre>
<strong>Create a sample table:</strong><br />
<pre class="crayon-plain-tag">CREATE TABLE tbl_Test (ID INT)
GO</pre>
<strong>Check the object id of table and save it:</strong><br />
<pre class="crayon-plain-tag">SELECT OBJECT_ID ('tbl_Test')
GO

--tbl_Test object id: 581577110</pre>
<strong>Now, drop the table:</strong><br />
<pre class="crayon-plain-tag">DROP TABLE tbl_Test
GO</pre>
<strong>Check the transaction id and user of that drop action:</strong><br />
Using below query, you can find only transaction id and username who dropped the objects. Later, you can use a transaction to know which object has been dropped.<br />
<pre class="crayon-plain-tag">SELECT [Transaction Id], [Begin Time], SUSER_SNAME ([Transaction SID]) AS [User]
FROM fn_dblog (NULL, NULL)
WHERE [Transaction Name] = 'DROPOBJ'
GO

-- The Result:
/*
Transaction Id Begin Time User
-------------- ------------------------ ---------
0000:00000335 2017/04/25 17:53:41:187 Anvesh
*/</pre>
<strong>Find out which object has been dropped:</strong><br />
Use above transaction id and see the details of dropped object.<br />
<pre class="crayon-plain-tag">SELECT [Transaction Id], [Begin Time], SUSER_SNAME ([Transaction SID]) AS [User]
FROM fn_dblog (NULL, NULL)
WHERE [Transaction Name] = 'DROPOBJ'
GO

-- The Result:
/*
Transaction Id Begin Time User
-------------- ------------------------ ---------
0000:00000335 2017/04/25 17:53:41:187 Anvesh
*/</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Who dropped a Table and Which Table has been dropped</title>
		<link>https://www.dbrnd.com/2016/12/sql-server-who-dropped-a-table-and-which-table-has-been-dropped/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 12 Dec 2016 20:14:17 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Audit]]></category>
		<category><![CDATA[CDC]]></category>
		<category><![CDATA[Change data capture]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[DDL Trii]]></category>
		<category><![CDATA[drop]]></category>
		<category><![CDATA[drop table]]></category>
		<category><![CDATA[fn_dblog()]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[transaction log]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4063</guid>

					<description><![CDATA[SQL Server provides different types of database auditing option like: CDC, Database Audit. Recently, I have shared one article about, change your database DDL changes using Encrypted DDL triggers. SQL Server: Encrypted DDL Trigger to Track all Database Changes Database Administrators are responsible for database security and Periodically, They have to track all the database [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-who-dropped-a-table-and-which-table-has-been-dropped%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20Table%20and%20Which%20Table%20has%20been%20dropped" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-who-dropped-a-table-and-which-table-has-been-dropped%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20Table%20and%20Which%20Table%20has%20been%20dropped" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-who-dropped-a-table-and-which-table-has-been-dropped%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20Table%20and%20Which%20Table%20has%20been%20dropped" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-who-dropped-a-table-and-which-table-has-been-dropped%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20Table%20and%20Which%20Table%20has%20been%20dropped" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-who-dropped-a-table-and-which-table-has-been-dropped%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20Table%20and%20Which%20Table%20has%20been%20dropped" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-who-dropped-a-table-and-which-table-has-been-dropped%2F&amp;linkname=SQL%20Server%3A%20Who%20dropped%20a%20Table%20and%20Which%20Table%20has%20been%20dropped" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-who-dropped-a-table-and-which-table-has-been-dropped%2F&#038;title=SQL%20Server%3A%20Who%20dropped%20a%20Table%20and%20Which%20Table%20has%20been%20dropped" data-a2a-url="https://www.dbrnd.com/2016/12/sql-server-who-dropped-a-table-and-which-table-has-been-dropped/" data-a2a-title="SQL Server: Who dropped a Table and Which Table has been dropped"></a></p><p>SQL Server provides different types of database auditing option like: CDC, Database Audit.<br />
Recently, I have shared one article about, change your database DDL changes using Encrypted DDL triggers. </p>
<blockquote class="wp-embedded-content" data-secret="0nSvSWs9bx"><p><a href="https://www.dbrnd.com/2016/10/sql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security/">SQL Server: Encrypted DDL Trigger to Track all Database Changes</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/10/sql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security/embed/#?secret=0nSvSWs9bx" data-secret="0nSvSWs9bx" width="600" height="338" title="&#8220;SQL Server: Encrypted DDL Trigger to Track all Database Changes&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote><p>Database Administrators are responsible for database security and Periodically, They have to track all the database related changes and make sure that everything is working fine. </p></blockquote>
<blockquote><p>But still sometimes, I used to track database changes from the SQL Server log files using fn_dblog().<br />
I am sharing one way to find a person who dropped a table and also can get the name of that dropped table without enabling any auditing option of SQL Server.</p></blockquote>
<p><strong>Script to find the log of dropped objects:</strong></p>
<blockquote><p>Using this script, you can find a list of dropped tables and login name information, but you cannot get table name directly.<br />
You can find the transaction id for each record and using this transaction ID, you can find the table name.</p></blockquote>
<pre class="crayon-plain-tag">SELECT 
	[Transaction Id]
	,[Begin Time]
	,SUSER_SNAME ([Transaction SID]) AS [LoginName] 
FROM fn_dblog (NULL, NULL)  
WHERE [Transaction Name] = N'DROPOBJ';</pre> </p>
<p><strong>Find Table name using TransactionID:</strong></p>
<pre class="crayon-plain-tag">SELECT TOP 1 
	[Lock Information] 
FROM fn_dblog (NULL, NULL)  
WHERE [Transaction Id] = '0000:0015d6b3'  
AND [Lock Information] LIKE '%SCH_M OBJECT%';</pre> </p>
<p><strong>The result:</strong><br />
To get the table name, you can copy the number and search into sys.objects table.</p>
<pre class="crayon-plain-tag">HoBt 0:ACQUIRE_LOCK_SCH_M OBJECT: 8:1015674666:0</pre> </p>
<p><strong>Find your dropped table:</strong><br />
Please do not start to search your dropped table in your current database because Table already dropped.<br />
You must restore the last backup of the database and you should search your dropped table in that database. </p>
<pre class="crayon-plain-tag">SELECT *FROM sys.objects 
WHERE Object_ID ='1015674666'</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
