[SQL development practical skills] series (forty-six): Oracle12C commonly used new features ☞ session-level sequence and data pump (DataPump enhancement) supports exporting views like tables

Series Article Directory

[SQL development practical skills] series (1): those things that have to be said about SQL
[SQL development practical skills] series (2): simple single table query
[SQL development practical skills] series (3): those things about SQL sorting
[SQL Development Practical Skills] Series (4): Discuss the Precautions for Using UNION ALL and Empty String & UNION and OR from the Execution Plan
[SQL Development Practical Skills] Series (5): Look at the Efficiency of IN, EXISTS and INNER JOIN from the Execution Plan , we need to divide the scenarios and don’t memorize the online conclusion
[SQL Development Practical Skills] series (6): Look at the efficiency of NOT IN, NOT EXISTS and LEFT JOIN from the execution plan, and remember that internal and external association conditions should not be misplaced
[SQL Development Practical Skills] series ( Seven): Let’s talk about how to compare the difference data and the corresponding number of records in two tables under the premise of duplicate data
[SQL development practical skills] series (eight): talk about how to insert data, which is more flexible than constraints to restrict data insertion And how does an insert statement insert multiple tables at the same time
[SQL development practical skills] series (9): An update mistakenly updates other column data to be empty? Merge rewrite update! Give you five ways to delete duplicate data!
[SQL Development Practical Skills] Series (10): Starting from splitting strings, replacing strings, and counting the number of occurrences of strings
[SQL Development Practical Skills] Series (11): Take a few cases to talk about translate|regexp_replace| listagg|wmsys.wm_concat|substr|regexp_substr Commonly used functions
[SQL development practical skills] series (12): Three questions (how to sort the strings in alphabetical order after deduplicating the letters of the string? How to identify which strings contain numbers? How to convert delimited data into a multivalued IN list?)
[SQL Development Practical Skills] Series (13): Discuss common aggregate functions & see sum() over () through the execution plan to accumulate employee wages
[SQL Development Practical Skills] Series (14): Calculate the balance after consumption &Calculate the cumulative sum of bank turnover & calculate the top three employees in each department's salary
[SQL development practical skills] series (fifteen): Find the data information of the row where the most value is located and quickly calculate the sum of max/min() keep() over(), fisrt_value, last_value, ratio_to_report
[SQL development practical skills] series (16): time type operation in data warehouse (primary) day, month, year, hour, minute, second difference and time interval calculation [SQL
development Practical Skills] Series (Seventeen): Time type operations in data warehouses (primary) determine the number of working days between two dates, calculate the number of occurrences of each date in the week of the year, and determine the difference between the current record and the next record Number of days
[SQL development practical skills] series (18): time type operations in data warehouse (advanced) INTERVAL, EXTRACT and how to determine whether a year is a leap year and the calculation of the week [SQL development practical skills] series (19)
: How to print the calendar of the current month or year with one SQL in the time type operation (advanced) in the data warehouse? How to determine the date of the first and last day of the week in a month?
[SQL Development Practical Skills] Series (20): Time Type Operations in Data Warehouse (Advanced) Obtain Quarter Start and End Time and How to Count Discontinuous Time Data
[SQL Development Practical Skills] Series (21): Data Time type operations in the warehouse (advanced) Identify overlapping date ranges, and summarize data at specified 10-minute intervals
[SQL development practical skills] series (22): Data warehouse report scenario ☞ Is the efficiency of the analysis function must be fast Chat 1 Talk about the implementation of result set paging and interlaced sampling
[SQL Development Practical Skills] Series (23): Data Warehouse Report Scenario ☞ How to de-duplicate data permutations and how to find the record containing the maximum and minimum values? Use the execution plan again to prove to you that the performance of the analysis function is not good. Must be high
[SQL development practical skills] series (24): data warehouse report scenario ☞ Detailed explanation of "row to column" and "column to row" through case execution plan [SQL development practical skills]
series (25 ): Data warehouse report scenario ☞ Duplicate data in the result set is only displayed once and the efficient way to write the salary difference of the calculation department and how to quickly group data
[SQL development practical skills] series (26): Data warehouse report scenario ☞ chat How ROLLUP and UNION ALL perform group totals respectively and how to identify which rows are the result rows for summary
[SQL Development Practical Skills] Series (27): Data Warehouse Report Scenario ☞Analytical functions are explained in detail by aggregating moving ranges The principle of window opening and how to print the ninety-nine multiplication table with one SQL
[SQL development practical skills] series (28): Data warehouse report scenario ☞ personnel distribution and how to achieve simultaneous aggregation of different groups (partitions)
[SQL development practical skills] series (29): Data warehouse report scenario ☞ simple tree (hierarchical) query and how to determine the root node, branch node and leaf node
[SQL development practical skills] series (30): Data warehouse report scenario ☞ tree How are (hierarchical) queries sorted? And how to correctly use the where condition in the tree query
[SQL development practical skills] series (31): Data warehouse report scenario ☞ Hierarchical query How to query only a certain branch of the tree structure? How to cut off a branch?
[SQL Development Practical Skills] Series (32): Data Warehouse Report Scenario ☞ Deduplicate the value in a field in the table
[SQL Development Practical Skills] Series (33): Data Warehouse Report Scenario ☞ Never Fixed Extract the elements of strings by position and search for data that meets the conditions such as letters first and numbers next
[SQL development practical skills] series (34): data warehouse report scenario ☞How to classify data and convert them into columns in parallel
[SQL Development Practical Skills] Series (35): Data Warehouse Report Scenario ☞Returning Data in Different Columns According to Conditions and Left/Full Join Precautions
[SQL Development Practical Skills] Series (36): Data Warehouse Report Scenario ☞ Organize garbage data: Find the relationship between the continuity time and overlapping time of data, and initialize the start and end time
[SQL development practical skills] series (37): Data warehouse report scenario ☞ There are only nearly two years of data in the table, and the requirements Use two columns to display the data of one year and talk about the importance of the implicit information of row-to-column
[SQL development practical skills] series (38): Data warehouse report scenario ☞ split strings to connect
[SQL development practical skills] Series (39): Commonly used new features of Oracle12C ☞ New paging query
[SQL development practical skills] Series (40): Commonly used new features of Oracle12C ☞ Multiple indexes can be created on the same column (column combination) and DDL operation for logging
[SQL development practical skills] series (41): Oracle12C commonly used new features ☞ APPROX_COUNT_DISTINCT and TEMP UNDO (temporary undo records can be stored in a temporary table)
[SQL development practical skills] series (42 ): Oracle12C commonly used new features ☞With FUNCTION new features
[SQL development practical skills] series (forty-three): Oracle12C common new features ☞ conversion function enhancement and invisible fields
[SQL development practical skills] series (forty-four): Oracle12C commonly used new features ☞Did you know? Oralcle has added a new Mysql-like self-increment (Identity Columns) function
[SQL development practical skills] series (forty-five): Oracle12C commonly used new features ☞varchar2/nvarchar2 type The maximum length is 4000 characters section extended to 32767 bytes
[SQL development practical skills] series (forty-six): Oracle12C commonly used new features ☞ session-level sequence and data pump (DataPump enhancement) supports exporting views like tables



