Oracle SQL Question Answer notes

Source: Internet
Author: User

To be verified 1. Create a student information sheet student_info, which contains the following information: School number, name, gender, birthday, home address, contact phone number; Create a student score table student_score  contains the number, subject, achievement. Create table student_info (ID&NBSP;INT,NAME&NBSP;VARCHAR2), SEX&NBSP;VARCHAR2 (4), Brithday DATE , Address varchar2 (+), phone int); Create table student_score (ID&NBSP;INT,SUBJECT&NBSP;VARCHAR2), Score number (4,1)), 2, according to two tables in the title , create a new table TEST that contains the following information: study number, name, subject, Grade create table test as select a.id,a.name,b.subject, B.score from student_info a,student_score b;3, the result will be converted according to the character query, the rule is: ' A ' is converted to ' male ', ' B ' is converted to ' female ', the other characters are converted to ' Unknown ', try writing out a SQL statement. insert into student_info values  (1100, ' AAA ', ' A ', to_date (' 1990/3/3 12:12:12 ', ' yyyy/mm/ Dd hh24:mi:ss '), ' ASDG ', 333); Select decode (Sex, ' A ', ' Male ', ' B ', ' female ', ' other ')  from student_info;4, extract the topic 1, the student Zhang San of the various subjects, need the following information: study number, name, subject, Grades, sorted in descending order of grades. Select a.id,a.name,b.subject,b.score from student_info a,student_score b where  a.id=b.id and a.name=' Zhang San '  order by b.score desc;5, Title 1 table, according to the students overall score from high to low rankings, if the same results are ranked the same, output fields: Rank, school number, name, total. Select dense_rank ()  over (Order by sum (b.score)  desc)  dense_rank,a.id,a.name,sum ( B.score)  total FROM student_info a,student_score b WHERE a.id=b.id  The Group by a.name,a.id①row_number:row_number function returns a unique value that, when the same data is encountered, is incremented sequentially in the order in which the records are recorded in the recordset. The  ②dense_rank:dense_rank function returns a unique value unless all the same data is ranked the same at the time when the same data is encountered. The  ③rank:rank function returns a unique value, except that when the same data is encountered, all the same data is ranked the same at the same time, and the rank between the last same record and the next record rank is vacated. Http://www.cnblogs.com/wuyisky/archive/2010/02/24/oracle_rank.html6. Topic 1, the hypothesis that disciplines contain ' language ', ' English ', ' mathematics ', ' geography ', Please output students ' academic number   name   language   English   math   geography   Total score xxx xxx 70 70 70 70 in the following format  280SELECT A.ID,       A.NAME,        sum (DECODE (b.subject,  ' language ',  score, null)  AS  Chinese,  --there are no single quotes       &Nbsp; sum (DECODE (b.subject,  ' mathematics ',  score, null))  AS  Mathematics,        sum (DECODE (b.subject,  ' English ',  score, null))  AS  English,        sum (DECODE (b.subject,  ' geography ',  score, null))  AS  geography,        sum (B.score)  total  from student_info a, student_ score b where a.id = b.id group by a.name, a.id;http:// BLOG.163.COM/MAGICC_LOVE/BLOG/STATIC/185853662201371481247696/7, the topic 1 table, to find out the average grade of each discipline, request descending sort Select b.subject, AVG (B.score)  average from student_info a,student_score b where a.id=b.id  group by b.subject order by average desc8, what is the difference between the two ends of the code select cust.*, Pos.bus_descfrom dw_ods.s00_sema_scmcustp custleft join dw_pdm.t99_pos_code poson  cust.cust_pos_code=pos.pos_cOdeand cust.dw_etl_date= ' 2013-07-31 '::d ate; data that meets both conditions will be rolled up select cust.*,pos.bus_descfrom dw_ Ods.s00_sema_scmcustp custleft join dw_pdm.t99_pos_code poson cust.cust_pos_code= Pos.pos_codewhere cust.dw_etl_date= ' 2013-07-31 '::d ate; data that meets the above criteria are aggregated, from which 9 of the following data are taken, one table test, and only one field, col, A total of 4 records, namely A,b,c,d, corresponding to four teams, now four teams to play, with an SQL statement to show all possible match combinations. select a.col,b.col from test a ,test b where a.col<b.col;10, with Table dm_ ACRM.TEST01, data structure for Class (class), school Number (Id_number), Math score (math), English score (Chinese) table the following:  (note: The bottom right corner of the water is obscured by the C02), please summarize the number of each class, Average scores in math, English averages, and calculation of the number of students, average scores in math, English averages (recommended rollup). Select count (Id_number), AVG (Match), AVG (中文版)  FROM dm_acrm.test01 GROUP BY  Rollup (CLASS); Http://blog.itpub.net/519536/viewspace-610995/11, with a table test with field Customer ID (cust_id) and transaction date (Txn_dte), The table structure is as follows Create test (cust_id numberic,txn_dte date) distributed by (cust_id); Assuming that the table contains more than TENS data (cannot be associated with a table), generate a table containing the customer ID, the transaction date, and the lastEasy date. /*distributed by keyword found is the GP database related, later encountered, * * A company's data development junior engineer written questions: first, the SQL statement is known to 3 tables of the relationship mode:s  (sno,sname)   student relations. sno ,sname  is the name c  (cno,cname,cteacher)   curriculum relationship for the school number. cno  for the course number,cname  for the course name,cteacher  for the instructor SC (sno,cno,scgrade)   elective relationship. scgrade  to achieve the following 5 processing requirements: 1.   Find out the names of all students who have not been enrolled in the "Li Ming" teacher course 2.   Lists the names of students with two or more (including two) failed courses and their average score of 3.   List all students who have studied the "1" course and have studied the "2" course for 4.   List "1" class scores than the "2" students in the course of the high scores of all the student's school number 5.   List the academic numbers of all students with "1" class scores higher than "2" and their "1" and "2" class scores 1. select sname  from s where  SNAME !=  (select a.sname                   FROM S A, C B, SC C                  where a.sno  = C.SNO                    and b.cno = C.CNO                    AND B.CTEACHER =  ' Li Ming '); 2. select a.sname, avg (C.scgrade)   FROM S A, C B, SC C WHERE A.SNO = C.SNO    AND B.CNO = C.CNO   AND  (Select count (C.CNO)            FROM S A, C B, SC C          WHERE A.SNO = C.SNO            AND B.CNO = C.CNO            AND C.SCGRADE < 60          group by a.sname)  >= 2 group by a.sname3. select a.sname   from s&nbsp a, c b, sc c where a.sno = c.sno   and b.cno  = c.cno   and  (select b.cno           FROM S A, C B, SC C          where a.sno = c.sno           and &NBSP;B.CNO&NBSP;=&NBSP;C.CNO)  = 1   AND  (select b.cno           FROM S A, C B, SC C          WHERE A.SNO = C.SNO       &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;AND&NBSP;B.CNO&NBSP;=&NBSP;C.CNO)  = 2;4. SELECT A.SNO   FROM S A, C B, SC C WHERE A.SNO = C.SNO    and b.cno = c.cno   and  (SELECT&NBSP;C.SCGRADE&NBSP;FROM&NBSP;SC)  >         (Select c.scgrade          from  S A, C B, SC C         WHERE  a.sno = c.sno           and b.cno =  c.cno           and a.sno = 2 &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;AND&NBSP;B.CNO&NBSP;=&NBSP;1) 5.   select a.sno, c.scgrade          from s  a, c b, sc c         where a.sno =  c.sno           and b.cno = c.cno            AND A.SNO =                 (select a.sno                   from s a, c b,  SC C                  WHERE A.SNO = C.SNO                    AND B.CNO = C.CNO                    AND  (SELECT &NBSP;C.SCGRADE&NBSP;FROM&NBSP;SC&NBSP;WHERE&NBSP;CNO&NBSP;=&NBSP;1)  >                         ( select c.scgrade from SC&NBSP;WHERE&NBSP;CNO&NBSP;=&NBSP;2))            and  C.CNO IN  (1,&NBSP;2), frequently asked Questions Summary: 1, how to use the temporary table in the stored procedure? 2. Dictate how the stored procedure is written 3. Do you understand Oracle table partitioning? What are the pros and cons of it? 4. What are the partitioning types for Oracle table partitioning? How do you know how to do it? 5. Talk about your understanding of the implementation plan, what part of the implementation plan do you mainly look at? 6. What do you think of SQL statement optimization, can you say several optimization methods? 7. How does the Oracle Optimizer handle table connections internally? What kinds are there? 8. Will the window function be used? Say something about your window function, aggregation function, analysis function Understanding 9, what are the properties of the cursor? What are the ways that explicit and implicit cursors are used? 10, plsql block how to catch abnormal? Can you tell a few common pre-defined exceptions? 11. How do custom exceptions work in Plsql blocks? 12. Do you understand the view? What are the pros and cons of a view? 13, if let you develop a report, the amount of data is small, how will you achieve it? Let the data of the report show up? 14. Have you heard of Hash join? (After answering   understanding  , continue to cross-examine   there are several ways to connect, you know? Say a look)   (this is actually similar to 7, hash connection This thing I interviewed 4 times was asked 3 times, impressive) 15, have you ever contacted a database in school? Do you understand the architecture of your database? 16. Do you know what the SGA and PGA are respectively? 17, have you tried to write a trigger? Can the trigger be roughly described? 18. What is the difference between a function and a stored procedure? 19. Do you understand the function? Say a few common functions 20, (say Sum, COUNT, AVG, etc.) know InStr and substr? What is their role? 22, (the interviewer took out a book) write about the basic structure of the Decode function (Decode (Valus,if1,then1,if2,then2 ... ) 23, what do OLAP and OLTP refer to separately? 24, talk about your understanding of the index 25, what is the difference between delete and truncate 26, the authorization and revocation of the permission to use the instructions respectively? 27. What is the difference between rowID and rownum? 28. How does the paging SQL statement section in the paging stored procedure be written? Can we just select * from&nbsp first?;table_name where rownum>=6  and then rownum<=10. (answer can not be questioned after   why?) 29. What are the packages used in Oracle jobs? (Cross-examine   run jobs, delete jobs to use the package is?) 30. What is your Oracle's development prospects? 31, if one day Oracle company collapsed, what choice would you make? 32. Do you know what Oracle's highest certification is? (Answer: OCM, cross-examine: Do you want to reach this height?) Answer: Think, cross-examine: But do you know how many people through OCM China? This height is the height of the senior DBA, some people will not reach the end of life, when you are forced by reality, you choose to give up? PS: The examiner was very sharp, the expression is very serious, the heart is very excited, a layer of cross-examination, asked me all want to cry, a little fresh students, in order to dream out, easy ... )


Oracle SQL Question Answer notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.