I need to create a job whith DBMS_SCHEDULER.CREATE_JOB using the EXCLUDE CLAUSE to exclude the dates of table (holidays, it have 2 columns date and ).
I tried to create a named schedule after this table, there is a way to accomplish this?
Related
I have a table 'X" in . Hbase that has millions of records i need to create another table 'mini_x' which has only 100 records of 'X' how do i create one such ??
You might have to create table "mini_x" in HBase then,
Either you can Use HBase API with Java to get records from main table "X", Filter them and then put to another table.
OR You can use Hadoop MapReduce Job to read one HBase table and put the selected records in another table(mini_x)
I want to use the ALTER TABLE ... CONCATENATE functionality in Hive, but it seems I have to give exact partition name. For example I have a table with two partition columns, date and group. I'd like to be able to do something like this:
alter table mytable partition (insert_date='2017-04-11',group='%') CONCATENATE;
But i can't find the way of doing it.
Concatenate doesn't support this.
Is it possible to create a Trigger based on the last update date of different views? The one that triggers inserting entire employee and dept records in new table when last_update_date changed/updated?
ex views:
CREATE OR REPLACE FORCE VIEW "EMPLOYEE_V" AS
SELECT employee_id
,employee_first_name
,employee_last_name
,emp_creation_date
,emp_last_update_date
FROM employees;
CREATE OR REPLACE FORCE VIEW "DEPARTMENT_V" AS
SELECT department_id
,department_name
,dep_creation_date
,dep_last_update_date
FROM department_id;
I know that this will require 1 trigger which will apply to both tables. But is there an alternative way to avoid several updates / update of records when the trigger in both tables have been fired?
Any help will be appreciated. Thanks :)
One trigger can't be created on multiple tables. You need to create two different triggers for each underlying tables. Thanks..
When I need to change a column into a partition (convert normal column as partition column in hive), I want to create a new table to copy all columns except one. I currently have >50 columns in the original table. Is there any clean way of doing that?
Something like:
CREATE student_copy LIKE student EXCEPT age and hair_color;
Thanks!
You can use a regex:
CTAS using REGEX column spec. :
set hive.support.quoted.identifiers=none;
CREATE TABLE student_copy AS SELECT `(age|hair_color)?+.+` FROM student;
set hive.support.quoted.identifiers=column;
BUT (as mentioned by Kishore Kumar Suthar :
this will not create a partitioned table, as that is not supported with CTAS (Create Table As Select).
Only way I see for you to get your partitioned table is by getting the complete create statement of the table (as mentioned by Abraham):
SHOW CREATE TABLE student;
Altering it to create a partition on the column you want. And after that you can use the select with regex when inserting into the new table.
If your partition column is already part of this select, then you need to make sure it is the last column you insert. If it is not you can exclude that column in the regex and including it as last. Also if you expect several partitions to be created based on your insert statement you need to enable 'dynamic partitioning':
set hive.support.quoted.identifiers=none;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
INSERT INTO TABLE student_copy PARTITION(partcol1) SELECT `(age|hair_color|partcol1)?+.+`, partcol1 FROM student;
set hive.support.quoted.identifiers=column;
the 'hive.support.quoted.identifiers=none' is required to use the backticks '`' in the regex part of the query. I set this parameter to it's original value after my statement: 'hive.support.quoted.identifiers=column'
CREATE TABLE student_copy LIKE student;
It just copies the source table definition.
CREATE TABLE student_copy AS select name, age, class from student;
Target cannot be partitioned table.
Target cannot be external table.
It copies the structure as well as the data
I use below command to get the create statement of existing table.
SHOW CREATE TABLE student;
Copy the result and modify that based on your requirement for new table and run the modified command to get the new table.
I want to create a table (lets say table_copy) which has same columns as other table (lets call it table_original) in Oracle database, so the query will be like this :
create table table_copy as (select * from table_original where 1=0);
This will create a table, but the constraints of table_original are not copied to table_copy, so what should be done in this case?
Only NOT NULL constraints are copied using Create Table As Syntax (CTAS). Others should be created manually.
You might however query data dictionary view to see the definitions of constraints and implement them on your new table using PL/SQL.
The other tool that might be helpful is Oracle Data Pump. You could import the table using REMAP_TABLE option specifying the name for the new table.
Use a database tool to extract the DDL needed for the constraints (SQL Developer does the job). Edit the resulting script to match the name of the new class.
Execute the script.
If you need to do this programmatically you can use a statement like this:
DBMS_METADATA.GET_DDL('TABLE','PERSON') from DUAL;