在对象资源管理器中看不到创建的表 - Microsoft SQL Management Studio

2021-09-10 00:00:00 sql tsql sql-server

我正在尝试在数据库中创建一些表,但是这些表没有出现在我的对象资源管理器视图中.

I am trying to create some tables within a database, however the tables are not appearing in my object explorer view.

我的代码如下:

use testDB
GO

create table dbo.teacher (id varchar(5), name varchar(24));
insert into teacher values ('dm112', 'Magro, Deirdre');
insert into teacher values ('je232', 'Elkner, Jeff');
insert into teacher values ('cm147', 'Meyers, Chris');
insert into teacher values ('kr387', 'Reed, Kevin');


create table dbo.course (
    number varchar(6),
    name varchar(24),
    credits int,
    teacherid varchar(6) 
);
insert into course values ('SDV100', 'College Success Skills', 1, 'dm112');
insert into course values ('ITD110', 'Web Page Design I', 3, 'je232');
insert into course values ('ITP100', 'Software Design', 3, 'je232');
insert into course values ('ITD132', 'Structured Query Language', 3, 'cm147');
insert into course values ('ITP140', 'Client Side Scripting', 4, 'kr378');
insert into course values ('ITP225', 'Web Scripting Languages', 4, 'kr387');


create table dbo.student (id varchar(3), name varchar(24));
insert into student values ('411', 'Perez, Gustavo');
insert into student values ('412', 'Rucker, Imani');
insert into student values ('413', 'Gonzalez, Alexis');
insert into student values ('414', 'Melgar, Lidia');


create table dbo.enrolled (studentId varchar(3), courseNumber varchar(6));
insert into enrolled values ('411', 'SDV100');
insert into enrolled values ('411', 'ITD132');
insert into enrolled values ('411', 'ITP140');
insert into enrolled values ('412', 'ITP100');
insert into enrolled values ('412', 'ITP14p');
insert into enrolled values ('412', 'ITP225');
insert into enrolled values ('413', 'ITD132');
insert into enrolled values ('413', 'ITP225');
insert into enrolled values ('414', 'SDV100');
insert into enrolled values ('414', 'ITD110');

我在发帖前查了一下,发现了这个确切的问题:

I looked this up before posting and found this exact question:

使用 T- 创建表SQL - 在对象资源管理器中看不到创建的表

但是,他使用的是tempdb",而我不是.

However, he was using "tempdb", which I am not.

我运行了查询

select name, type_desc from testDB.sys.objects

返回:

name          type_desc
---------------------------
...
teacher       USER_TABLE
course        USER_TABLE 
student       USER_TABLE
enrolled      USER_TABLE
...

我可以对这些表进行修改、选择、删除等操作,但我看不到它们.我错过了什么吗?另一个问题提出了测试"和生产"的前景?他们没有详细说明,谷歌也没有帮助我

I can modify, select, drop, etc. on these tables, but I cannot see them. Am I missing something? Another question brought up the prospect of "test" and "production"? They didn't go into much detail and google did not help me

:(

感谢您提供的任何帮助.

Thank you for any help you can offer.

下面的卡尔找到了解决方案!尽管在对象资源管理器上单击刷新 (F5) 不会更新数据库视图,但右键单击数据库并单击刷新会更新表.

Karl below found the solution! Although clicking refresh (F5) on the object explorer does not update the database view, right clicking on the database and clicking refresh updates the tables.

推荐答案

如果您在对象资源管理器中打开了表节点并且在运行 DDL 后不刷新,则会发生这种情况.令人讨厌的是,SSMS 在 DDL 后不会自动刷新资源管理器.可通过对象资源管理器中的右键单击上下文菜单进行刷新.

This would happen if you have the tables node open in object explorer and don't refresh after running your DDL. It is annoying that SSMS doesn't autorefresh explorer after DDL. Refresh is available via the right-click context menu in object explorer.

相关文章