Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Constraint on Update and Delete

Posted on 2007-03-30
6
Medium Priority
?
280 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 1500 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

609 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