Dual table instances used in oracle, mysql, and hive, dualhive
The concept of dual table comes from oracle. dual is a virtual table, which is initialized together with the data dictionary when the database is created. This table has only one field named dummy in varchar2 (string in hive, oracle/mysql ensures that there is always only one record in dual, which is used to query some system information to form the select syntax rules ,. We can use it to do many things. We can use desc dual to view them.
Functions:
1. view the current user. You can execute the following statement in SQL Plus.
SQL code
Select user from dual;
2. Used to call system functions
SQL code
Select to_char (sysdate, 'yyyy-mm-dd hh24: mi: ss') from dual; -- get the current system time
Select dbms_random.random from dual; -- obtain a random number
3. It can be used as a calculator.
SQL code
Select 7*9 from dual
Dual is used in hive: to test some time, mathematics, and aggregate functions in hive, you can create a dual table like oracle.
Hive> create dual (dummy String );
Hadoop100 @ robot] $ echo 'A'>/home/hadoop/dual.txt
Hive> load data local inpath '/home/hadoop/dual.txt' overwrite into table dual;
. For example:
Select round (21.2) from dual;