<?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>security &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/security/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>Sat, 20 Apr 2019 18:30: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>SQL Server: Find Stored Procedures which use Dynamic SQL and Temporary Table</title>
		<link>https://www.dbrnd.com/2019/04/sql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table/</link>
					<comments>https://www.dbrnd.com/2019/04/sql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 08 Apr 2019 18:30:46 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Data Security]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[dynamic sql]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL Injection]]></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[Stored Procedure]]></category>
		<category><![CDATA[Temp Table]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4076</guid>

					<description><![CDATA[Whenever you are searching for SQL query optimization tips or prevent SQL injection tips, you can find few common suggestions like: Please do not use Dynamic SQL in your Stored Procedure. Please try to avoid the use of Temp Tables. I always tell to database developers, please try to avoid the use of Dynamic SQL [&#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%2F2019%2F04%2Fsql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table%2F&amp;linkname=SQL%20Server%3A%20Find%20Stored%20Procedures%20which%20use%20Dynamic%20SQL%20and%20Temporary%20Table" 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%2F2019%2F04%2Fsql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table%2F&amp;linkname=SQL%20Server%3A%20Find%20Stored%20Procedures%20which%20use%20Dynamic%20SQL%20and%20Temporary%20Table" 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%2F2019%2F04%2Fsql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table%2F&amp;linkname=SQL%20Server%3A%20Find%20Stored%20Procedures%20which%20use%20Dynamic%20SQL%20and%20Temporary%20Table" 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%2F2019%2F04%2Fsql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table%2F&amp;linkname=SQL%20Server%3A%20Find%20Stored%20Procedures%20which%20use%20Dynamic%20SQL%20and%20Temporary%20Table" 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%2F2019%2F04%2Fsql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table%2F&amp;linkname=SQL%20Server%3A%20Find%20Stored%20Procedures%20which%20use%20Dynamic%20SQL%20and%20Temporary%20Table" 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%2F2019%2F04%2Fsql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table%2F&amp;linkname=SQL%20Server%3A%20Find%20Stored%20Procedures%20which%20use%20Dynamic%20SQL%20and%20Temporary%20Table" 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%2F2019%2F04%2Fsql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table%2F&#038;title=SQL%20Server%3A%20Find%20Stored%20Procedures%20which%20use%20Dynamic%20SQL%20and%20Temporary%20Table" data-a2a-url="https://www.dbrnd.com/2019/04/sql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table/" data-a2a-title="SQL Server: Find Stored Procedures which use Dynamic SQL and Temporary Table"></a></p><p>Whenever you are searching for SQL query optimization tips or prevent SQL injection tips, you can find few common suggestions like: Please do not use Dynamic SQL in your Stored Procedure. Please try to avoid the use of Temp Tables.</p>
<blockquote><p>I always tell to database developers, please try to avoid the use of Dynamic SQL and Temp Table in your Stored Procedures.</p></blockquote>
<blockquote><p>A Temp Table requires additional CPU/IO which degrades the query performance. A Dynamic SQL is not safe against the SQL Injection and It also compiles data every time which requires more Memory. </p></blockquote>
<blockquote><p>Here, I am sharing one of the important scripts which gives you list of SQL Server Stored Procedures, which use the Dynamic SQL and Temp Table.<br />
You can easily get the list of Stored Procedures and can make plans of modifying it.</p></blockquote>
<blockquote><p>Prepared this script using sys.dm_exec_describe_first_result_set and sys.procedures where error number 4 = Dynamic SQL and error number 10 = Temporary Table.</p></blockquote>
<pre class="crayon-plain-tag">SELECT  
	SP_Name
	,error_message
	,error_type_desc 
FROM (SELECT schema_name(schema_id)+'.'+name SP_Name FROM sys.procedures) AS T
CROSS APPLY sys.dm_exec_describe_first_result_set (SP_Name, NULL, 0) 
WHERE error_type IN (4,10)</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/04/sql-server-find-stored-procedures-which-use-dynamic-sql-and-temporary-table/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: Script to find Database USER LOGIN Information</title>
		<link>https://www.dbrnd.com/2018/01/sql-server-script-to-find-database-user-login-information-password-expiration-authentication-security/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 27 Jan 2018 16:16:44 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[login expiration]]></category>
		<category><![CDATA[Password]]></category>
		<category><![CDATA[security]]></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[TSQL]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4047</guid>

					<description><![CDATA[In this post, I am sharing one T-SQL Script to find SQL Server USER LOGIN Information. As a DBA, we should check the USER LOGIN Information to make sure about the user expiration, password expiration. Using password expiration information, you can also notify the user before its password expires. [crayon-6ab44a2a1c028694806272/]]]></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%2F01%2Fsql-server-script-to-find-database-user-login-information-password-expiration-authentication-security%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Database%20USER%20LOGIN%20Information" 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%2F01%2Fsql-server-script-to-find-database-user-login-information-password-expiration-authentication-security%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Database%20USER%20LOGIN%20Information" 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%2F01%2Fsql-server-script-to-find-database-user-login-information-password-expiration-authentication-security%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Database%20USER%20LOGIN%20Information" 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%2F01%2Fsql-server-script-to-find-database-user-login-information-password-expiration-authentication-security%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Database%20USER%20LOGIN%20Information" 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%2F01%2Fsql-server-script-to-find-database-user-login-information-password-expiration-authentication-security%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Database%20USER%20LOGIN%20Information" 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%2F01%2Fsql-server-script-to-find-database-user-login-information-password-expiration-authentication-security%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Database%20USER%20LOGIN%20Information" 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%2F01%2Fsql-server-script-to-find-database-user-login-information-password-expiration-authentication-security%2F&#038;title=SQL%20Server%3A%20Script%20to%20find%20Database%20USER%20LOGIN%20Information" data-a2a-url="https://www.dbrnd.com/2018/01/sql-server-script-to-find-database-user-login-information-password-expiration-authentication-security/" data-a2a-title="SQL Server: Script to find Database USER LOGIN Information"></a></p><p>In this post, I am sharing one T-SQL Script to find SQL Server USER LOGIN Information. </p>
<blockquote><p>As a DBA, we should check the USER LOGIN Information to make sure about the user expiration, password expiration.<br />
Using password expiration information, you can also notify the user before its password expires. </p></blockquote>
<pre class="crayon-plain-tag">SELECT 
	SL.name AS LoginName 
	,LOGINPROPERTY (SL.name, 'PasswordLastSetTime') AS PasswordLastSetTime 
	,LOGINPROPERTY (SL.name, 'DaysUntilExpiration') AS DaysUntilExpiration 
	,DATEADD(dd, CONVERT(int, LOGINPROPERTY (SL.name, 'DaysUntilExpiration')) 
				, CONVERT(datetime, LOGINPROPERTY (SL.name, 'PasswordLastSetTime'))) AS PasswordExpiration 
	,SL.is_policy_checked AS IsPolicyChecked 
	,LOGINPROPERTY (SL.name, 'IsExpired') AS IsExpired 
	,LOGINPROPERTY (SL.name, 'IsMustChange') AS IsMustChange 
	,LOGINPROPERTY (SL.name, 'IsLocked') AS IsLocked 
	,LOGINPROPERTY (SL.name, 'LockoutTime') AS LockoutTime 
	,LOGINPROPERTY (SL.name, 'BadPasswordCount') AS BadPasswordCount 
	,LOGINPROPERTY (SL.name, 'BadPasswordTime') AS BadPasswordTime 
	,LOGINPROPERTY (SL.name, 'HistoryLength') AS HistoryLength 
FROM sys.sql_logins AS SL 
WHERE is_expiration_checked = 1 
ORDER BY LOGINPROPERTY (SL.name, 'PasswordLastSetTime') DESC</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server 2016: Row Level Security by Example</title>
		<link>https://www.dbrnd.com/2017/08/sql-server-2016-row-level-security-by-example/</link>
					<comments>https://www.dbrnd.com/2017/08/sql-server-2016-row-level-security-by-example/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 16 Aug 2017 16:16:30 +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[FILTER PREDICAT]]></category>
		<category><![CDATA[Row level scrity]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server 2016]]></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=5876</guid>

					<description><![CDATA[<div><img width="573" height="255" src="https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity.png" class="attachment-post-image size-post-image wp-post-image" alt="Postgre SQL Row Level Security" decoding="async" fetchpriority="high" srcset="https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity.png 573w, https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity-300x134.png 300w, https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity-150x67.png 150w" sizes="(max-width: 573px) 100vw, 573px" /></div>In this post, I am going to publish about The Row Level Security which is now a common feature of all new version of RDBMSs like SQL Server 2016, PostgreSQL 9.5. With the concept of Row Level Security, we can restrict the user for a particular set of records. Previously, we are doing this kind [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="573" height="255" src="https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity.png" class="attachment-post-image size-post-image wp-post-image" alt="Postgre SQL Row Level Security" decoding="async" srcset="https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity.png 573w, https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity-300x134.png 300w, https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity-150x67.png 150w" sizes="(max-width: 573px) 100vw, 573px" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-2016-row-level-security-by-example%2F&amp;linkname=SQL%20Server%202016%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fsql-server-2016-row-level-security-by-example%2F&amp;linkname=SQL%20Server%202016%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fsql-server-2016-row-level-security-by-example%2F&amp;linkname=SQL%20Server%202016%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fsql-server-2016-row-level-security-by-example%2F&amp;linkname=SQL%20Server%202016%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fsql-server-2016-row-level-security-by-example%2F&amp;linkname=SQL%20Server%202016%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fsql-server-2016-row-level-security-by-example%2F&amp;linkname=SQL%20Server%202016%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fsql-server-2016-row-level-security-by-example%2F&#038;title=SQL%20Server%202016%3A%20Row%20Level%20Security%20by%20Example" data-a2a-url="https://www.dbrnd.com/2017/08/sql-server-2016-row-level-security-by-example/" data-a2a-title="SQL Server 2016: Row Level Security by Example"></a></p><p>In this post, I am going to publish about The Row Level Security which is now a common feature of all new version of RDBMSs like SQL Server 2016, PostgreSQL 9.5.</p>
<blockquote><p>With the concept of Row Level Security, we can restrict the user for a particular set of records.<br />
Previously, we are doing this kind of restriction using by creating filtered VIEWS and assign related VIEWS to relevant Users.</p></blockquote>
<p>SQL Server 2016 has this Row Level Security feature which extends the overall security policy of the SQL Server.</p>
<blockquote class="wp-embedded-content" data-secret="uBuwPD5cuC"><p><a href="https://www.dbrnd.com/2016/08/postgresql-9-5-row-level-security-by-example-restrict-records-for-user/">PostgreSQL 9.5: Row Level Security by Example</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/08/postgresql-9-5-row-level-security-by-example-restrict-records-for-user/embed/#?secret=uBuwPD5cuC" data-secret="uBuwPD5cuC" width="600" height="338" title="&#8220;PostgreSQL 9.5: Row Level Security by Example&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>Please check the below full demonstration on this.</p>
<p><strong>Create a test database:</strong></p>
<pre class="crayon-plain-tag">CREATE DATABASE CheckRowSecurity;
GO 
USE CheckRowSecurity;
GO</pre> </p>
<p><strong>Create a table with sample data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_employeeSalary
(
	empcode VARCHAR(10)
	,empname VARCHAR(10)
	,empsalary BIGINT
	,[month] INT
)
GO
 
INSERT  INTO tbl_employeeSalary
VALUES 
('Anv','Anvesh',150000,1)
,('Anv','Anvesh',120000,2)
,('Anv','Anvesh',160000,3)
,('Anv','Anvesh',170000,4)
,('Mar','Martin',90000,1)
,('Mar','Martin',100000,2)
,('Mar','Martin',120000,3)
,('Mar','Martin',130000,4)
GO</pre> </p>
<p><strong>Create two test users and assign SELECT permission on the table:</strong></p>
<pre class="crayon-plain-tag">CREATE USER Anv WITHOUT LOGIN;
CREATE USER Mar WITHOUT LOGIN;
GO

GRANT SELECT ON tbl_employeeSalary TO Anv
GRANT SELECT ON tbl_employeeSalary TO Mar
GO</pre> </p>
<p><strong>Create filter predicate function:</strong></p>
<pre class="crayon-plain-tag">CREATE FUNCTION rowLevelSecurity(@userName as sysname)
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN SELECT 1 AS rowLevelSecurityResult
WHERE @userName = USER_NAME();
GO</pre> </p>
<p><strong>Add filter predicate to the table:</strong></p>
<pre class="crayon-plain-tag">CREATE SECURITY POLICY UserFilter
ADD FILTER PREDICATE dbo.rowLevelSecurity(empcode)
ON dbo.tbl_employeeSalary
WITH (STATE = ON);
GO</pre> </p>
<p><strong>Select table without any user:</strong><br />
You will get a blank result set because we alter the security policy of this table.</p>
<pre class="crayon-plain-tag">SELECT * FROM tbl_employeeSalary</pre> </p>
<p><strong>Check for User &#8216;Anv&#8217;:</strong></p>
<pre class="crayon-plain-tag">EXECUTE AS USER = 'Anv'
SELECT * FROM tbl_employeeSalary
REVERT
GO</pre> </p>
<p><strong>Result:</strong></p>
<pre class="crayon-plain-tag">empcode    empname    empsalary            month
---------- ---------- -------------------- -----------
Anv        Anvesh     150000               1
Anv        Anvesh     120000               2
Anv        Anvesh     160000               3
Anv        Anvesh     170000               4</pre> </p>
<p><strong>Check for User &#8216;Mar&#8217;:</strong></p>
<pre class="crayon-plain-tag">EXECUTE AS USER = 'Mar'
SELECT * FROM tbl_employeeSalary
REVERT
GO</pre> </p>
<p><strong>Result:</strong></p>
<pre class="crayon-plain-tag">empcode    empname    empsalary            month
---------- ---------- -------------------- -----------
Mar        Martin     90000                1
Mar        Martin     100000               2
Mar        Martin     120000               3
Mar        Martin     130000               4</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/08/sql-server-2016-row-level-security-by-example/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Database Theory: What is difference between MySQL and PostgreSQL?</title>
		<link>https://www.dbrnd.com/2016/12/database-theory-what-is-difference-between-mysql-and-postgresql-relational-database-system-concurrency-performance/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 01 Dec 2016 03:34:20 +0000</pubDate>
				<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database concept]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[database standards]]></category>
		<category><![CDATA[database topic]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[innodb]]></category>
		<category><![CDATA[Multi version concurrency control]]></category>
		<category><![CDATA[MVCC]]></category>
		<category><![CDATA[MyISAM]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[RDBMS]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3960</guid>

					<description><![CDATA[As a database professional, I work with both databases on a regular basis, and I typically use all the features of both databases for design and implementation. I have got many replies to write about the core differences between PostgreSQL and MySQL. As innovation on these databases has progressed, each development community has actively made [&#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%2Fdatabase-theory-what-is-difference-between-mysql-and-postgresql-relational-database-system-concurrency-performance%2F&amp;linkname=Database%20Theory%3A%20What%20is%20difference%20between%20MySQL%20and%20PostgreSQL%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%2F2016%2F12%2Fdatabase-theory-what-is-difference-between-mysql-and-postgresql-relational-database-system-concurrency-performance%2F&amp;linkname=Database%20Theory%3A%20What%20is%20difference%20between%20MySQL%20and%20PostgreSQL%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%2F2016%2F12%2Fdatabase-theory-what-is-difference-between-mysql-and-postgresql-relational-database-system-concurrency-performance%2F&amp;linkname=Database%20Theory%3A%20What%20is%20difference%20between%20MySQL%20and%20PostgreSQL%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%2F2016%2F12%2Fdatabase-theory-what-is-difference-between-mysql-and-postgresql-relational-database-system-concurrency-performance%2F&amp;linkname=Database%20Theory%3A%20What%20is%20difference%20between%20MySQL%20and%20PostgreSQL%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%2F2016%2F12%2Fdatabase-theory-what-is-difference-between-mysql-and-postgresql-relational-database-system-concurrency-performance%2F&amp;linkname=Database%20Theory%3A%20What%20is%20difference%20between%20MySQL%20and%20PostgreSQL%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%2F2016%2F12%2Fdatabase-theory-what-is-difference-between-mysql-and-postgresql-relational-database-system-concurrency-performance%2F&amp;linkname=Database%20Theory%3A%20What%20is%20difference%20between%20MySQL%20and%20PostgreSQL%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%2F2016%2F12%2Fdatabase-theory-what-is-difference-between-mysql-and-postgresql-relational-database-system-concurrency-performance%2F&#038;title=Database%20Theory%3A%20What%20is%20difference%20between%20MySQL%20and%20PostgreSQL%3F" data-a2a-url="https://www.dbrnd.com/2016/12/database-theory-what-is-difference-between-mysql-and-postgresql-relational-database-system-concurrency-performance/" data-a2a-title="Database Theory: What is difference between MySQL and PostgreSQL?"></a></p><p><em>As a database professional, I work with both databases on a regular basis, and I typically use all the features of   both databases for design and implementation.<br />
I have got many replies to write about the core differences between PostgreSQL and MySQL. </p>
<p>As innovation on these databases has progressed, each development community has actively made changes to address their respective sets of perceived disadvantages.<br />
The result that it has gotten more difficult to objectively determine which database is likely to be better suited for a given application. </em></p>
<blockquote><p>MySQL is controlled by Oracle, whereas Postgres is available under an open-source license from the PostgreSQL Global Development Group.</p></blockquote>
<blockquote><p>PostgreSQL is closer to the ANSI SQL standard, MySQL is closer to the ODBC standard.</p></blockquote>
<blockquote><p>One of the most notable differences between MySQL and PostgreSQL is the fact that you can’t do nested subqueries of subselects in MySQL. MySQL doesn’t support CTE, window functions, full outer joins and arrays. </p></blockquote>
<blockquote><p>Compare to PostgreSQL, MySQL has its own large user community and various type of materials.</p></blockquote>
<blockquote><p>MySQL uses nonstandard &#8216;#&#8217; to begin a comment line and PostgreSQL use &#8216;&#8211;&#8216; to begin a comment line.</p></blockquote>
<blockquote><p>MySQL provides different type of table storage engines like: InnoDB, MyIsam, Memory. PostgreSQL does not provide different type of table stroage engines.
</p></blockquote>
<blockquote><p>PostgreSQL is case-sensitive for string comparisons. The field &#8220;DbRnd&#8221; is not the same as the field &#8220;dbrnd&#8221;. This is a big change for many users from MySQL and other small database systems.</p></blockquote>
<blockquote><p>PostgreSQL has some nice features like: generate_series, custom aggregate functions, arrays etc. other hand MySQL has also some nice feature like: session variables in queries, FORCE INDEX, etc.</p></blockquote>
<blockquote><p>In PostgreSQL, when you are inside a transaction almost any operation can be undone. There are some irreversible operations (like creating or destroying a database or tablespace), but normal table modifications can be backed out by issuing a ROLLBACK via its Write-Ahead Log design.</p>
<p>MySQL doesn&#8217;t support any sort of rollback when using MyISAM. With InnoDB, the server has an implicit commit that occurs even if the normal auto-commit behavior is turned off. This means that any single table alteration or similar change is immediately committed.</p></blockquote>
<blockquote><p>Postgres obliterates MySQL in all manner of query-level goodness, and we can use Postgres for data mining and batch analytics databases, where we run lots of very large, hand-coded queries that can take advantage of Postgres’ advantages in join methods (MySQL only supports Nested Loop and Nested Loop over Index, while Postgres supports numerous methods), generally richer querying capabilities, and other good stuff like partial indexes can be used extensively.</p></blockquote>
<blockquote><p>PostgreSQL uses a robust locking model called MVCC that limits situations where individual clients interfere with each other. A short summary of the main benefit of MVCC would be &#8220;readers are never blocked by writers&#8221;.</p>
<p>MySQL&#8217;s InnoDB implements MVCC using a rollback segment and InnoDB databases supports all four SQL standard transaction isolation levels.
</p></blockquote>
<blockquote><p>PostgreSQL uses cost-based query optimization methods in order to get good performance for many different types of joins. Query costs are assessed based on planner statistics collected when tables are analyzed combined with adjustable planner costs and advanced features such as the Genetic Query Optimizer.</p>
<p>MySQL doesn&#8217;t have this level of sophistication in its planner, and the tunables for Controlling Query Optimizer Performance are crude. Developers instead do things like explicitly provide index hints to make sure joins are executed correctly.</p></blockquote>
<blockquote><p>PostgreSQL has different replication options than MySQL. MySQL has no point-in-time recovery.</p></blockquote>
<blockquote><p>One operation that PostgreSQL is known to be slow performing is doing a full count of rows in a table, typically using this SQL:</p>
<pre class="crayon-plain-tag">SELECT COUNT(*) FROM your_table_name;</pre> </p>
<p>The reason why this is slow is related to the MVCC implementation in PostgreSQL. The fact that multiple transactions can see different states of the data means that there can be no straightforward way for &#8220;COUNT(*)&#8221; to summarize data across the whole table; PostgreSQL must walk through all rows, in some sense.</p>
<p>In MySQL, MyISAM tables cache the row count information, making this type of count operation almost instant. But if you&#8217;re using InnoDB instead, this is no longer the case and on InnoDB can&#8217;t assume that a full row count will be fast.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Encrypted DDL Trigger to Track all Database Changes</title>
		<link>https://www.dbrnd.com/2016/10/sql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security/</link>
					<comments>https://www.dbrnd.com/2016/10/sql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 21 Oct 2016 16:16:57 +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[database security]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[DDL Trigger]]></category>
		<category><![CDATA[security]]></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[Track Object]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3674</guid>

					<description><![CDATA[I know, you guys are thinking that why we require DDL Trigger to track database changes in SQL Server. SQL Server already has Changed Data Capture (CDC) and Audit option. When we are talking about DDL Trigger, compare to other automated process this manual process is still preferred by SQL DBA because It is easy [&#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%2F10%2Fsql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security%2F&amp;linkname=SQL%20Server%3A%20Encrypted%20DDL%20Trigger%20to%20Track%20all%20Database%20Changes" 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%2F10%2Fsql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security%2F&amp;linkname=SQL%20Server%3A%20Encrypted%20DDL%20Trigger%20to%20Track%20all%20Database%20Changes" 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%2F10%2Fsql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security%2F&amp;linkname=SQL%20Server%3A%20Encrypted%20DDL%20Trigger%20to%20Track%20all%20Database%20Changes" 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%2F10%2Fsql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security%2F&amp;linkname=SQL%20Server%3A%20Encrypted%20DDL%20Trigger%20to%20Track%20all%20Database%20Changes" 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%2F10%2Fsql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security%2F&amp;linkname=SQL%20Server%3A%20Encrypted%20DDL%20Trigger%20to%20Track%20all%20Database%20Changes" 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%2F10%2Fsql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security%2F&amp;linkname=SQL%20Server%3A%20Encrypted%20DDL%20Trigger%20to%20Track%20all%20Database%20Changes" 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%2F10%2Fsql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security%2F&#038;title=SQL%20Server%3A%20Encrypted%20DDL%20Trigger%20to%20Track%20all%20Database%20Changes" data-a2a-url="https://www.dbrnd.com/2016/10/sql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security/" data-a2a-title="SQL Server: Encrypted DDL Trigger to Track all Database Changes"></a></p><p>I know, you guys are thinking that why we require DDL Trigger to track database changes in SQL Server. </p>
<blockquote><p>SQL Server already has Changed Data Capture (CDC) and Audit option.<br />
When we are talking about DDL Trigger, compare to other automated process this manual process is still preferred by SQL DBA because It is easy to use and manage.</p></blockquote>
<blockquote><p>A Database Administrator is also responsible for all different types of Database Security like: Database / Schema / Object level permission, Tracking object creation. </p></blockquote>
<blockquote><p>I have enabled SQL Server Audit for one of our production report server, but some time It does not work as per the expectation.
</p></blockquote>
<blockquote><p>I have searched the alternate solution and found that we can create DDL trigger on a database to track the DDL operation of different objects.<br />
We can also use DDL triggers to verify the result of SQL Server Audit. </p></blockquote>
<p><strong>Other take care points of DDL Trigger are:</strong></p>
<blockquote><p>Only SA or Admin user has to perform this stuff. The DBA should restrict other common database user to view or modify the DDL trigger.</p></blockquote>
<blockquote><p>It should be encrypted. </p></blockquote>
<blockquote><p>If our database is heavily loaded with tons of transaction, we should not create any type of DDL trigger on it. </p></blockquote>
<p>Here, I am creating one encrypted DDL Trigger which tracks different types of object like:<br />
Stored Procedure, Table, View, Function, Trigger, Sequence, Index.</p>
<p><strong>Step to create Encrypted DDL Trigger:</strong></p>
<p><strong>First Create separate database:</strong></p>
<pre class="crayon-plain-tag">CREATE DATABASE [DDLChanges]
GO</pre> </p>
<p><strong>Create one table which will hold all event information:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE [DDLChanges].[dbo].[tbl_TrackDDLChanges](
	[EventDate] [datetime] NOT NULL DEFAULT (getdate()),
	[EventType] [nvarchar](64) NULL,
	[EventDDL] [nvarchar](max) NULL,
	[LoginName] [nvarchar](255) NULL,
	[DatabaseName] [nvarchar](255) NULL,
	[SchemaName] [nvarchar](255) NULL,
	[ObjectName] [nvarchar](255) NULL,
	[HostName] [varchar](64) NULL,
	[IPAddress] [varchar](32) NULL,
	[ProgramName] [nvarchar](255) NULL,
	[EventXML] [xml] NULL
)
GO</pre> </p>
<p><strong>SELECT your application Database and create below encrypted DDL trigger:</strong></p>
<blockquote><p>If you require to enable DDL trigger on multiple database, execute DDL trigger one by one on each require a database. </p></blockquote>
<blockquote><p>Please do not create a DDL Trigger on [DDLChanges] database, that we have created in the first step which is for tracking purposes.</p></blockquote>
<blockquote><p>Now, perform any DDL action on your database and check [DDLChanges].[dbo].[tbl_TrackDDLChanges] table where you can find important information like: which SQL Query, who created, which host, what time, on which database and other. </p></blockquote>
<pre class="crayon-plain-tag">CREATE TRIGGER [trg_DDL_Changes]
ON DATABASE
WITH ENCRYPTION
FOR 
	CREATE_PROCEDURE
	,ALTER_PROCEDURE
	,DROP_PROCEDURE
	,CREATE_TABLE
	,ALTER_TABLE
	,DROP_TABLE
	,CREATE_VIEW
	,ALTER_VIEW
	,DROP_VIEW
	,CREATE_FUNCTION
	,ALTER_FUNCTION
	,DROP_FUNCTION
	,CREATE_TRIGGER
	,ALTER_TRIGGER
	,DROP_TRIGGER
	,CREATE_SEQUENCE
	,ALTER_SEQUENCE
	,DROP_SEQUENCE
	,CREATE_INDEX
	,ALTER_INDEX
	,DROP_INDEX
AS
BEGIN
    SET NOCOUNT ON;
    DECLARE
        @EventData XML = EVENTDATA(); 
    DECLARE 
        @ip VARCHAR(32) =
        (
            SELECT client_net_address
            FROM sys.dm_exec_connections
            WHERE session_id = @@SPID
        );
 
    INSERT DDLChanges.dbo.tbl_TrackDDLChanges
    (
        EventType
        ,EventDDL
	,LoginName        
        ,DatabaseName
        ,SchemaName
        ,ObjectName
        ,HostName
        ,IPAddress
        ,ProgramName        
	,EventXML
    )
    SELECT
        @EventData.value('(/EVENT_INSTANCE/EventType)[1]','NVARCHAR(100)')
        ,@EventData.value('(/EVENT_INSTANCE/TSQLCommand)[1]','NVARCHAR(MAX)')
	,SUSER_SNAME()        
        ,DB_NAME()
        ,@EventData.value('(/EVENT_INSTANCE/SchemaName)[1]','NVARCHAR(255)')
        ,@EventData.value('(/EVENT_INSTANCE/ObjectName)[1]','NVARCHAR(255)')
        ,HOST_NAME()
        ,@ip
        ,PROGRAM_NAME()        
	,@EventData
END
GO</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/10/sql-server-encrypted-ddl-trigger-to-track-all-database-changes-to-ensure-database-object-security/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Why New User can access all Databases without any Grants</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission/</link>
					<comments>https://www.dbrnd.com/2016/08/postgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 16 Aug 2016 17:43:16 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[CONNECT role]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[database user]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[GRANT]]></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 Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[REVOKE]]></category>
		<category><![CDATA[role]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3515</guid>

					<description><![CDATA[The Database security is always one of the major tasks for all the Database Administrators. I have also prepared one article to create Read only User in PostgreSQL. PostgreSQL: Script to Create a Read-Only Database User In this post, I am sharing small note about REVOKE privileges for newly created Database Users of PostgreSQL. Before [&#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%2F08%2Fpostgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission%2F&amp;linkname=PostgreSQL%3A%20Why%20New%20User%20can%20access%20all%20Databases%20without%20any%20Grants" 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%2F08%2Fpostgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission%2F&amp;linkname=PostgreSQL%3A%20Why%20New%20User%20can%20access%20all%20Databases%20without%20any%20Grants" 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%2F08%2Fpostgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission%2F&amp;linkname=PostgreSQL%3A%20Why%20New%20User%20can%20access%20all%20Databases%20without%20any%20Grants" 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%2F08%2Fpostgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission%2F&amp;linkname=PostgreSQL%3A%20Why%20New%20User%20can%20access%20all%20Databases%20without%20any%20Grants" 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%2F08%2Fpostgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission%2F&amp;linkname=PostgreSQL%3A%20Why%20New%20User%20can%20access%20all%20Databases%20without%20any%20Grants" 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%2F08%2Fpostgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission%2F&amp;linkname=PostgreSQL%3A%20Why%20New%20User%20can%20access%20all%20Databases%20without%20any%20Grants" 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%2F08%2Fpostgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission%2F&#038;title=PostgreSQL%3A%20Why%20New%20User%20can%20access%20all%20Databases%20without%20any%20Grants" data-a2a-url="https://www.dbrnd.com/2016/08/postgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission/" data-a2a-title="PostgreSQL: Why New User can access all Databases without any Grants"></a></p><p>The Database security is always one of the major tasks for all the Database Administrators.<br />
I have also prepared one article to create Read only User in PostgreSQL. </p>
<blockquote class="wp-embedded-content" data-secret="KAMMknEJXF"><p><a href="https://www.dbrnd.com/2015/10/postgresql-script-to-create-a-read-only-database-user/">PostgreSQL: Script to Create a Read-Only Database User</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/10/postgresql-script-to-create-a-read-only-database-user/embed/#?secret=KAMMknEJXF" data-secret="KAMMknEJXF" width="600" height="338" title="&#8220;PostgreSQL: Script to Create a Read-Only Database User&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote><p>In this post, I am sharing small note about REVOKE privileges for newly created Database Users of PostgreSQL. </p></blockquote>
<blockquote><p>Before a few days ago, one of the PostgreSQL Junior DBA asked this question on my FB Page. He created one new DB User in PostgreSQL and without giving a any permission that USER can CONNECT to all Databases. </p></blockquote>
<blockquote><p>Yes: When you create any new DB User in PostgreSQL, It has a default CONNECT privileges.<br />
But It cannot access any Table or data of Databases, yes It can create new Table in any Database. </p></blockquote>
<p>To prevent a new User for connecting any existing Database, we should run REVOKE command on particular User or Role.</p>
<p><strong>REVOKE CONNECT privileges from Database:</strong></p>
<pre class="crayon-plain-tag">REVOKE CONNECT ON DATABASE Database_Name FROM User_Name;</pre> </p>
<p><strong>REVOKE all privileges from Database: </strong></p>
<pre class="crayon-plain-tag">REVOKE ALL PRIVILEGES ON DATABASE Database_Name FROM User_Name;</pre> </p>
<p><strong>You should GRANT only required Databases:</strong></p>
<pre class="crayon-plain-tag">GRANT CONNECT ON DATABASE Database_Name TO User_Name;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/08/postgresql-why-new-user-can-access-all-databases-without-any-grants-revoke-connect-permission/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL 9.5: Row Level Security by Example</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-9-5-row-level-security-by-example-restrict-records-for-user/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 01 Aug 2016 19:33:53 +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[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[postgresql 9.5]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[row level security]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3433</guid>

					<description><![CDATA[Hello guys, Since last two months I have published about the SQL Server Interview Questions and Answers. During this time, I got lots of messages and requests about the PostgreSQL. In this August &#8211; 2016, I am going to post about only PostgreSQL and will try to complete all pending requests of readers. In this [&#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%2F08%2Fpostgresql-9-5-row-level-security-by-example-restrict-records-for-user%2F&amp;linkname=PostgreSQL%209.5%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fpostgresql-9-5-row-level-security-by-example-restrict-records-for-user%2F&amp;linkname=PostgreSQL%209.5%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fpostgresql-9-5-row-level-security-by-example-restrict-records-for-user%2F&amp;linkname=PostgreSQL%209.5%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fpostgresql-9-5-row-level-security-by-example-restrict-records-for-user%2F&amp;linkname=PostgreSQL%209.5%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fpostgresql-9-5-row-level-security-by-example-restrict-records-for-user%2F&amp;linkname=PostgreSQL%209.5%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fpostgresql-9-5-row-level-security-by-example-restrict-records-for-user%2F&amp;linkname=PostgreSQL%209.5%3A%20Row%20Level%20Security%20by%20Example" 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%2F08%2Fpostgresql-9-5-row-level-security-by-example-restrict-records-for-user%2F&#038;title=PostgreSQL%209.5%3A%20Row%20Level%20Security%20by%20Example" data-a2a-url="https://www.dbrnd.com/2016/08/postgresql-9-5-row-level-security-by-example-restrict-records-for-user/" data-a2a-title="PostgreSQL 9.5: Row Level Security by Example"></a></p><p><strong>Hello guys, Since last two months I have published about the SQL Server Interview Questions and Answers.<br />
During this time, I got lots of messages and requests about the PostgreSQL.</strong></p>
<p>In this August &#8211; 2016, I am going to post about only PostgreSQL and will try to complete all pending requests of readers.</p>
<blockquote><p>In this post, I am going to publish about The Row Level Security which is now a common feature of all new version of RDBMSs like SQL Server 2016, PostgreSQL 9.5.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-3436 size-full" title="Postgre SQL Row Level Security" src="https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity.png" alt="Postgre SQL Row Level Security" width="573" height="255" srcset="https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity.png 573w, https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity-300x134.png 300w, https://www.dbrnd.com/wp-content/uploads/2016/08/PostgreSQLRowLevelSecurity-150x67.png 150w" sizes="auto, (max-width: 573px) 100vw, 573px" /></p></blockquote>
<blockquote><p>With the concept of Row Level Security, we can restrict the user for a particular set of records.<br />
Previously, we are doing this kind of restriction using by creating filtered VIEWS and assign related VIEWS to related Users.</p></blockquote>
<blockquote><p>PostgreSQL 9.5 has this Row Level Security feature which extends the overall security policy of the PostgreSQL.</p></blockquote>
<p><strong>Let me demonstrate this.</strong></p>
<p><strong>Execute below all steps using Postgres Super user:</strong></p>
<p><strong>First create two sample users:</strong><br />
<pre class="crayon-plain-tag">CREATE USER abc LOGIN PASSWORD '123';
CREATE USER xyz LOGIN PASSWORD '321';</pre>
<strong>Create a table with sample data:</strong><br />
<pre class="crayon-plain-tag">CREATE TABLE tbl_Employees
(
	EmpID INT
	,EmpName CHARACTER VARYING 
);
INSERT INTO tbl_Employees VALUES 
(1,'Anvesh'),(2,'Martin'),(3,'Roy')
,(4,'Jeeny'),(5,'Kavita'),(6,'Neevan');</pre>
<strong>Add one new column for row level security:</strong><br />
<pre class="crayon-plain-tag">ALTER TABLE tbl_Employees ADD pgUser CHARACTER VARYING;</pre>
<strong>Update table with specific user:</strong><br />
<pre class="crayon-plain-tag">UPDATE tbl_Employees SET pgUser = 'abc' WHERE EmpID IN (1,2,3);
UPDATE tbl_Employees SET pgUser = 'xyz' WHERE EmpID IN (4,5,6);</pre>
<strong>Give some DML grants to these users:</strong><br />
<pre class="crayon-plain-tag">GRANT SELECT,UPDATE,INSERT,DELETE ON tbl_Employees TO abc;
GRANT SELECT,UPDATE,INSERT,DELETE ON tbl_Employees TO xyz;</pre>
<strong>Create a security policy on tbl_Employee for current logged-in user only:</strong><br />
<pre class="crayon-plain-tag">CREATE POLICY policy_employee_user ON tbl_Employees FOR ALL
TO PUBLIC USING (pgUser = current_user);</pre>
<strong>Enable ROW LEVEL SECURITY on tbl_Employees:</strong><br />
<pre class="crayon-plain-tag">ALTER TABLE tbl_Employees ENABLE ROW LEVEL SECURITY;</pre>
<strong>Execute this SELECT with the different logins:</strong><br />
<pre class="crayon-plain-tag">SELECT *FROM tbl_Employees;</pre>
<strong>Result of User abc:</strong><br />
<pre class="crayon-plain-tag">empid   empname   pguser
--------------------------
 1      Anvesh     abc
 2      Martin     abc
 3      Roy        abc</pre>
<strong>Result of User xyz:</strong><br />
<pre class="crayon-plain-tag">empid   empname   pguser
--------------------------
 4      Jeeny      xyz
 5      Kavita     xyz
 6      Neevan     xyz</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Security Interview Questions and Answers  (Day-1)</title>
		<link>https://www.dbrnd.com/2016/07/sql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1/</link>
					<comments>https://www.dbrnd.com/2016/07/sql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 18 Jul 2016 19:28:52 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Data Masking]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Decryption]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[orphaned user]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[secure socket layer]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL Injection]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></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[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3364</guid>

					<description><![CDATA[What do you mean by Database Security? Database security refers to the collective measures used to protect and secure a database or database management software from illegitimate use and malicious threats and attacks. It is a broad term that includes a multitude of processes, tools and methodologies that ensure security within a database environment. What [&#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%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" 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%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" 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%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" 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%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" 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%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" 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%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" 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%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&#038;title=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" data-a2a-url="https://www.dbrnd.com/2016/07/sql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1/" data-a2a-title="SQL Server: Database Security Interview Questions and Answers  (Day-1)"></a></p><p><strong>What do you mean by Database Security?</strong></p>
<blockquote><p>Database security refers to the collective measures used to protect and secure a database or database management software from illegitimate use and malicious threats and attacks. It is a broad term that includes a multitude of processes, tools and methodologies that ensure security within a database environment.</p></blockquote>
<p><strong>What is Data Masking?</strong></p>
<blockquote class="wp-embedded-content" data-secret="JnDNNa5P6s"><p><a href="https://www.dbrnd.com/2015/11/database-theory-what-is-a-data-masking-2/">Database Theory: What is a Data Masking ?</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/11/database-theory-what-is-a-data-masking-2/embed/#?secret=JnDNNa5P6s" data-secret="JnDNNa5P6s" width="600" height="338" title="&#8220;Database Theory: What is a Data Masking ?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is Data Theft?</strong></p>
<blockquote><p>Data theft is the act of stealing computer-based information from an unknowing victim with the intent of compromising privacy or obtaining confidential information. Data theft is increasingly a problem for individual computer users, as well as big corporate firms.</p>
<p>Data must be stored and transmitted securely, so that information such as credit card numbers cannot be stolen. Over the Internet and Wide Area Network (WAN) environments, both public carriers and private network owners often route portions of their network through insecure landlines, extremely vulnerable microwave and satellite links, or a number of servers.</p></blockquote>
<p><strong>What are the different types of Security levels?</strong></p>
<ul>
<li>Physical</li>
<li>Human</li>
<li>Operating System</li>
<li>Network</li>
<li>Database System</li>
</ul>
<p><strong>What does Database Encryption and Decryption mean?</strong></p>
<blockquote><p>Database encryption is the process of converting data, within a database, in plain text format into a meaningless cipher text by means of a suitable algorithm.</p>
<p>Database decryption is converting the meaningless cipher text into the original information using keys generated by the encryption algorithms.</p>
<p>Database encryption can be provided at the file or column level.</p></blockquote>
<p><strong>What is SQL injection?</strong></p>
<blockquote><p>SQL injection is an attack by malicious users in which malicious code can be inserted into strings that can be passed to an instance of SQL server for parsing and execution. All statements have to checked for vulnerabilities as it executes all syntactically valid queries that it receives.</p>
<p>Even parameters can be manipulated by the skilled and experienced attackers.</p></blockquote>
<p><strong>What are the methods used to protect against SQL injection attack?</strong></p>
<p>Following are the methods used to protect against SQL injection attack:</p>
<ul>
<li>Use Parameters for Stored Procedures</li>
<li>Filtering input parameters</li>
<li>Use Parameter collection with Dynamic SQL</li>
<li>In like clause, user escape characters</li>
</ul>
<p><strong>How can SQL Server instances be hidden?</strong></p>
<blockquote><p>To hide a SQL Server instance, we need to make a change in SQL Server Configuration Manager.</p>
<p>To do this launch SQL Server Configuration Manager and do the following:</p>
<p>select the instance of SQL Server, right click and select Properties. After selecting properties you will just set Hide Instance to &#8220;Yes&#8221; and click OK or Apply.</p>
<p>After the change is made, you need to restart the instance of SQL Server to not expose the name of the instance.</p></blockquote>
<p><strong>What are Orphaned Users?</strong></p>
<p>A database user for which the corresponding SQL Server login is undefined or is incorrectly defined on a server instance cannot log in to the instance. Such a user is said to be an orphaned user of the database on that server instance.</p>
<ul>
<li>A database user can become orphaned if the corresponding SQL Server login is dropped.</li>
<li>A database user can become orphaned after a database is restored or attached to a different instance of SQL Server.</li>
<li>Orphaning can happen if the database user is mapped to a SID that is not present in the new server instance.</li>
</ul>
<p><strong>Would you please describe any five server role with its permission?</strong></p>
<ul>
<li>bulkadmin: Granted &#8211; ADMINISTER BULK OPERATIONS</li>
<li>dbcreator: Granted &#8211; CREATE ANY DATABASE</li>
<li>diskadmin: Granted &#8211; ALTER RESOURCES</li>
<li>processadmin: Granted &#8211; ALTER ANY CONNECTION, ALTER SERVER STATE</li>
<li>securityadmin: Granted &#8211; ALTER ANY LOGIN</li>
<li>serveradmin: Granted &#8211; ALTER ANY ENDPOINT, ALTER RESOURCES, ALTER SERVER STATE, ALTER SETTINGS, SHUTDOWN, VIEW SERVER STATE</li>
<li>setupadmin: Granted &#8211; ALTER ANY LINKED SERVER</li>
<li>sysadmin: Granted with GRANT option &#8211; CONTROL SERVER</li>
</ul>
<p><strong>Which authentication mode is more secured?</strong></p>
<blockquote><p>Windows authentication is definitely more secure as it’s controlled and authenticated by Active Directory policies.</p></blockquote>
<p><strong>What is a Symmetric key in Data encryption process?</strong></p>
<blockquote><p>In Symmetric cryptography system, the sender and the receiver of a message share a single, common key that is used to encrypt and decrypt the message. This is relatively easy to implement, and both the sender and the receiver can encrypt or decrypt the messages.</p></blockquote>
<p><strong>What is a Asymmetric key in Data encryption process?</strong></p>
<blockquote><p>Asymmetric cryptography, also known as Public-key cryptography, is a system in which the sender and the receiver of a message have a pair of cryptographic keys – a public key and a private key – to encrypt and decrypt the message. This is a relatively complex system where the sender can use his key to encrypt the message but he cannot decrypt it. The receiver, on the other hand, can use his key to decrypt the message but he cannot encrypt it.</p></blockquote>
<p><strong>What Secure Socket Layer (SSL) with SQL Server and can we enable it?</strong></p>
<blockquote><p>Yes: We can enable SSL with SQL Server</p>
<p>Microsoft SQL Server can use Secure Sockets Layer (SSL) to encrypt data that is transmitted across a network between an instance of SQL Server and a client application. Enabling SSL encryption increases the security of data transmitted across networks between instances of SQL Server and applications.</p></blockquote>
<p><strong>What are basic steps to configure SSL for SQL Server?</strong></p>
<blockquote><p>Install a certificate in the Windows certificate store of the server computer.</p>
<p>Click Start, in the Microsoft SQL Server program group, point to Configuration Tools, and thenclick SQL Server Configuration Manager.</p>
<p>Expand SQL Server Network Configuration, right-click the protocols for the server you want, and then click Properties.</p>
<p>On the Certificate tab, configure the Database Engine to use the certificate.</p>
<p>On the Flags tab, view or specify the protocol encryption option. The login packet will always be encrypted.</p></blockquote>
<p><strong>What are the built-In Schemas?</strong></p>
<ul>
<li>dbo</li>
<li>guest</li>
<li>sys</li>
<li>INFORMATION_SCHEMA</li>
</ul>
<p><strong>Are you agree with User-Schema Separation in SQL Server?</strong></p>
<blockquote><p>Yes: User-schema separation allows for more flexibility in managing database object permissions. A schema is a named container for database objects, which allows you to group objects into separate namespaces.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/07/sql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Script to Create a Read-Only Database User</title>
		<link>https://www.dbrnd.com/2015/10/postgresql-script-to-create-a-read-only-database-user/</link>
					<comments>https://www.dbrnd.com/2015/10/postgresql-script-to-create-a-read-only-database-user/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 22 Oct 2015 16:20:45 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL 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[permission]]></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 Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[PostgreSQL Tuning]]></category>
		<category><![CDATA[role]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=911</guid>

					<description><![CDATA[In this post, I am sharing the help on how to create, a read-only user with limited access in PostgreSQL Database Server?. As a Database Administrator, you should create different database users for the different purposes. In the standard application, there are a few various types of Database Users like Application user, Read-only user, Admin [&#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%2F2015%2F10%2Fpostgresql-script-to-create-a-read-only-database-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20Create%20a%20Read-Only%20Database%20User" 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%2F2015%2F10%2Fpostgresql-script-to-create-a-read-only-database-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20Create%20a%20Read-Only%20Database%20User" 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%2F2015%2F10%2Fpostgresql-script-to-create-a-read-only-database-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20Create%20a%20Read-Only%20Database%20User" 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%2F2015%2F10%2Fpostgresql-script-to-create-a-read-only-database-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20Create%20a%20Read-Only%20Database%20User" 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%2F2015%2F10%2Fpostgresql-script-to-create-a-read-only-database-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20Create%20a%20Read-Only%20Database%20User" 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%2F2015%2F10%2Fpostgresql-script-to-create-a-read-only-database-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20Create%20a%20Read-Only%20Database%20User" 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%2F2015%2F10%2Fpostgresql-script-to-create-a-read-only-database-user%2F&#038;title=PostgreSQL%3A%20Script%20to%20Create%20a%20Read-Only%20Database%20User" data-a2a-url="https://www.dbrnd.com/2015/10/postgresql-script-to-create-a-read-only-database-user/" data-a2a-title="PostgreSQL: Script to Create a Read-Only Database User"></a></p><p>In this post, I am sharing the help on how to create, a read-only user with limited access in PostgreSQL Database Server?.</p>
<p>As a Database Administrator, you should create different database users for the different purposes.<br />
In the standard application, there are a few various types of Database Users like Application user, Read-only user, Admin user.</p>
<p><strong>You should always create a shared database role group and assign roles to the user. </strong></p>
<p>Here, I am sharing one script to create the read only user with limited access to PostgreSQL Database. This user can only SELECT table data and also restricted by schema access. </p>
<p><strong>Create the Read-Only user:</strong></p>
<pre class="crayon-plain-tag">CREATE ROLE Read_Only_User WITH LOGIN PASSWORD 'Test1234' 
NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION VALID UNTIL 'infinity';</pre> </p>
<p><strong>Assign permissions to the read only user:</strong></p>
<pre class="crayon-plain-tag">GRANT CONNECT ON DATABASE YourDatabaseName TO Read_Only_User;
GRANT USAGE ON SCHEMA public TO Read_Only_User;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO Read_Only_User;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO Read_Only_User;</pre> </p>
<p>In the above script, you can find that I restricted user by Database, Schema and gave only SELECT permission for tables. </p>
<p><strong>If you need to give any additional permission like EXECUTE permission for functions, use below script. </strong></p>
<pre class="crayon-plain-tag">GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO Read_Only_User;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/10/postgresql-script-to-create-a-read-only-database-user/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
	</channel>
</rss>