foreword

This article mainly explains the new features of Oracle12C+: In Oracle12C, the data pump (DataPump) has been enhanced, and TRANSFORMthe parameters of Impdp have been expanded to include DISABLE_ARCHIVE_LOGGINGoptions. The default value for this option is "N" and does not affect logging behavior. Set this option to "Y", which will make the table and index set the date index attribute to before importing NOLOGGING, thereby reducing the generation of related logs during import, and reset the log attribute to after importing LOGGING. VIEWS_AS_TABLESparameter allows to export the view as a table. The table structure matches the view columns, and the view query results correspond to the table data.

[SQL development practical skills] This series of bloggers writes as a review of old knowledge. After all, SQL development is very important and basic in data analysis scenarios. Interviews will often ask about SQL development and tuning experience. I believe that when I finish writing this A series of articles can also gain something, and you can also face SQL interviews with ease in the future~.


[SQL development practical skills] series (forty-six): Oracle12C commonly used new features ☞ session-level sequence and data pump (DataPump enhancement) supports exporting views like tables

1. DataPump Enhancement

Disable logging option (DISABLE_ARCHIVE_LOGGING)

The parameters of impdp TRANSFORMhave been extended to include DISABLE_ARCHIVE_LOGGINGoptions. The default value for this option is "N" and does not affect logging behavior. Set this option to "Y", which will make the table and index set the date index attribute to before importing NOLOGGING, thereby reducing the generation of related logs during import, and reset the log attribute to after importing LOGGING.

TRANSFORM=DISABLE_ARCHIVE_LOGGING:Y

The effect can be limited to a specific object type by appending the object type ( TABLE or INDEX).

