Archive for the ‘SQL’ Category

Tables

  Tables: Table is a database object which holds the data and contains one or more columns associated with its datatypes Creating a Table: we use the create table statement to create a table. The simple syntax for the creation of table. Syntax: CREATE Table table_name (column_name type [CONSTRAINT constraint_def DEFAULT default_exp], column_name type [CONSTRAINT […]

SQL Queries

1) SQL Query to write ‘ORACLE’ string vertically Query: SELECT SUBSTR(‘ORACLE’, ROWNUM, 1)FROM DUAL CONNECT BY LEVEL <= LENGTH(‘ORACLE’) 2) Display 1 to 10 numbers using DUAL table Query: SELECT ROWNUM FROM DUAL CONNECT BY LEVEL <= 10

SQL/PLSQL FAQ’s

1 triggers A Database Trigger is a stored procedure that is fired when a DML operation is performed on the table.In total there are 13 types of Triggers Sytax for creating a trigger: CREATE OR REPLACE TRIGGER <TRIGGERNAME> before / after [INSERT / UPDATE / DELTE ] ON <TABLE NAME> {For each Statement / Row} […]

Find the capital and the name where the capital includes the name of the country

Answer:   SELECT name,capital  ROM world WHERE capital LIKE concat(concat(‘%’,name),’%’)

Find the countries that have exactly four characters.?

Answer: SELECT name FROM world WHERE length(name) = 4

Find the countries that have two “o” characters separated by two others.

answer: SELECT name FROM world WHERE name LIKE ‘%O__O%’;

Find the country where the capital is the country plus “City”.

Find the country where the capital is the country plus “City”. Answer:   SELECT name FROM world where capital =  concat(name, ‘ city’)

Powered by k2schools