请问下用SQL语句为表添加约束可不可用用判断

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请问下用SQL语句为表添加约束可不可用用判断相关的知识,希望对你有一定的参考价值。

在数据库中 ,在用SQL语句创建库和创建表之前可以用if exists来判断
但是用if exists在添加约束之前不行,请问添加约束之前可bu可以判断。
如果可以 请告诉一下方法 谢谢!!!

参考技术A SQL语言,数据库基础电子资料:

SQL语法大全中文版
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148128
SQL语言案头完全参考手册
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146159
SQL - A Practical Introduction
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148095
O'Reilly SQL Tuning
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=159156
O'Reilly The Art of SQL
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=163611
数据库综合资料库
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146238
数据库设计指南
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148082
Wrox Beginning Database Design
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=145206
SQL Puzzles and Answers
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=160834
SQL Queries for Mere Mortals
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=162978
SQL Puzzles and Answers
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=160834
Apress出版 The Berkeley DB Book
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=168290
The Handbook of Data Mining
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=176600
数据库系统概论 浙江大学张军教授主讲(全32讲)
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=154299

MS SQL Server电子资料:

Transact-SQL Cookbook
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=163150
SQL Server 2005宝典
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=149644
Microsoft SQL Server 2005完全参考
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152872
O'Reilly Learning SQL on SQL Server 2005
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=163464
Beginning SQL Server 2005 Programming
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=153216
Pro SQL Server 2005 High Availability
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=162981
Beginning SQL Server 2005 Administration
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152863
SQL Server 2005 Management and Administration
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=176845
SQL Server 2005 Unleashed
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152874
Pro SQL Server 2005
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152325
A Developer's Guide to SQL Server 2005
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=145565
Pro T-SQL 2005 Programmer's Guide
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=154245
Beginning Transact-SQL with SQL Server 2000 and 2005
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152868
SQL Server 2005报表服务
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148376
Wrox Professional SQL Server 2005 Programming
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=151270
Scaling Out SQL Server 2005权威指南
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=162785
Sql Server 2005 Performance Optimiztion and Tuning Handbood
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=165048
Microsoft SQL Server 2005编程傻瓜书
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152864
Pro SQL Server 2005 Assemblies
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=151269
MS SQL Server 2005 Reporting Essentials
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=147862
SQL Server 2005工具箱内幕
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152321
SQL Server 2005管理员手册
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152347
SQL Server 2005工具箱内幕
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152321
SQL Server 2005数据挖掘
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148099
Pro SQL Server 2005 Service Broker
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=159656
Pro SQL Server 2005 Replication
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=160606
Sql server 2005的XML最佳实施策略
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152278
Microsoft SQL Server Black Book
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=163457
MS SQL Server2000 宝典
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=145853
SQL Server 2000存储过程和XML编程
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152873
SQL Server 2005高级数据分析视频教程系列
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=162737
SQL Server 2005盛宴系列视频 全52讲
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=151642

mysql电子资料:

MySQL宝典
http://bbs.topsage.com/dispbbs_122_159157_1.html
SQL for MySQL Developers
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152862
MySQL教程
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146824
Teach Yourself MySQL in 10 Minutes
http://bbs.topsage.com/dispbbs_122_174432_1.html
O'Reilly MySQL Pocket Reference 第二版 PDF
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=175014
MySQL 5 权威指南(第三版)
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148867
MySQL培训经典教程
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146795
MySQL Cookbook 第二版
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=175972
The Definitive Guide to MySQL
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=175382
O'Reilly MySQL Pocket Reference 第二版
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=175014
MySQL Essential Skills
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146749
MySQL Administrators Guide
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=146580
MySQL权威指南 中文版+英文版
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148870
MySQL 4.1.0 中文参考手册
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148869
MySQL in a Nutshell
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=148868
Export MySQL
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152865
MySQL and php from Scratch
http://bbs.topsage.com/dispbbs.asp?boardID=122&ID=152162
参考技术B 当然可以,数据库中有系统表记录这些约束 的,不知你用的是什么数据库,你可以自己找找 参考技术C SQL-server数据库中,约束都保存在你当前库的系统表sysobjects表中,例如要添加约束:
if exists(select * from sysobjects where name=约束名)
drop constraint 约束名
alter table 表名
add constraint 约束本回答被提问者采纳
参考技术D 愿意的话等我半年。如今我刚学VFP,之后考级。现在我无能为力哦。

以上是关于请问下用SQL语句为表添加约束可不可用用判断的主要内容,如果未能解决你的问题,请参考以下文章

oracle建表

sql server 判断记录存在更新不存在插入

ORACLE语句怎么删除外键约束,只是删约束,不是删表

sql怎么设置外键

SQL语句

oracle 有记录就更新没有添加问题