SQL Server Management Studio:为什么在插入表时,外键列不可见?

时间:2021-10-12 00:35:27

It's about SQL Server 2012 Management Studio. I'm training my SQL skills as manually create queries.

它是关于SQL Server 2012 Management Studio的。我正在训练我的SQL技能,比如手动创建查询。

Now I want to insert several records in the Users table. As you see there exists a column GroupID, which is a foreign key to another table Groups.

现在我想在Users表中插入几个记录。如您所见,存在一个列GroupID,它是另一个表组的外键。

SQL Server Management Studio:为什么在插入表时,外键列不可见?

However when I write a query:

然而,当我写一个查询:

insert into Users (Username, Pass, FullName, GroupID)
values ('Tyana', '17890', 'Tyana Stoyanov', 4)

I get an error:

我得到一个错误:

Invalid column name GroupID

无效列名GroupID

SQL Server Management Studio:为什么在插入表时,外键列不可见?

Why is that?

这是为什么呢?

3 个解决方案

#1


5  

Ctrl + Shift + R is the hotkey to refresh Intellisense. It should fix the problem.

Ctrl + Shift + R是刷新智能感知的热键。它应该能解决问题。

#2


0  

Have you tried [GroupID]? I meant whether or not you tried using brackets? Also, are you sure that GroupID is not an auto incremental field or something similar?

你有试过(GroupID)?我是说你是否试过用括号?另外,你确定GroupID不是一个自动递增的域或者类似的东西吗?

#3


0  

Have you tried executing this? I think it will execute properly. The error is indicated only because of non-refreshed intellisense.

你试过这么做吗?我认为它会正常执行。这个错误仅仅是因为没有刷新的智能感知。

#1


5  

Ctrl + Shift + R is the hotkey to refresh Intellisense. It should fix the problem.

Ctrl + Shift + R是刷新智能感知的热键。它应该能解决问题。

#2


0  

Have you tried [GroupID]? I meant whether or not you tried using brackets? Also, are you sure that GroupID is not an auto incremental field or something similar?

你有试过(GroupID)?我是说你是否试过用括号?另外,你确定GroupID不是一个自动递增的域或者类似的东西吗?

#3


0  

Have you tried executing this? I think it will execute properly. The error is indicated only because of non-refreshed intellisense.

你试过这么做吗?我认为它会正常执行。这个错误仅仅是因为没有刷新的智能感知。