Thursday, 22 February 2018

Azure Data Lake – U-SQL – Creating Database and DB Object


Introduction

In this article we are trying to discuss about creation of Database and DB Object. Hope it will be informative.

 

Scenario

What we are doing in this article is mentioned bellow:

1.    Create a Database in the name of “MyUSQLDb”.

2.    Create a Schema in the name of “AbcPvtLtd”.

3.    Create a Table in the name of “ItemRate”.

4.    Insert some records in the table objects.

 


 

CREATE Database

To Create Database

CREATE DATABASE IF NOT EXISTS MyUSQLDb;

To Drop a Database

DROP DATABASE IF EXISTS MyUSQLDb;

 

CREATE Schema

To Create Schema

 

USE MyUSQLDb;

CREATE SCHEMA IF NOT EXISTS AbcPvtLtd;

 

To Drop Schema

 

USE MyUSQLDb;

DROP SCHEMA IF NOT EXISTS AbcPvtLtd;

 

CREATE Table Object and Index

 

USE DATABASE MyUSQLDb;   // DATABASE keyword is optional
USE SCHEMA AbcPvtLtd; // SCHEMA keyword is required for schemas



CREATE TABLE IF NOT EXISTS ItemRate
(
    ItemCode int,
    ItemRate int,
    INDEX idx_ItemCode CLUSTERED (ItemCode)
    DISTRIBUTED BY HASH (ItemCode)

);

 

Insert Records in Table

 

USE DATABASE MyUSQLDb;   // DATABASE keyword is optional
USE SCHEMA AbcPvtLtd; // SCHEMA keyword is required for schemas


INSERT INTO ItemRate
VALUES
(
    101,
    210
);

INSERT INTO ItemRate
VALUES
(
    102,
    120
);

INSERT INTO ItemRate
VALUES
(
    103,
    112

);

 

Job Graph:


 

Hope you like it.

 

Posted by: MR. JOYDEEP DAS


1 comment:

  1. • Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingAzure Online Training Bangalore

    ReplyDelete