如何修改表

发布于 2024-08-03 05:10:23 字数 1281 浏览 4 评论 0原文

CREATE TABLE [dbo].[INVS_ITEM_LOCATIONS](
    [DEPARTMENT_CODE] [varchar](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [IM_INV_NO] [numeric](10, 0) NOT NULL,
    [LOCATION_CODE] [varchar](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CURR_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__CURR___1352D76D]  DEFAULT ((0)),
    [DO_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__DO_QT__1446FBA6]  DEFAULT ((0)),
    [ALLOC_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__ALLOC__153B1FDF]  DEFAULT ((0)),
    [YOB_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__YOB_Q__162F4418]  DEFAULT ((0)),
    [FOC_QTY] [numeric](10, 0) NULL CONSTRAINT [DF__INVS_ITEM__FOC_Q__17236851]  DEFAULT ((0)),
    [USER_CREATED] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [DATE_CREATED] [datetime] NOT NULL,
    [USER_MODIFIED] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [DATE_MODIFIED] [datetime] NULL,
 CONSTRAINT [INVS_ITEM_LOCATIONS_PK] PRIMARY KEY CLUSTERED 
(
    [DEPARTMENT_CODE] ASC,
    [IM_INV_NO] ASC,
    [LOCATION_CODE] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

这是我的表名,如何删除 im_inv_ni 和 location_ 代码中的主键

,而且我应该将外键添加到 im_inv_no....请帮助

CREATE TABLE [dbo].[INVS_ITEM_LOCATIONS](
    [DEPARTMENT_CODE] [varchar](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [IM_INV_NO] [numeric](10, 0) NOT NULL,
    [LOCATION_CODE] [varchar](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CURR_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__CURR___1352D76D]  DEFAULT ((0)),
    [DO_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__DO_QT__1446FBA6]  DEFAULT ((0)),
    [ALLOC_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__ALLOC__153B1FDF]  DEFAULT ((0)),
    [YOB_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__YOB_Q__162F4418]  DEFAULT ((0)),
    [FOC_QTY] [numeric](10, 0) NULL CONSTRAINT [DF__INVS_ITEM__FOC_Q__17236851]  DEFAULT ((0)),
    [USER_CREATED] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [DATE_CREATED] [datetime] NOT NULL,
    [USER_MODIFIED] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [DATE_MODIFIED] [datetime] NULL,
 CONSTRAINT [INVS_ITEM_LOCATIONS_PK] PRIMARY KEY CLUSTERED 
(
    [DEPARTMENT_CODE] ASC,
    [IM_INV_NO] ASC,
    [LOCATION_CODE] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

this is my table name how can i delete primary key in im_inv_ni and location_ code

and also i should add foriegn key to im_inv_no....pls help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

还给你自由 2024-08-10 05:10:23

您可以使用 ALTER TABLE 语句。更多信息请访问 http://ss64.com/ora/table_a_cons.html

所需的语句是

ALTER TABLE [dbo].INVS_ITEM_LOCATIONS DROP PRIMARY KEY;
ALTER TABLE [dbo].INVS_ITEM_LOCATIONS ADD CONSTRAINT <name of fk> FOREIGN KEY (<columns>) REFERENCES <table>(<columns>);

You can use the ALTER TABLE -statements. More information can be found here http://ss64.com/ora/table_a_cons.html.

The needed statements are

ALTER TABLE [dbo].INVS_ITEM_LOCATIONS DROP PRIMARY KEY;
ALTER TABLE [dbo].INVS_ITEM_LOCATIONS ADD CONSTRAINT <name of fk> FOREIGN KEY (<columns>) REFERENCES <table>(<columns>);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文