create a schema in hive - hadoop

How can I create multiple schema under a user defined DB in hive?
I am trying to create a schema under a DB sam_db in hive. I am using the folowing code.
use sam_db;
create schema sam_db_schema;
But when I visit the local host to see the filesystem I see that instead of a schema being created inside sam_db a db named sam_db_schema is getting created.
Below is the screen shot presenting my case:
Isn't multiple schemas for a DB not possible in hive.
If possible then how do I create them.
Are both database and schema same for hive. Because when I do a
show databases;
show schemas
It gives me the same output.
Please help me understand : Thanks in advance

Are both database and schema same for hive?
Yes. The Language manual states this clearly:
CREATE (DATABASE|SCHEMA) [IF NOT EXISTS] database_name
[COMMENT database_comment]
[LOCATION hdfs_path]
[WITH DBPROPERTIES (property_name=property_value, ...)];
The uses of SCHEMA and DATABASE are interchangeable – they mean the same thing

Related

Export oracle database tables

i am working on a large database ,how do i Export some database tables without having dba privileges .do i have to copy the structures of the tables and using spool command to get the data in a text file then create the tables and inserting data from the text file?
One of the methods would be to install Oracle SQL Developer and export the required table structures and data using the wizard.
Here is the link to a tutorial which can guide you if you go with this option.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev/r30/SQLdev3.0_Import_Export/sqldev3.0_import_export.htm
A second option would be to use SQL Loader to load data in your target tables. But for that you will have to first create the data structures on your target schema and spool the data from your source tables in CSV (comma separated values) or any other eligible format.
Here is a link for SQL Loader.
http://docs.oracle.com/cd/B28359_01/server.111/b28319/ldr_concepts.htm
A third option would be that you create the table structures on the target schema and generate the insert statements from the source schema using a script. Here is a link to such an example.
https://pandazen.wordpress.com/2008/08/18/generate-insert-statement-script-to-extract-data-from-oracle-table/
I would recommend going with the SQL Developer option since it is relatively simple.

How to take database backup in hive? i mean hive database back up

Please any one suggest me how to take hive database backup. we are using mapr.
Regards
Sunilkumar
Currently I have taken backups of Hive DB by using the Import/ Export hive provided utilities. It will backup both the metadata (hive structure info) and the actual data.
EXPORT TABLE tablename [PARTITION (part_column="value"[, ...])]
TO 'export_target_path' [ FOR replication('eventid') ]
IMPORT [[EXTERNAL] TABLE new_or_original_tablename
[PARTITION (part_column="value"[, ...])]]
FROM 'source_path'
[LOCATION 'import_target_path']
But the problem with the above method is for every individual table, you need to provide this statement.
The other method is to get a list of all the available tables in the Hive DB by querying the MySQL Database which will have the metadata of all the Hive Tables. Refer to TBLS table in MySQL for the list of tables.

Oracle Database creation with exitsting tables

I've database with 15 tables. Now due to development process one column has to added to all the tables in the database. This changes should not affect the existing process because some other services are also consuming this database. So to accomplish it I thought of creating a new database. Is there are any other way to do it.
Usually it should be enough to create a new schema ("user") and create the tables in that new schema. In Oracle, identically named tables can exist in several schemas.
CREATE USER xxx IDENTIFIED BY yyy
you can create another schema for development and import the table to new schema.Developer should use the development schema instead of production schema.you can also create new database and import from current database but it might be last option
What's wrong with alter table T add (COL varchar2(5)); ?
Of course dependend stored procedures or packages become invalid.
You can leave them alone, then the first call would return an exception and auto-recompile the called procedure. Or you can alter procedure P compile;.

How to see the metadata of objects in Vertica Database (desc like Oracle)

I would like to know how I can get the metadata of an object in a Vertica database; like metadata of a table. Is there any table that stores the metadata of objects (functions, views, tables) in Vertica Database.
For example in Oracle, I could type the following and get a detailed description of tables or see the code of a procedure.
oracle :> desc table_name;
or
oracle :> edit proc_name;
I know that I can see the tables from my schemas with \dt command, but is there any way I can see the DDL statements that created the objects?
Thanks, but this is not what I want. I was looking for is the export_objects() function:
select export_objects('','object_name')
This way you will get the creation script for the object.
\d table-name should get you what you need.
Extra tip: If you specify only the schema, you will get all of the objects inside that schema. Sure beats having to enter a loop where you run export_objects() for every object.

How should I read the data from different oracle schema using ado.net?

The database user has got two schemas. I need to read the data from a specific schema using ado.net. I am using OleDbConnection object to create the connection to database. Appreciate your answers.
Use SCHEMA_NAME.TABLE_NAME in your queries.
If you don't specify a schema, Oracle will look into the current schema. The schema is by default the connexion user (so if you connect with USER1 and query TABLE1, Oracle will look for the table USER1.TABLE1). You can change your current schema at any time during a session with:
ALTER SESSION SET CURRENT_SCHEMA=SCHEMA2;
You can also use synonyms to point to the correct table.

Resources