Solved

Constraint on Update and Delete

Posted on 2007-03-30
6
222 Views
Last Modified: 2010-03-20
Hi

I am trying to write a create statement whereby I create a new table with two constraints.  They are that there can be no updates or deletes.  I know that the syntax for constraints is CONSTRAINT XXX, but am not quite sure on how to use it.  Here is my current statement:

CREATE TABLE  `ordertbl` (
  `OrdNo` varchar(8) NOT NULL,
  `OrdDate` date NOT NULL,
  `CustNo` varchar(8) NOT NULL,
  `EmpNo` varchar(8) default NULL,
  PRIMARY KEY  (`OrdNo`));

Greg
0
Comment
Question by:greg_c
6 Comments
 
LVL 7

Expert Comment

by:jeepstyx22
ID: 18827764
Couldn't you just remove Update and Delete rights from the table?  See this MSDN page on denying permssions: http://msdn2.microsoft.com/en-us/library/ms177518.aspx

Also, you can view this forum,http://www.webservertalk.com/archive132-2005-7-1147074.html, which has a few ideas for locking down these things.
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18828248
in addition to DENY the UPDATE and DELETE to the users, you could also implement a trigger that rollsback any updates/deletes.
you cannot implement this with constraints.
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 18828528
you can't do that with constraints as angeliii says... a trigger is the only ultimate safeguard...

what are you actually trying to do?  
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:greg_c
ID: 18829735
I am trying to prevent a user from updating and deleting a row, through SQL.

Greg
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18832918
So I repeat my comment:
in addition to DENY the UPDATE and DELETE to the users, you could also implement a trigger that rollsback any updates/deletes.
do you need help with those?
0
 

Author Comment

by:greg_c
ID: 18833057
No, Thanks for your help.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now