Solved

Constraint on Update and Delete

Posted on 2007-03-30
6
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 143

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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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 143

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
T-SQL: New to using transactions 9 55
SQL Use Distinct with two fields 3 21
CSV How to add columns based on existing column(s)? 20 39
Please explain Equi-join 3 17
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…

696 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