DekGenius.com
SQL
sql
SELECT - extracts data from a database
UPDATE - updates data in a database
DELETE - deletes data from a database
INSERT INTO - inserts new data into a database
CREATE DATABASE - creates a new database
ALTER DATABASE - modifies a database
CREATE TABLE - creates a new table
ALTER TABLE - modifies a table
DROP TABLE - deletes a table
CREATE INDEX - creates an index ( search key )
DROP INDEX - deletes an index
sql
CREATE TABLE Customers (
PersonID int ,
CustomerName varchar ( 255 ) ,
ContactName varchar ( 255 ) ,
Address varchar ( 255 ) ,
City varchar ( 255 ) ,
PostalCode varchar ( 255 ) ,
Country varchar ( 255 )
) ;
INSERT INTO Customers ( 1 , CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ( 'Cardinal' , 'Tom B. Erichsen' , 'Skagen 21' , 'Stavanger' , '4006' , 'Norway' ) ;
select * from Customers;
SQL
sql
Structured Query Language
SQL
CREATE TABLE friends (
id INTEGER ,
name TEXT ,
birthday DATE
) ;
INSERT INTO friends ( id, name, birthday)
VALUES ( 1 , 'Jane Doe' , '1990-05-30' ) ;
INSERT INTO friends( id , name , birthday)
VALUES ( 2 , 'APOORV' , '2000-2-2' ) ;
UPDATE friends
SET name = 'Jane Srivastava'
WHERE id = 1 ;
ALTER TABLE friends
ADD COLUMN email TEXT ;
UPDATE friends
SET email = '203029@klsafjls'
where id = 1 ;
UPDATE friends
SET email = '203029@klsafjls'
where id = 2 ;
DELETE FROM friends
WHERE id = 1 ;
SELECT *
FROM friends;
sql
SQL - the standard language to communicate with DBMS.
sql
SQL is a domain- specific language used in programming and designed for managing
data held in a relational database management system, or for stream processing
in a relational data stream management system.
sql
sql
SQL
create or replace view active_toys as
select * from toys
where is_deleted = 'N' ;
select * from active_toys;
sql
SELECT * , isnull( pvt1. id, 0 ) FROM (
SELECT id, date , relay_type, line_number, machine_number
, process, TIMES, time_val
FROM
[ OutputMonitoring] . [ dbo] . [ output_tbl]
UNPIVOT (
time_val FOR times
IN
( [ 0000 HR] ,
[ 0100 HR] )
) AS PV1
WHERE machine_number = 'CVR 9' and date = '2022-07-14'
) tb2
PIVOT (
max ( time_val)
FOR TIMES IN ( [ 0000 HR] ,
[ 0100 HR] )
) pvt1
FULL JOIN target_tbl
on
target_tbl. relay_type = pvt1. relay_type
and target_tbl. line_no = pvt1. line_number
and target_tbl. machine_count = pvt1. machine_number
and target_tbl. process = pvt1. process
and target_tbl. Date = pvt1. date
WHERE pvt1. date = '2022-07-14'
SQL
select *
from toys
join bricks
on toy_id > brick_id;
SQL
select *
from toys, bricks
where toy_id = brick_id ( + ) ;
SQL
select count ( all colour ) total_number_of_rows,
count ( distinct colour ) number_of_different_colours,
count ( unique colour ) number_of_unique_colours
from bricks;
sql
BRICKS
COLOR SHAPE
green cube
yellow prism
red cylinder
COLORS
COLOR RGB_HEX_VALUE
red FF0000
green 00 FF00
blue 0000 FF
SQL
select count ( colour ) from bricks;
SQL
select count ( * ) from bricks;
SQL
select count ( distinct colour ) number_of_different_colours
from bricks;
SQL
SELECT
team_long_name,
team_api_id
FROM teams_germany
WHERE team_long_name IN ( 'FC Schalke 04' , 'FC Bayern Munich' ) ;
SQL
select colour, count ( * )
from bricks
group by colour;
SQL
select count ( * )
from bricks
group by colour;
SQL
select colour, shape, count ( * )
from bricks
group by colour;
SQL
select colour, count ( * )
from bricks
where count ( * ) > 1
group by colour;
SQL
select colour, count ( * )
from bricks
group by colour
having count ( * ) > 1 ;
select colour, count ( * )
from bricks
having count ( * ) > 1
group by colour;
SQL
select *
from toys
join bricks
on toy_id > brick_id;
SQL
SELECT
season,
date ,
home_goal,
away_goal
FROM matches_italy
WHERE
CASE
WHEN hometeam_id = 9857 AND home_goal > away_goal THEN 'Bologna Win'
WHEN awayteam_id = 9857 AND away_goal > home_goal THEN 'Bologna Win'
END 【IS NOT NULL 】;
SQL
SHAPE SHAPE_WEIGHT
cube 5
cuboid 1
pyramid 4
SQL
select *
from toys
left outer join bricks
on toy_id = brick_id;
SQL
select *
from toys, bricks
where toy_id = brick_id;
SQL
TOY_ID TOY_NAME TOY_COLOUR BRICK_ID BRICK_COLOUR BRICK_SHAPE
3 Baby Turtle green 2 blue cube
SQL
select toy_name
from toys
where not colour = 'green' ;
SQL
select *
from toys
where not colour = 'green' ;
SQL
select * from toys
where price = null ;
SQL
select * from toys
where price is null ;
SQL
select *
from toys
where colour <> 'green' ;
SQL
select *
from toys
where not colour = null ;
select *
from toys
where colour <> null ;
SQL
select *
from toys
where colour is not null ;
SQL
select toy_name
from toys
where not colour = 'green'
and not price = 6 ;
SQL
select *
from toys
join bricks
on toy_id = brick_id
SQL
select * from toys;
select * from bricks;
SQL
select *
from toys, bricks;
SQL
select *
from toys
cross join bricks;
SQL
SHAPE SUM ( WEIGHT)
cuboid 1
SQL
select *
from toys
inner join bricks
on toy_id = brick_id;
SQL
select *
from toys
join bricks
on toy_colour = brick_colour;
SQL
select *
from toys
join bricks
on toy_colour <> brick_colour;
SQL
select colour, count ( * )
from bricks
having sum ( weight ) > 1
group by colour;
SQL
insert into < table_name> ( col1, col2, . . . )
values ( 'value1' , 'value2' , . . . )
SQL
select colour, shape, count ( * )
from bricks
group by cube ( colour, shape ) ;
SQL
SELECT EmpId FROM
EmployeeDetails
where EmpId IN
( SELECT EmpId FROM EmployeeSalary) ;
SQL
alter session set row archival visibility = active;
select * from toys;
sql
SQL ( Structured Query Language )
sql
Connection conn = DriverManager. getConnection( URL, USER , PASS) ;
String sql = "SELECT * FROM users WHERE email = ?" ;
PreparedStatement stmt = conn. prepareStatement( sql ) ;
stmt. setString( 1 , email) ;
ResultSet results = stmt. executeQuery( sql ) ;
while ( results. next ( ) )
{
}
SQL
String firstname = req. getParameter( "firstname" ) ;
String lastname = req. getParameter( "lastname" ) ;
String query = "SELECT id, firstname, lastname FROM authors WHERE firstname = ? and lastname = ?" ;
PreparedStatement pstmt = connection. prepareStatement( query ) ;
pstmt. setString( 1 , firstname ) ;
pstmt. setString( 2 , lastname ) ;
try
{
ResultSet results = pstmt. execute ( ) ;
}
sql
CREATE TABLE ` users` (
` id` int ( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
` username` varchar ( 100 ) NOT NULL ,
` email` varchar ( 100 ) NOT NULL ,
` password` varchar ( 100 ) NOT NULL
) ENGINE = InnoDB DEFAULT CHARSET = latin1;
SQL
SELECT
concat( '<a target="_new" href=%%WWWROOT%%/course/view.php?id=' , c. id, '">' , c. fullname, '</a>' ) AS Course
, c. shortname, r. name
, ( SELECT CONCAT( u. firstname, ' ' , u. lastname) AS Teacher
FROM prefix_role_assignments AS ra
JOIN prefix_context AS ctx ON ra. contextid = ctx. id
JOIN prefix_user AS u ON u. id = ra. userid
WHERE ra. roleid = 3 AND ctx. instanceid = c. id LIMIT 1 ) AS Teacher
, concat( '<a target="_new" href="%%WWWROOT%%/mod/resource/view.php?id=' , r. id, '">' , r. name, '</a>' ) AS Resource
FROM prefix_resource AS r
JOIN prefix_course AS c ON r. course = c. id
WHERE r. reference LIKE 'https://stackoverflow.com/%'
SQL
SQL
create table toys (
toy_name varchar2( 30 ) ,
price number( 4 , 2 )
) ;
insert into toys values ( 'Baby Turtle' , 0.01 ) ;
insert into toys values ( 'Miss Snuggles' , 0.51 ) ;
insert into toys values ( 'Cuteasaurus' , 10.01 ) ;
insert into toys values ( 'Sir Stripypants' , 14.03 ) ;
insert into toys values ( 'Purple Ninja' , 14.22 ) ;
commit ;
sql
SQL ( Structured Query Language ) is a domain- specific
language used in programming and designed for
managing data held in a relational database management system,
or for stream processing in a relational data stream management system.
sql
SELECT name, population/ area AS density FROM bbc WHERE population = ( SELECT MAX ( population) FROM bbc)
sql
sql
Structured Query Language ( SQL ) is a programming language released in 1974.
It is used to manage relational databases and perform various operations on them.
I would recommend Docker to run SQL servers locally.
MySQL would recommend as well.
Flask is good for SQLite development.
SQL
Structured Query Language ( SQL )
SQL
SELECT id, payer_email
FROM paypal_ipn_orders
WHERE payer_email IN (
SELECT payer_email
FROM paypal_ipn_orders
GROUP BY payer_email
HAVING COUNT ( id) > 1
)
sql
< tr>
< td> Emp ID:< / td>
< td> < input type = "text" name= "EmpID" > < / td>
< / tr>
< tr>
< td> First Name:< / td>
< td> < input type = "text" name= "Firstname" > < / td>
< / tr>
< tr>
< td> Middle Name:< / td>
< td> < input type = "text" name= "Middlename" > < / td>
< / tr>
< tr>
< td> Last Name:< / td>
< td> < input type = "text" name= "Lastname" > < / td>
< / tr>
< tr>
< td> Department:< / td>
< td> < input type = "text" name= "Department" > < / td>
< / tr>
< tr>
< td> Age:< / td>
< td> < input type = "text" name= "Age" > < / td>
< / tr>
< tr>
< td> Brith Year :< / td>
< td>
< select name= "BrithYear>
<option selected hidden value="">select code</option>
<option> 1980 </option>
<option> 1985 </option>
<option> 1990 </option>
<option> 1995 </option>
</td>
</tr>
<tr>
<td>Education Status :</td>
<td>
<select name=" Education Status >
< option selected hidden value = "" > select code< / option >
< option > Level < / option >
< option > Diploma < / option >
< option > B. A Degree < / option >
< option > M/ r < / option >
< / td>
< / tr>
< tr>
< td> Date of Emp :< / td>
< td>
< select name= "Date of Emp >
<option selected hidden value="">select code</option>
<option> 01 </option>
<option> 05 </option>
<option> 10 </option>
<option> 20 </option>
</td>
</tr>
<tr>
<td>Month of Emp :</td>
<td>
<select name=" Month of Emp >
< option selected hidden value = "" > select code< / option >
< option > 01 < / option >
< option > 05 < / option >
< option > 08 < / option >
< option > 10 < / option >
< / td>
< / tr>
< tr>
< td> Year of Emp :< / td>
< td>
< select name= "Year of Emp >
<option selected hidden value="">select code</option>
<option>2010 </option>
<option>2015 </option>
<option>2020 </option>
<option>2022 </option>
</td>
</tr>
<tr>
<td>Marriage Status :</td>
<td>
<select name=" Marriage Status >
< option selected hidden value = "" > select code< / option >
< option > SINGLE < / option >
< option > NO < / option >
< option > yES < / option >
< / td>
< / tr>
< tr>
< td> Type of Emp :< / td>
< td>
< select name= "Type of Emp >
<option selected hidden value="">select code</option>
<option>Daily </option>
<option>Extension </option>
<option>Weekend </option>
<tr>
<td>Gender :</td>
<td>
<input type=" radio" name=" gender" value=" m">Male
<input type=" radio" name=" gender" value=" f">Female
</td>
</tr>
<tr>
<td>phone no :</td>
<td>
<select name=" phoneCode>
< option selected hidden value = "" > select code< / option >
< option > + 251 < / option >
< option > + 251 < / option >
< option > 979 < / option >
< option > 973 < / option >
< option > 972 < / option >
< option > 974 < / option >
< / select >
< input type = "phone" >
< / td>
< / tr>
< tr>
< td> Salary:< / td>
< td> < input type = "text" name= "Salary" > < / td>
< / tr>
< tr>
< tr>
< td> < input type = "submit" value = "submit" > < / td>
< / tr>
< tr>
< td> < input type = "Reset" value = "Reset" > < / td>
< / tr>
SQL
alter session set row archival visibility = all ;
select * from toys;
SQL
alter table bricks add ( version_number integer default 1 ) ;
select * from bricks;
SQL
COLOR SHAPE
blue cube
blue cylinder
green cube
red cylinder
red rectangular cuboid
yellow rectangular cuboid
SQL
select * from toys;
insert into bricks ( brick_id )
select toy_id
from toys;
select * from bricks;
SQL
create table toys (
toy_id integer ,
toy_name varchar2( 100 ) ,
colour varchar2( 10 )
) ;
create table bricks (
brick_id integer ,
colour varchar2( 10 ) ,
shape varchar2( 10 )
) ;
SQL
select * from toys;
select * from bricks;
select table_name, column_name, data_type
from user_tab_columns
where table_name in ( 'TOYS' , 'BRICKS' )
order by table_name, column_id
SQL
select * from toys
where toy_name like '%_%' ;
SQL
insert into toys values ( 1 , 'Miss Snuggles' , 'pink' ) ;
select * from toys;
SQL
insert into toys ( toy_id, toy_name ) values ( 2 , 'Baby Turtle' ) ;
select * from toys;
SQL
insert into toys values ( 2 , 'Baby Turtle' ) ;
SQL
TOY_ID TOY_NAME COLOUR
3 < null > red
SQL
insert into toys ( toy_id, colour ) values ( 4 , 'blue' ) ;
insert into toys ( toy_id, colour ) values ( 5 , 'green' ) ;
SQL
select * from bricks
where colour = 'red'
for update ;
SQL
BRICK_ID COLOUR SHAPE
4 blue < null >
5 green < null >
SQL
insert into toys ( toy_id, toy_name, colour )
values ( 7 , 'Pink Rabbit' , 'pink' ) ;
select * from toys
where toy_id = 7 ;
commit ;
rollback ;
select * from toys
where toy_id = 7 ;
SQL
insert into toys ( toy_id, toy_name, colour )
values ( 7 , 'Pink Rabbit' , 'pink' ) ;
select * from toys
where toy_id = 7 ;
rollback ;
select * from toys
where toy_id = 7 ;
sql
mysql> CREATE TABLE char_test( char_col CHAR ( 10 ) ) ;
mysql> INSERT INTO char_test( char_col) VALUES
- > ( 'string1' ) , ( ' string2' ) , ( 'string3 ' ) ;
sql
~ / $ sqlite3
SQLite version 3.22 .0 2018 - 01 - 22 18 :45 :57
Enter ".help" for usage hints.
sqlite> . mode csv
sqlite> . import 'Favorite TV Shows (Responses) - Form Responses 1.csv' shows
SQL
COLUMN_NAME DATA_TYPE DATA_LENGTH DATA_PRECISION DATA_SCALE
TOY_ID NUMBER 22 < null > 0
TOY_NAME VARCHAR2 100 < null > < null >
WEIGHT NUMBER 22 8 1
SQL
create table toys (
varchar2( 10 )
) ;
select column_name, data_type, data_length
from user_tab_columns
where table_name = 'TOYS' ;
SQL
select toy_name
from toys
where toy_name LIKE '%B%' ;
SQL
select *
from toys
where colour in ( 'blue' , 'red' )
and price >= 6 and price < 14.22 ;
SQL
select * from toys
where colour like '_e_' ;
select * from toys
where colour like '%e%' ;
select * from toys
where colour like '%_e_%' ;
SQL
select table_name, iot_name, iot_type, external,
partitioned, temporary , cluster_name
from user_tables;
sql
sql
SQL
create table people (
person_id integer ,
full_name varchar2( 100 )
) ;
SQL
create table appointments (
appointment_doc varchar2( 4000 )
) ;
SQL
create table < table_name> (
< column1_name> < data_type> ,
< column2_name> < data_type> ,
< column3_name> < data_type> ,
. . .
)
SQL
create table toys (
toy_name varchar2( 100 ) ,
weight number
) ;
SQL
create table toys_heap (
toy_name varchar2( 100 )
) organization heap;
select table_name, iot_name, iot_type, external,
partitioned, temporary , cluster_name
from user_tables
where table_name = 'TOYS_HEAP' ;
SQL
create table bricks (
brick_id number( 20 , 0 ) ,
colour varchar2( 10 ) ,
price number( 10 , 2 ) ,
purchased_date date
) ;
select column_name, data_type, data_length, data_precision, data_scale
from user_tab_columns
where table_name = 'BRICKS' ;
SQL
create table toys_iot (
toy_id integer primary key ,
toy_name varchar2( 100 )
) organization index ;
SQL
select table_name, iot_type
from user_tables
where table_name = 'TOYS_IOT' ;
SQL
create or replace directory toy_dir as '/path/to/file' ;
create table toys_ext (
toy_name varchar2( 100 )
) organization external (
default directory tmp
location ( 'toys.csv' )
) ;
SQL
SQL
create global temporary table toys_gtt (
toy_name varchar2( 100 )
) ;
SQL
create private temporary table ora$ptt_toys (
toy_name varchar2( 100 )
) ;
SQL
create table toys_part_iot (
toy_id integer primary key ,
toy_name varchar2( 100 )
) organization index
partition by hash ( toy_id ) partitions 4 ;
sql
SQL
create table toys (
toy_name varchar2( 10 )
) ;
select column_name, data_type, data_length
from user_tab_columns
where table_name = 'TOYS' ;
SQL
TABLE_NAME PARTITIONED
BRICKS_HASH YES
SQL
Structured Query Language is a database communiacation language . It manages data
in a database and processes a relational data stream in a management system.
sql
SQL is used to communicate with a database .
According to ANSI ( American National Standards Institute) , it is the standard language for relational database management systems.
SQL statements are used to perform tasks such as update data on a database , or retrieve data from a database .
sql
sql
DOWNLOAD XAMPP
And then start apache and mysql then go to localhost/ phpmyadmin
sql
INSERT into table_ values ( )
sql
CREATE DEFINER = ` root` @`localhost` PROCEDURE ` business_registration` ( IN ` bscode` VARCHAR ( 10 ) , IN ` bsname` VARCHAR ( 50 ) , IN ` appcode` VARCHAR ( 10 ) , IN ` in_state` VARCHAR ( 25 ) , IN ` in_sector` VARCHAR ( 50 ) , IN ` in_cac` VARCHAR ( 10 ) , IN ` dobinc` DATE , IN ` fname` VARCHAR ( 100 ) , IN ` phone` VARCHAR ( 20 ) , IN ` in_email` VARCHAR ( 20 ) , IN ` biz_add` VARCHAR ( 50 ) , IN ` app_status` VARCHAR ( 10 ) , IN ` in_id` INT , IN ` query_type` VARCHAR ( 30 ) ) NO SQL
Begin
if query_type= "insert" THEN
INSERT INTO ` business_registration` ( ` business_code` , ` business_name` , ` application_code` , ` state` , ` sector` , ` cac_registration` , ` date_of_biz_incorporation` , ` founders_name` , ` phone_number` , ` email` , ` biz_address` , ` application_status` ) VALUES ( bscode, bsname, appcode, in_state, in_sector, in_cac, dobinc, fname, phone, in_email, biz_add, app_status) ;
ELSEIF query_type= "delete" THEN
DELETE FROM business_registration where id= in_id;
ELSEIF query_type= "select_all" THEN
SELECT * FROM business_registration;
ELSEI[ . . . ]
sql
CREATE TABLE consultation (
id SERIAL ,
Identification VARCHAR ( 50 ) ,
Coord_X INT ,
Coord_Y INT ,
PRIMARY KEY ( Identification)
)
sql
Codecademy has a free course on this.
https:
sql
TABLE a bills
id q INTEGER x NOT k NULL d PRIMARY n KEY
customerName u VARCHAR ( 50 ) s NOT 5 NULL
TABLE 1 billItems
id b INTEGER r NOT g NULL 9 PRIMARY n KEY
name g VARCHAR ( 50 ) 9 NOT f NULL
amountDollars v DECIMAL ( 10 , n 2 ) 5 NOT 7 NULL
m g discountDollars r DECIMAL ( 10 , b 2 ) q NOT t NULL
billId 8 INTEGER t NOT y NULL p REFERENCES 1 bill( id)
SQL
drop table toys ;
select table_name
from user_tables
where table_name = 'TOYS' ;
sql
select username, high_score from users;
SQL
create table bricks (
Colour varchar2( 10 ) ,
Shape varchar2( 10 )
) ;
select table_name
from user_tables
where table_name = 'BRICKS' ;
SQL
create table bricks_iot (
bricks_id integer primary key
) organization index ;
select table_name, iot_type
from user_tables
where table_name = 'BRICKS_IOT' ;
sql
SQL ( Structured Query Language ) is a standardized programming language
that's used to manage relational databases and perform various
operations on the data in them.
SQL
create table bricks_iot (
bricks_id integer primary key
) organization index ;
select table_name, iot_type
from user_tables
where table_name = 'BRICKS_IOT' ;
SQL
select table_name, temporary
from user_tables
where table_name in ( 'TOYS_GTT' , 'ORA$PTT_TOYS' ) ;
SQL
create table bricks_hash (
brick_id integer
) partition by hash ( brick_id) partitions 8 ;
select table_name, partitioned
from user_tables
where table_name = 'BRICKS_HASH' ;
SQL
select table_name, partitioned
from user_tables
where table_name in ( 'TOYS_HASH' , 'TOYS_LIST' , 'TOYS_RANGE' , 'TOYS_PART_IOT' ) ;
select table_name, partition_name
from user_tab_partitions;
SQL
create cluster toy_cluster (
toy_name varchar2( 100 )
) ;
SQL
select * from toys
where toy_name like '___________' ;
SQL
select * from toys
where colour in ( 'red' , 'green' ) ;
SQL
select * from toys
where ( toy_name = 'Mr Bunnykins' or toy_name = 'Baby Turtle' )
and colour = 'green' ;
select * from toys
where colour = 'green'
and ( toy_name = 'Mr Bunnykins' or toy_name = 'Baby Turtle' ) ;
SQL
select *
from toys
where toy_name = 'Sir Stripypants'
or colour = 'blue' ;
SQL
select *
from toys
where toy_name = 'Sir Stripypants'
or colour = 'blue'
and price = 6 ;
SQL
select *
from toys
where ( toy_name = 'Sir Stripypants'
or colour = 'blue' )
and price = '6' ;
SQL
TOY_NAME COLOUR PRICE
Miss Smelly_bottom blue 6
SQL
select * from toys
where colour = 'red' or
colour = 'green' ;
SQL
select * from toys
where price < 10 ;
SQL
select * from toys
where toy_name = 'Mr Bunnykins' or toy_name = 'Baby Turtle'
and colour = 'green' ;
select * from toys
where colour = 'green'
and toy_name = 'Mr Bunnykins' or toy_name = 'Baby Turtle' ;
SQL
select * from toys
where price >= 6 ;
SQL
select * from toys
where price between 6 and 20 ;
SQL
select * from toys
where price >= 6
and price <= 20 ;
SQL
select * from toys
where price > 6
and price <= 20 ;
SQL
TOY_NAME COLOUR PRICE
Miss Smelly_bottom blue 6
SQL
select * from toys
where colour like 'b%' ;
SQL
select * from toys
where colour like '%n' ;
SQL
PRICE COLOUR
0.01 red
6 blue
17.22 blue
14.22 red
< null > green
SQL
select * from toys
where toy_name = 'Sir Stripypants'
and colour = 'green' ;
© 2022 Copyright:
DekGenius.com