在表中显示约束
您好,我正在尝试在我的一个表中显示约束,但由于某种原因,我收到消息“未选择行”。下面注明的是我创建的表格。
Create table Teams (
TeamID varCHAR2(4) constraint Teams_TeamID_PK Primary Key,
TeamName VARCHAR2(40)
);
这是我用来显示我的约束的代码。
SELECT constraint_name,
constraint_type,
search_condition
FROM USER_CONSTRAINTS
WHERE table_name = 'Teams';
我是一个新手,所以我想确保我明白出了什么问题。我试图删除该表,认为我的约束没有发生 - 我没有,在创建表并且我在另一个表中引用 TeamID 时也没有收到任何错误。因此,当我尝试删除该表时,我收到一条错误消息,这正是我所希望的。
Hello I am trying to display the constraints in one of my tables but for some reason I get the message no rows selected. Noted below is the table I have created.
Create table Teams (
TeamID varCHAR2(4) constraint Teams_TeamID_PK Primary Key,
TeamName VARCHAR2(40)
);
This is the code I am using to show my constraints.
SELECT constraint_name,
constraint_type,
search_condition
FROM USER_CONSTRAINTS
WHERE table_name = 'Teams';
I am a rookie so I want to make sure I understand what is wrong. I have tried to drop the table thinking that my constraints did not take - I did not, nor did I receive any errors when I created the table and I am referencing TeamID in another table. So when I try to drop the table I get an error message when is what I was hoping for.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
试试这个:
除非创建时使用双引号,否则 Oracle 中的所有对象名称都是大写的。
Try this:
Unless double-quoted when created, all object names in Oracle are upper case.
使用以下代码:
Use the following code:
我个人使用:
I personally use:
如果您更喜欢 CamelCase 名称,您的创建表脚本应该是:
没有双引号 Oracle 会有助于将所有标识符转换为大写:)
If you prefer the CamelCase names, your create table script should have been:
Without double-quotes Oracle helpfully converts all identifiers to uppercase :)
在单引号内的
where
子句中输入大写的表名称。例如
WHERE table_name = 'TEAMS';
Type the table name in upper case in
where
clause within the single quotes.e.g.
WHERE table_name = 'TEAMS';