TRANSFORM=DISABLE_ARCHIVE_LOGGING:Y:TABLE
TRANSFORM=DISABLE_ARCHIVE_LOGGING:Y:INDEX

Export views like tables

VIEWS_AS_TABLESparameter allows to export the view as a table. The table structure matches the view columns, and the view query results correspond to the table data.

VIEWS_AS_TABLES=[schema_name.]view_name[:table_name],...

case:

CONN scott/tiger
CREATE VIEW emp_v AS
 SELECT * FROM emp;

Export VIEWS_AS_TABLESa view with parameters.

$ expdp scott/tiger views_as_tables=scott.emp_vdirectory=test_dir dumpfile=emp_v.dmp logfile=expdp_emp_v.log

By default, Expdp creates a temporary table as a copy of the view, but does not contain data, but only provides a metadata source for export. Alternatively, an appropriately structured table can be determined instead. But maybe this only makes sense on read-only libraries.

2. Session-level sequence

In 12c it is now possible to create new session-level database sequences to support session-level sequence values. These types of sequences work best with session-level global temporary tables. A session-level sequence produces a unique range of values ​​that are bounded within the session, not beyond. Once the session is terminated, the state of the session sequence also disappears.

the case

SQL>create sequence session_seq start with 1 increment by 1 session;
Sequence created
SQL> select DBMS_METADATA.GET_DDL('SEQUENCE','SESSION_SEQ','TEST') from dual;
DBMS_METADATA.GET_DDL('SEQUENCE','SESSION_SEQ','TEST')
-------------------------------------------------------------------
CREATE SEQUENCE"TEST"."SESSION_SEQ"MINVALUE1MAXVALUE 9999999999999999

For session-level sequences, CACHE, NOCACHE, ORDERthe or NOORDERstatement is ignored:

SQL> create sequence session_seq_test start with 1 increment by 1 session cache 20 order;
Sequence created
SQL>selectDBMS_METADATA.GET_DDL('SEQUENCE','SESSION_SEQ_TEST','TEST') from dual;
DBMS_METADATA.GET_DDL('SEQUENCE','SESSION_SEQ_TEST','TEST')
---------------------------------------------------------------------
CREATE SEQUENCE"TEST"."SESSION_SEQ_TEST"MINVALUE1MAXVALUE 99999999999

Test a session-level sequence;
session 1:

SQL> select session_seq.nextval from dual;
   NEXTVAL
----------
         1
SQL> select session_seq.nextval from dual;
   NEXTVAL
----------
         2

Session 2:

SQL> select session_seq.nextval from dual;
   NEXTVAL
----------
         1

It can be seen that the value of the sequence only SESSIONaffects the level, and you can ALTER SEQUENCEset a sequence to the global or session level through the command, as follows to modify the sequence to global. The sequence value will restart from the initial value, and open another session 3 to perform the following operations:

SQL> select session_seq.nextval from dual;
   NEXTVAL
----------
         1
SQL> select session_seq.nextval from dual;
   NEXTVAL
----------
         2
SQL> ALTER SEQUENCE session_seq GLOBAL;
Sequence altered
SQL> select session_seq.nextval from dual;
   NEXTVAL
----------
         1
SQL> select session_seq.nextval from dual;
   NEXTVAL
----------
         2

Modifying the sequence from global to session level through ALTER SQEUENCEthe command is different from modifying the sequence from session level to global. When modifying the sequence from global to session level, the value of the sequence will not be reinitialized, but will be based on the previous sequence of the current session value, do the following test in session three.

SQL> ALTER SEQUENCE session_seq session;
Sequence altered
SQL> select session_seq.nextval from dual;
   NEXTVAL
----------
         3

The result of the previous session three query is 2, sessionafter modifying the global level, it is checked again nextvalas 3.

Summarize

This article mainly explains the new features of Oracle12C+: In Oracle12C, the data pump (DataPump) has been enhanced, and TRANSFORMthe parameters of Impdp have been expanded to include DISABLE_ARCHIVE_LOGGINGoptions. The default value for this option is "N" and does not affect logging behavior. Set this option to "Y", which will make the table and index set the date index attribute to before importing NOLOGGING, thereby reducing the generation of related logs during import, and reset the log attribute to after importing LOGGING. VIEWS_AS_TABLESparameter allows to export the view as a table. The table structure matches the view columns, and the view query results correspond to the table data.

Guess you like

Origin blog.csdn.net/qq_28356739/article/details/130022582