oracle 将列值显式设置为空 SQL Developer

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7142577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 03:29:09  来源:igfitidea点击:

Explicitly set column value to null SQL Developer

oraclenulloracle11goracle-sqldeveloperplsqldeveloper

提问by Mark Estrada

I am new to Oracle DB and I am using Oracle SQL Developer (Ver 3.0.02) to query the DB. I wanted to explicitly set one column to null?

我是 Oracle DB 的新手,我正在使用 Oracle SQL Developer (Ver 3.0.02) 来查询 DB。我想明确地将一列设置为空?

How do I do that in the SQL Developer GUI?

如何在 SQL Developer GUI 中执行此操作?

Previously in MSSQL, clicking CTRL+0 will explicitly set the value to null. How about Oracle SQL Developer? Thanks

以前在 MSSQL 中,单击 CTRL+0 会将值显式设置为 null。Oracle SQL Developer 怎么样?谢谢

采纳答案by Leniel Maccaferri

If you want to use the GUI... click/double-click the table and select the Datatab. Click in the column value you want to set to (null). Select the value and delete it. Hit the commit button (green check-mark button). It should now be null.

如果要使用 GUI... 单击/双击表并选择Data选项卡。单击要设置为 的列值(null)。选择该值并将其删除。点击提交按钮(绿色复选标记按钮)。它现在应该为空。

enter image description here

在此处输入图片说明

More info here:

更多信息在这里:

How to use the SQL Worksheet in SQL Developer to Insert, Update and Delete Data

如何在 SQL Developer 中使用 SQL Worksheet 插入、更新和删除数据

回答by Ollie

You'll have to write the SQL DML yourself explicitly. i.e.

您必须自己明确地编写 SQL DML。IE

UPDATE <table>
   SET <column> = NULL;

Once it has completed you'll need to commit your updates

完成后,您需要提交更新

commit;

If you only want to set certain records to NULL use a WHERE clause in your UPDATE statement.

如果您只想将某些记录设置为 NULL,请在 UPDATE 语句中使用 WHERE 子句。

As your original question is pretty vague I hope this covers what you want.

由于您最初的问题非常模糊,我希望这涵盖了您想要的内容。

回答by Mostafa Vatanpour

Use Shift+Del.

使用 Shift+Del。

More info: Shift+Del combination key set a field to null when you filled a field by a value and you changed your decision and you want to make it null. It is useful and I amazed from the other answers that give strange solutions.

更多信息:当您用一个值填充一个字段并且您更改了您的决定并希望将其设为空时,Shift+Del 组合键会将一个字段设置为空。它很有用,我对提供奇怪解决方案的其他答案感到惊讶。

回答by Robert Bartlett

It is clear that most people who haven't used SQL Server Enterprise Manager don't understand the question (i.e. Justin Cave).

很明显,大多数没有使用过 SQL Server 企业管理器的人不明白这个问题(即 Justin Cave)。

I came upon this post when I wanted to know the same thing.

当我想知道同样的事情时,我来到了这篇文章。

Using SQL Server, when you are editing your data through the MS SQL Server GUI Tools, you can use a KEYBOARD SHORTCUT to insert a NULL rather than having just an EMPTY CELL, as they aren't the same thing. An empty cell can have a space in it, rather than being NULL, even if it is technically empty. The difference is when you intentionally WANT to put a NULL in a cell rather than a SPACE or to empty it and NOT using a SQL statement to do so.

使用 SQL Server,当您通过 MS SQL Server GUI 工具编辑数据时,您可以使用 KEYBOARD SHORTCUT 插入一个 NULL 而不是只有一个 EMPTY CELL,因为它们不是一回事。一个空单元格中可以有一个空格,而不是 NULL,即使它在技术上是空的。不同之处在于当您有意在单元格中放置 NULL 而不是 SPACE 或清空它时,而不是使用 SQL 语句来执行此操作。

So, the question really is, how do I put a NULL value in the cell INSTEAD of a space to empty the cell?

所以,真正的问题是,如何在空格的单元格 INSTEAD 中放置一个 NULL 值来清空单元格?

I think the answer is, that the way the Oracle Developer GUI works, is as Laniel indicated above, And THAT should be marked as the answer to this question.

我认为答案是,Oracle 开发人员 GUI 的工作方式,正如 Laniel 上面指出的那样,并且应该将其标记为这个问题的答案。

Oracle Developer seems to default to NULL when you empty a cell the way the op is describing it.

当您按照操作描述的方式清空单元格时,Oracle Developer 似乎默认为 NULL。

Additionally, you can force Oracle Developer to change how your null cells look by changing the color of the background color to further demonstrate when a cell holds a null:

此外,您可以通过更改背景颜色的颜色来强制 Oracle Developer 更改空单元格的外观,以进一步演示单元格何时包含空值:

Tools->Preferences->Advanced->Display Null Using Background Color

工具->首选项->高级->使用背景色显示空值

or even the VALUE it shows when it's null:

甚至是它在为空时显示的 VALUE:

Tools->Preferences->Advanced->Display Null Value As

工具->首选项->高级->空值显示为

Hope that helps in your transition.

希望对您的过渡有所帮助。