需要帮助的SQL Server 2005 [英] need help for sql server 2005

查看:63
本文介绍了需要帮助的SQL Server 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友

我是新手,所以我不知道如何开始我的问题?我需要有关外键约束的帮助,或者说加入2个表.请为我找到一个源代码.

Ridhi Shrestha

Friends

I am new, so I don''t konw how to start my question ? I need help for foreign key constraint or say join 2 tables. please find me a source code for this.

Ridhi Shrestha

推荐答案

Ridhi,

http://www.java2s.com/Code/SQLServer/Constraints/Howtouseforeignkeyconstraints.htm [ ^ ]

http://www.1keydata.com/sql/sql-foreign-key.htm [ ^ ]

http://www.sql-tutorial.net [
Hi Rid

http://www.java2s.com/Code/SQLServer/Constraints/Howtouseforeignkeyconstraints.htm[^]

http://www.1keydata.com/sql/sql-foreign-key.htm[^]

http://www.sql-tutorial.net[^]

Refer those links.

In my suggestion first you can learn basics of sql.There are lot of books available in online.Search in google.

Cheers :)


好吧,外键并不是真正的联接"表,它们是关联"表,也是创建外键约束有用的主要原因表中的表用作检查机制,以防止通过诸如删除表等之类的动作而导致相关表中的数据的动作

以下是显示带有外键缺点的表的基本sql代码.
ok first, Foreign keys do not really ''join'' tables, they rather ''relate'' tables and the main reason why it is useful to create foreign key constraint in a table is serve as a checking mechanism to prevent actions that will cause data in a related table through an action like dropping a table etc

Below is a basic sql code showing a table with a foreign key cons.
CREATE TABLE Orders
(
O_Id int NOT NULL,
OrderNo int NOT NULL,
P_Id int,
PRIMARY KEY (O_Id),
FOREIGN KEY (P_Id) REFERENCES Persons(P_Id)
)



但是在连接两个表(以某种扩展名)时,您将不得不使用sql joins,如果您还不了解sql,我将推荐您使用google进行阅读. sql union ..:)



but in joining two tables (in a sort of extension), then you would have to use sql joins, which if you dont have any knowledge of yet, I would edge you to do google it up and read..Also check up the sql union..:)


Ridhi Shrestha,

遵循以下链接

http://www.1keydata.com/sql/sql-foreign-key.html

http://www.mssqlcity.com/Articles/General/using_constraints.htm
Hi Ridhi Shrestha,

follow the below links

http://www.1keydata.com/sql/sql-foreign-key.html

http://www.mssqlcity.com/Articles/General/using_constraints.htm


Table CUSTOMER
column name characteristic
------------ ------------
SID int Primary Key
Last_Name varchar(50)
First_Name varchar(50)

Table ORDERS

CREATE TABLE ORDERS
(Order_ID integer primary key,
Order_Date datetime,
Customer_SID int references CUSTOMER(SID),
Amount money)


Cheers :)


这篇关于需要帮助的SQL Server 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