Skip to main content

SQL

Thomson n Reuters




create table employee(
empId  int not null unique,
empName varchar(40) not null);


CREATE TABLE DEPARTMENT
(DEPT_ID INT NOT NULL UNIQUE,
 DEPT_NAME VARCHAR(40) NOT NULL);

---------------------------------------------

insert into employee values(1,'Takshila');
insert into employee values(2,'Vidushi');
insert into employee values(3,'Priyanka');
insert into employee values(4,'Kiran');select


insert into department values(1,'HR');
insert into department values(2,'ADMIN');
insert into department values(3,'CORE ENGINEERING');
insert into department values(4,'QA');


UPDATE  employee SET salary =10000 where empid= 1;
UPDATE employee SET salary =20000 where empid= 2;
UPDATE  employee SET salary =30000 where empid= 3;
UPDATE employee SET salary =40000 where empid= 4;

SELECT TOP 2 column FROM employee[oracle]

select count(*) from employee
4 records

select max(salary) from employee
40000

select salary from employee order by salary desc limit 2 

40000
30000

select salary from employee order by salary fetch first 2 rows only 

o/p
10000
40000


SELECT Salary FROM (select * from employee order by salary desc limit 2)  as A order by salary limit 1 

[SELECT Salary FROM (select * from employee order by salary desc limit 2)  as A order by salary limit 1 ]

[SELECT  MAX(salary) AS salary
  FROM employee
 WHERE salary < (SELECT MAX(salary)
                 FROM employee); ]


Select min(A.salary) from  (Select * from employee  order by salary desc limit 2 ) as A 
-----------------------------------------
select * from employee
____________________________


Clauses used in SQL



ALTER TABLE TO ADD COLUMN


Alter table employee add column salary int ;

ALTER TABLE TO ADD CONSTRAINT

ALTER TABLE TO RENAME TABLE


TRUNCATE TABLE Employee; 








ALTER TABLE table_name   RENAME TO new_table_name;  

TRUNCATE TABLE Employee;  


SQL COPY TABLE

SELECT * INTO  FROM  

SQL DELETE TABLE

DELETE FROM table_name [WHERE condition];  


SQL UPDATE

UPDATE students  
SET User_Name = 'beinghuman'  
WHERE Student_Id = '3'  








Comments

Popular posts from this blog

Microservices Design patterns

What are microservices? Microservices - also known as the microservice architecture - is an architectural style that structures an application as a collection of services that are Highly maintainable and testable Loosely coupled Independently deployable Organized around business capabilities Owned by a small team The microservice architecture enables the rapid, frequent and reliable delivery of large, complex applications. It also enables an organization to evolve its technology stack. You are developing a server-side enterprise application. It must support a variety of different clients including desktop browsers, mobile browsers and native mobile applications. The application might also expose an API for 3rd parties to consume. It might also integrate with other applications via either web services or a message broker. The application handles requests (HTTP requests and messages) by executing business logic; accessing a database; exchanging messages with other systems; and returni...

GraphQL

What is GraphQL  API Standard invented & open-sourced by Facebook Alternative to  REST API  enables declarative data fetching  exposes single endpoint & responds to queries How it works?  Why Graphql? Improvises performance by reducing the data that is to be transferred over the internet Variety of different frontend frameworks and platforms on client-side Fast development speed & expectation for rapid feature development Why Graphql is better than REST? Flexibility & efficient  No more over /under fetching of data Over fetching : Under fetching: Insightful analytics  Schema serves as contract between client and server CORE CONCEPTS : SDL :SCHEMA DEFINITION LANGUAGE Writing Data with mutations 3 kinds of mutations creating new data updating existing data deleting existing data

Jackson

<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId> jackson-core </artifactId> <version>2.9.6</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId> jackson-annotations </artifactId> <version>2.9.6</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId> jackson-databind </artifactId> <version>2.9.6</version> </dependency> CBOR encoded data with Jackson <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-cbor</artifactId> <version>2.9.6</version> </dependency> In order to read and write MessagePack encoded data <dependency> <groupId>org.msgpack</groupId> <artifactId>jackson-dataformat-msgp...