In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Basic query
SQL >-- current user
SQL > show use
USER is "SCOTT"
SQL >-- the table under the current user
SQL > select * from tab
TNAME TABTYPE CLUSTERID
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
SQL >-- structure of the employee table
SQL > desc emp
Is the name empty? Types
EMPNO NOT NULL NUMBER (4)
ENAME VARCHAR2 (10)
JOB VARCHAR2 (9)
MGR NUMBER (4)
HIREDATE DATE
SAL NUMBER (7 dint 2)
COMM NUMBER (7 dint 2)
DEPTNO NUMBER (2)
SQL >-- clear the screen
SQL > host cls
SQL >-- query all employee information
SQL > select * from emp
EMPNO ENAME JOB MGR HIREDATE SAL COMMDEPTNO 7369 SMITH CLERK 7902 17-December-80 800 20 7499 ALLEN SALESMAN 7698 20-February-81 1600 300 30 7521 WARD SALESMAN 7698 22-February-81 1250 7698 30 EMPNO ENAME JOB MGR HIREDATE SAL COMMDEPTNO 7566 JONES MANAGER 7839 02-April-81 2975 20 7654 MARTIN SALESMAN 7698 28-September-81 1250 1400 30 7698 BLAKE MANAGER 7839 01-May-81 2850 30 EMPNO ENAME JOB MGR HIREDATE SAL COMMDEPTNO 7782 CLARK MANAGER 7839 09-June-81 2450 10 7788 SCOTT ANALYST 7566 19-April-87 3000 20 7839 KING PRESIDENT 17-November-81 5000 10 EMPNO ENAME JOB MGR HIREDATE SAL COMMDEPTNO 7844 TURNER SALESMAN 7698 08-September- 81 1500 0 30 7876 ADAMS CLERK 7788 23-May-87 1100 20 7900 JAMES CLERK 7698 03-December-81 950 30 EMPNO ENAME JOB MGR HIREDATE SAL COMMDEPTNO 7902 FORD ANALYST 7566 03-December-81 3000 20 7934 MILLER CLERK 7782 23-January-82 1300 10
14 rows have been selected.
SQL >-- set the line width
SQL > show linesize
Linesize 80
SQL > set linesize 120
SQL >-- set column width
SQL > col ename for A8
SQL > col sal for 9999
SQL > /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7369 SMITH CLERK 7902 17-December-80800 20 7499 ALLEN SALESMAN 7698 20-February-81 1600 300 30 7521 WARD SALESMAN 7698 22-February-81 1250 1250 30 7566 JONES MANAGER 7839 02-April-81 2975 20 7654 MARTIN SALESMAN 7698 28-September-81 1250 1400 30 7698 BLAKE MANAGER 7839 01-May-81 2850 30 7782 CLARK MANAGER 7839 09-June-81 2450 10 7788 SCOTT ANALYST 7566 19-April-87 3000 20 7839 KING PRESIDENT 17-November-81 5000 10 7844 TURNER SALESMAN 7698 08 -September-81 1500 0 30 7876 ADAMS CLERK 7788 23-May-87 1100 20 EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7900 JAMES CLERK 7698 03-December-81 950 30 7902 FORD ANALYST 7566 03-December-81 3000 20 7934 MILLER CLERK 7782 23-January -82 1300 10
14 rows have been selected.
SQL >-- by column name
SQL > select empno,ename,job,mgr,hiredate,sal,comm,deptno
2 from emp
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7369 SMITH CLERK 7902 17-December-80800 20 7499 ALLEN SALESMAN 7698 20-February-81 1600 300 30 7521 WARD SALESMAN 7698 22-February-81 1250 1250 30 7566 JONES MANAGER 7839 02-April-81 2975 20 7654 MARTIN SALESMAN 7698 28-September-81 1250 1400 30 7698 BLAKE MANAGER 7839 01-May-81 2850 30 7782 CLARK MANAGER 7839 09-June-81 2450 10 7788 SCOTT ANALYST 7566 19-April-87 3000 20 7839 KING PRESIDENT 17-November-81 5000 10 7844 TURNER SALESMAN 7698 08 -September-81 1500 0 30 7876 ADAMS CLERK 7788 23-May-87 1100 20 EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7900 JAMES CLERK 7698 03-December-81 950 30 7902 FORD ANALYST 7566 03-December-81 3000 20 7934 MILLER CLERK 7782 23-January -82 1300 10
14 rows have been selected.
SQL > / *
Principles for SQL > SQL optimization:
SQL > 1. Use column names as much as possible
SQL > * /
SQL > host cls
SQL >-- query employee information: employee number, name, monthly salary
SQL > select empno,ename,sal
2 form emp
Form emp
*
An error occurred on line 2:
ORA-00923: no required FROM keyword found
SQL >-- c command change
SQL > 2
2 * form emp
SQL > c / form/from
2 * from emp
SQL > /
EMPNO ENAME SAL
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.