Which of the following is not a data type for applying the single row function?
Using single row functions to customize output from Syed Zaid Irshad Show
Single-row functions return a single result row for every row of a queried table or view. These functions can appear in select lists, Character Functions Returning Character ValuesCharacter functions that return character values return values of the following data types unless otherwise documented:
The length of the value returned by the function is limited by the maximum length of the data type returned.
The character functions that return character values are: CHR CONCAT INITCAP LOWER LPAD LTRIM NCHR NLS_INITCAP NLS_LOWER NLS_UPPER NLSSORT REGEXP_REPLACE REGEXP_SUBSTR REPLACE RPAD RTRIM SOUNDEX SUBSTR TRANSLATE TRANSLATE ... USING TRIM UPPER Character Functions Returning Number ValuesCharacter functions that return number values can take as their argument any character data type. The character functions that return number values are: ASCII INSTR LENGTH REGEXP_COUNT REGEXP_INSTR General Comparison FunctionsThe general comparison functions determine the greatest and or least value from a set of values. The general comparison functions are: GREATEST LEAST Hierarchical FunctionsHierarchical functions applies hierarchical path information to a result set. The hierarchical function is: SYS_CONNECT_BY_PATH Encoding and Decoding FunctionsThe encoding and decoding functions let you inspect and decode data in the database. The encoding and decoding functions are: Each query portion of a statement is called a query block. The input to the query transformer is a parsed query, which is represented by a set of query blocks. In the following example, the SQL statement consists of two query blocks. The subquery in parentheses is the inner query block. The outer query block, which is the rest of the SQL statement, retrieves names of employees in the departments whose IDs were supplied by the subquery. SELECT first_name, last_name FROM employees WHERE department_id IN (SELECT department_id FROM departments WHERE location_id = 1800); The query form determines how query blocks are interrelated. The transformer determines whether it is advantageous to rewrite the original SQL statement into a semantically equivalent SQL statement that can be processed more efficiently. The query transformer employs several query transformation techniques, including the following: Any combination of these transformations can apply to a given query. 11.1.2.1.1 View MergingEach view referenced in a query is expanded by the parser into a separate query block. The block essentially represents the view definition, and thus the result of a view. One option for the optimizer is to analyze the view query block separately and generate a view subplan. The optimizer then processes the rest of the query by using the view subplan to generate an overall query plan. This technique usually leads to a suboptimal query plan because the view is optimized separately. In view merging, the transformer merges the query block representing the view into the containing query block. For example, suppose you create a view as follows: CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50; You then query the view as follows: SELECT employee_id FROM employees_50_vw WHERE employee_id > 150; The optimizer can use view merging to transform the query of CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50;2 into the following equivalent query: SELECT employee_id FROM employees WHERE department_id = 50 AND employee_id > 150; The view merging optimization applies to views that contain only selections, projections, and joins. That is, mergeable views do not contain set operators, aggregate functions, CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50;3, CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50;4, CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50;5, and so on. To enable the optimizer to use view merging for any query issued by the user, you must grant the CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50;6 CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50;7 CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50;8 privilege to the user. Grant the CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50;6 CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50;8 privilege to a user on specific views to enable the optimizer to use view merging for queries on these views. These privileges are required only under specific conditions, such as when a view is not merged because the security checks fail. 11.1.2.1.2 Predicate PushingIn predicate pushing, the optimizer "pushes" the relevant predicates from the containing query block into the view query block. For views that are not merged, this technique improves the subplan of the unmerged view because the database can use the pushed-in predicates to access indexes or to use as filters. For example, suppose you create a view that references two employee tables. The view is defined with a compound query that uses the SELECT employee_id FROM employees_50_vw WHERE employee_id > 150;1 set operator, as follows: CREATE VIEW all_employees_vw AS ( SELECT employee_id, last_name, job_id, commission_pct, department_id FROM employees ) UNION ( SELECT employee_id, last_name, job_id, commission_pct, department_id FROM contract_workers ); You then query the view as follows: SELECT last_name FROM all_employees_vw WHERE department_id = 50; Because the view is a compound query, the optimizer cannot merge the view's query into the accessing query block. Instead, the optimizer can transform the accessing statement by pushing its predicate, the SELECT employee_id FROM employees_50_vw WHERE employee_id > 150;2 clause condition SELECT employee_id FROM employees_50_vw WHERE employee_id > 150;3, into the view's compound query. The equivalent transformed query is as follows: SELECT last_name FROM ( SELECT employee_id, last_name, job_id, commission_pct, department_id FROM employees WHERE department_id=50 UNION SELECT employee_id, last_name, job_id, commission_pct, department_id FROM contract_workers WHERE department_id=50 ); 11.1.2.1.3 Subquery UnnestingIn subquery unnesting, the optimizer transforms a nested query into an equivalent join statement, and then optimizes the join. This transformation enables the optimizer to take advantage of the join optimizer technique. The optimizer can perform this transformation only if the resulting join statement is guaranteed to return exactly the same rows as the original statement, and if subqueries do not contain aggregate functions such as SELECT employee_id FROM employees_50_vw WHERE employee_id > 150;4. For example, suppose you connect as user SELECT employee_id FROM employees_50_vw WHERE employee_id > 150;5 and execute the following query: SELECT * FROM sales WHERE cust_id IN ( SELECT cust_id FROM customers ); Because the SELECT employee_id FROM employees_50_vw WHERE employee_id > 150;6 is a primary key, the optimizer can transform the complex query into the following join statement that is guaranteed to return the same data: SELECT sales.* FROM sales, customers WHERE sales.cust_id = customers.cust_id; If the optimizer cannot transform a complex statement into a join statement, it selects execution plans for the parent statement and the subquery as though they were separate statements. The optimizer then executes the subquery and uses the rows returned to execute the parent query. To improve execution speed of the overall query plan, the optimizer orders the subplans efficiently. 11.1.2.1.4 Query Rewrite with Materialized ViewsA materialized view is like a query with a result that the database materializes and stores in a table. When the database finds a user query compatible with the query associated with a materialized view, then the database can rewrite the query in terms of the materialized view. This technique improves query execution because most of the query result has been precomputed. The query transformer looks for any materialized views that are compatible with the user query and selects one or more materialized views to rewrite the user query. The use of materialized views to rewrite a query is cost-based. That is, the optimizer does not rewrite the query if the plan generated without the materialized views has a lower cost than the plan generated with the materialized views. Consider the following materialized view, SELECT employee_id FROM employees_50_vw WHERE employee_id > 150;7, which aggregates the dollar amount sold each month: CREATE MATERIALIZED VIEW cal_month_sales_mv ENABLE QUERY REWRITE AS SELECT t.calendar_month_desc, SUM(s.amount_sold) AS dollars FROM sales s, times t WHERE s.time_id = t.time_id GROUP BY t.calendar_month_desc; Assume that sales number is around one million in a typical month. The view has the precomputed aggregates for the dollar amount sold for each month. Consider the following query, which asks for the sum of the amount sold for each month: CREATE VIEW employees_50_vw AS SELECT employee_id, last_name, job_id, salary, commission_pct, department_id FROM employees WHERE department_id = 50;0 Without query rewrite, the database must access SELECT employee_id FROM employees_50_vw WHERE employee_id > 150;8 directly and compute the sum of the amount sold. This method involves reading many million rows from SELECT employee_id FROM employees_50_vw WHERE employee_id > 150;8, which invariably increases query response time. The join also further slows query response because the database must compute the join on several million rows. With query rewrite, the optimizer transparently rewrites the query as follows: Which of the following is a single row function?Single row function in SQL can be character, numeric, date, and conversion functions. these functions are used to modify data items. These functions need one or more input and operate on each row, thereby returning one output value for each row.
What are the types of single row functions in SQL?Single-Row Functions. Numeric Functions. Numeric functions accept numeric input and return numeric values. ... . Character Functions Returning Character Values. ... . Character Functions Returning Number Values. ... . Character Set Functions. ... . Datetime Functions. ... . General Comparison Functions. ... . Large Object Functions. ... . Collection Functions.. Which of the following is not true about single row?Q 49 - Which of the following is not true about single-row subqueries? A - Single row subqueries return one row from the inner SELECT statement.
Which of the following is a single row in database table?A row in the table of database is also known as a record. Alternatively, it is also called a tuple. * It consists of a single record for a given type of data.
|