Mysterious Dual ------ Black

xiaoxiao2021-03-06  65

Title Mysterious Dual Black_snail (original) Keyword Oracle Dual Dual? What is mystery? When you want to get an Oracle system time, you will not get a single line SQL? Therefore, I'm mysterious ....sql> select sysdate from dual; sysdate-- ------- 28-Sep-03 haha, it is really easy to use. But everyone knows what Dual is Object. Is there any special behavior? Come, let's take a look together. First of all What DUAL OBJECT: SQL> connect system / managerConnected.SQL> select owner, object_name, object_type from dba_objects where object_name like '% DUAL%'; oWNER oBJECT_NAME oBJECT_TYPE --------------- - -------------- ------------- Sys Dual TablePublic Dual Synonym It turned out that Dual is a table belonging to Sys Schema, then in the way as public synonym is available in other ways. Database User use. Take a look at its structure: SQL> Desc Dualname Null? Type ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------- ---------------------------- Dummy varcha2 (1) SQL> There is only one name called Dummy characters column. Then query the data in the table: SQL> Select Dummy from Dual; Dummy -------- X Oh, only one record, Dummy's value is' X '. Very normal, there is nothing strange. Ok, let's have a wonderful thing! Insert a record: SQL> Connect Sys as sysdbaconnected.sql> Insert Into Dual Values ​​(' Y ​​'); 1 row created.sql > commit; commit completion.sql> select count (*) from dual; count (*) ---------- 2 so far, everything is normal. However, when we query the record again, weird things SQL> SELECT * from Dual; Dummy ---------- The record just inserted did not show it! It has two records in the DUAL table, but only one is displayed! Delete, pay attention, full delete! SQL> delete from dual; / * Note no qualification, try to delete all records * / 1 row deleted.sql> commit; commit complete. Haha, only one record is deleted, SQL> SELECT *.

转载请注明原文地址:https://www.9cbs.com/read-119957.html

New Post(0)