blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
133
path
stringlengths
3
276
src_encoding
stringclasses
33 values
length_bytes
int64
23
9.61M
score
float64
2.52
5.28
int_score
int64
3
5
detected_licenses
listlengths
0
44
license_type
stringclasses
2 values
text
stringlengths
23
9.43M
download_success
bool
1 class
adee8a27a1a9cfd0942a8e2562dd570290b4c476
SQL
lixu0818/ERMS
/sql/insert_mock_data.sql
UTF-8
14,426
2.828125
3
[]
no_license
use cs6400_team021; insert into User (username, password, type) VALUES ('user1', '123', 'Individual'); insert into User (username, password, type) VALUES ('user2', '123', 'Company'); insert into User (username, password, type) VALUES ('user3', '123', 'Municipality'); insert into User (username, password, type) VALUES ('user4', '123', 'Government_Agency'); insert into User (username, password, type) VALUES ('user5', '123', 'Individual'); insert into User (username, password, type) VALUES ('user6', '123', 'Company'); insert into User (username, password, type) VALUES ('user7', '123', 'Municipality'); insert into User (username, password, type) VALUES ('user8', '123', 'Government_Agency'); insert into User (username, password, type) VALUES ('user9', '123', 'Individual'); insert into User (username, password, type) VALUES ('user10', '123', 'Company'); insert into User (username, password, type) VALUES ('user11', '123', 'Municipality'); insert into User (username, password, type) VALUES ('user12', '123', 'Government_Agency'); insert into User (username, password, type) VALUES ('user13', '123', 'Individual'); insert into User (username, password, type) VALUES ('user14', '123', 'Company'); insert into User (username, password, type) VALUES ('user15', '123', 'Municipality'); insert into User (username, password, type) VALUES ('user16', '123', 'Government_Agency'); insert into User (username, password, type) VALUES ('user17', '123', 'Individual'); insert into User (username, password, type) VALUES ('user18', '123', 'Company'); insert into User (username, password, type) VALUES ('user19', '123', 'Municipality'); insert into User (username, password, type) VALUES ('user20', '123', 'Government_Agency'); insert into Individual (username, firstname, lastname, job_title, hired_date) VALUES ('user1', 'Harry', 'Potter', 'Software Developer', '1997-06-26'); insert into Individual (username, firstname, lastname, job_title, hired_date) VALUES ('user5', 'Hao', 'Chen', 'Chemical Engineer', '2014-06-26'); insert into Individual (username, firstname, lastname, job_title, hired_date) VALUES ('user9', 'Joe', 'Smith', 'Dentist', '1998-06-26'); insert into Individual (username, firstname, lastname, job_title, hired_date) VALUES ('user13', 'Andrew', 'Ng', 'Professor', '1996-06-26'); insert into Individual (username, firstname, lastname, job_title, hired_date) VALUES ('user17', 'David', 'Nash', 'Software Developer', '2016-06-26'); insert into Company (username, name, headquarter_location) VALUES ('user2', 'Caterpillar', 'Illinois'); insert into Company (username, name, headquarter_location) VALUES ('user6', 'Intel', 'Portland'); insert into Company (username, name, headquarter_location) VALUES ('user10', 'Microsoft', 'Seattle'); insert into Company (username, name, headquarter_location) VALUES ('user14', 'Google', 'SF'); insert into Company (username, name, headquarter_location) VALUES ('user18', 'Seven Bridges', 'Cambridge'); insert into Municipality (username, name, population_size) VALUES ('user3', 'City of Atlanta', '1000000'); insert into Municipality (username, name, population_size) VALUES ('user7', 'City of Boston', '300000'); insert into Municipality (username, name, population_size) VALUES ('user11', 'City of Cambridge', '200000'); insert into Municipality (username, name, population_size) VALUES ('user15', 'City of Watertown', '100000'); insert into Municipality (username, name, population_size) VALUES ('user19', 'City of Portland', '800000'); insert into Government_Agency (username, name, jurisdiction) VALUES ('user4', 'CDC', 'Federal'); insert into Government_Agency (username, name, jurisdiction) VALUES ('user8', 'FBI', 'Federal'); insert into Government_Agency (username, name, jurisdiction) VALUES ('user12', 'FDA', 'Federal'); insert into Government_Agency (username, name, jurisdiction) VALUES ('user16', 'DoD', 'Federal'); insert into Government_Agency (username, name, jurisdiction) VALUES ('user20', 'DoT', 'Federal'); insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (1, 'user1', '2016-11-01', 'flood', 31.005, 38.202); insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (2, 'user1', '2016-11-18', 'traffic accident', 31.122, 38.513); insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (3, 'user2', '2016-11-16', 'flood', 27.156, 38.211); insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (4, 'user2', '2016-11-16', 'fire', 27.101, 38.204); insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (5, 'user3', '2016-11-17', 'land slide', 31.511, 38.721); insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (6, 'user3', '2016-11-17', 'midtown power outage', 31.503, 38.701); insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (7, 'user3', '2016-11-17', 'hurricane', 31.123, 38.123); insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (8, 'user3', '2016-11-18', 'traffic accident', 31.123, 38.521); insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (9, 'user4', '2016-11-18', 'flu', 31.235, 38.513); insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (10, 'user7', '2016-11-18', 'earthquake', 42.35, 71.06); -- insert into Incident (id, reporter_username, incident_date, description, lon, lat) VALUES (11, 'user5', '2016-11-18', 'fire', 45.52, -122.68); insert into Cost_Denominator (cost_denominator) VALUES ('day'); insert into Cost_Denominator (cost_denominator) VALUES ('hour'); insert into Cost_Denominator (cost_denominator) VALUES ('week'); insert into Cost_Denominator (cost_denominator) VALUES ('month'); insert into Cost_Denominator (cost_denominator) VALUES ('item'); insert into ESF (id, description) VALUES (1, 'Transportation'); insert into ESF (id, description) VALUES (2, 'Communications'); insert into ESF (id, description) VALUES (3, 'Public Works and Engineering'); insert into ESF (id, description) VALUES (4, 'Firefighting'); insert into ESF (id, description) VALUES (5, 'Emergency Management'); insert into ESF (id, description) VALUES (6, 'Mass Care, Emergency Assistance, Housing, and Human Services'); insert into ESF (id, description) VALUES (7, 'Logistics Management and Resource Support'); insert into ESF (id, description) VALUES (8, 'Public Health and Medical Services'); insert into ESF (id, description) VALUES (9, 'Search and Rescuse'); insert into ESF (id, description) VALUES (10, 'Oil and Hazardous Materials Response'); insert into ESF (id, description) VALUES (11, 'Agriculture and Natural Resources'); insert into ESF (id, description) VALUES (12, 'Energy'); insert into ESF (id, description) VALUES (13, 'Public Safety and Security'); insert into ESF (id, description) VALUES (14, 'Long-Term Community Recovery'); insert into ESF (id, description) VALUES (15, 'External Affairs'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (1, 'user2', 'Tractor', 'toyota', 27.1, 38.3, 3, 50, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (2, 'user2', 'Truck', 'ford', 27.1, 38.3, 3, 40, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (3, 'user2', 'Tent', 'peak', 27.1, 38.3, 6, 60, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (4, 'user3', 'Water', '10000 ton', 30.1, 38.3, 11, 1000, 'week'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (5, 'user3', 'All Terrain Vehicle', 'CAT', 30.1, 38.3, 1, 150, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (6, 'user3', 'Ambulance', 'Medical', 30.1, 38.3, 8, 100, 'hour'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (7, 'user3', 'Hummer', '', 30.1, 38.3, 1, 100, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (8, 'user3', 'Fire truck', '', 30.1, 38.3, 4, 200, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (9, 'user3', 'Bus', '30 seats', 30.1, 38.3, 1, 100, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (10, 'user2', 'Corn', '1000 ton', 27.1, 38.3, 11, 100, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (11, 'user1', 'SUV', 'GMC', 26.1, 39.1, 1, 50, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (12, 'user3', 'Fax machine', '', 30.1, 38.3, 2, 10, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (13, 'user2', 'Portable power supply', '', 27.1, 38.3, 12, 1000, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (14, 'user2', 'Warehouse', '10000 sqft', 27.1, 38.3, 7, 200, 'day'); insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) VALUES (15, 'user3', 'Medicine', 'Tylenol', 30.1, 38.3, 8, 10, 'item'); -- insert into Resource (id, owner_username, name, model, lon, lat, primary_ESF_id, cost_dollar_amount, cost_denominator) -- VALUES (16, 'user19', 'Fire Truck', '', 45.52, -122.71, 4, 100, 'day'); insert into Resource_AdditionalESF (resource_id, ESF_id) VALUES (1, 9); insert into Resource_AdditionalESF (resource_id, ESF_id) VALUES (5, 9); insert into Resource_AdditionalESF (resource_id, ESF_id) VALUES (6, 9); insert into Resource_AdditionalESF (resource_id, ESF_id) VALUES (7, 9); insert into Resource_AdditionalESF (resource_id, ESF_id) VALUES (8, 1); insert into Resource_AdditionalESF (resource_id, ESF_id) VALUES (9, 6); insert into Resource_AdditionalESF (resource_id, ESF_id) VALUES (14, 6); insert into Capability (resource_id, capability) VALUES (1, '500 hp'); insert into Capability (resource_id, capability) VALUES (7, 'GPS'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (1, 1, '2016-10-01', '2016-10-07'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (2, 5, '2016-11-01', '2016-12-30'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (3, 6, '2016-12-15', '2016-12-30'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (4, 7, '2016-11-01', '2016-12-30'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (5, 8, '2016-12-10', '2016-12-30'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (6, 9, '2016-12-10', '2016-12-30'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (7, 12, '2017-01-01', '2017-02-01'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (8, 13, '2017-01-01', '2017-02-01'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (9, 2, '2016-12-15', '2016-12-31'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (10, 3, '2017-01-01', '2017-02-01'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (11, 14, '2017-01-01', '2017-02-01'); insert into Repair_Schedule (id, resource_id, start_date, end_date) VALUES (12, 11, '2017-01-01', '2017-02-01'); insert into Request (id, status, expected_return_date, requesting_resource_id, sender_username, incident_id) VALUES (1, 'Accepted', '2016-02-01', 1, 'user1', 1); insert into Request (id, status, expected_return_date, requesting_resource_id, sender_username, incident_id) VALUES (2, 'Pending', '2016-12-10', 6, 'user1', 2); insert into Request (id, status, expected_return_date, requesting_resource_id, sender_username, incident_id) VALUES (3, 'Accepted', '2017-01-30', 10, 'user2', 3); insert into Request (id, status, expected_return_date, requesting_resource_id, sender_username, incident_id) VALUES (4, 'Pending', '2016-12-15', 4, 'user2', 4); insert into Request (id, status, expected_return_date, requesting_resource_id, sender_username, incident_id) VALUES (5, 'Pending', '2016-12-19', 4, 'user2', 5); insert into Request (id, status, expected_return_date, requesting_resource_id, sender_username, incident_id) VALUES (6, 'Accepted', '2016-12-15', 13, 'user3', 6); insert into Request (id, status, expected_return_date, requesting_resource_id, sender_username, incident_id) VALUES (7, 'Accepted', '2016-12-15', 3, 'user3', 7); insert into Request (id, status, expected_return_date, requesting_resource_id, sender_username, incident_id) VALUES (8, 'Pending', '2017-12-30', 2, 'user3', 8); insert into Request (id, status, expected_return_date, requesting_resource_id, sender_username, incident_id) VALUES (9, 'Pending', '2016-12-30', 15, 'user4', 9); insert into Request (id, status, expected_return_date, requesting_resource_id, sender_username, incident_id) VALUES (10, 'Pending', '2016-12-30', 5, 'user1', 1); insert into Deploy_Schedule (id, resource_id, responding_incident_id, start_date, end_date) VALUES (1, 1, 1, '2016-11-01', '2017-01-07'); insert into Deploy_Schedule (id, resource_id, responding_incident_id, start_date, end_date) VALUES (2, 10, 3, '2016-11-02', '2016-12-15'); insert into Deploy_Schedule (id, resource_id, responding_incident_id, start_date, end_date) VALUES (3, 13, 6, '2016-11-02', '2016-12-15'); insert into Deploy_Schedule (id, resource_id, responding_incident_id, start_date, end_date) VALUES (4, 3, 7, '2016-11-02', '2016-12-15'); insert into Deploy_Schedule (id, resource_id, responding_incident_id, start_date, end_date) VALUES (5, 11, 7, '2016-11-02', '2016-12-15');
true
fdfc0dbaae3efd4a4255b25c98510f4be5ab4ea3
SQL
xiahuidefanfan/mumu
/mumu-admin/sql/sys_dict.sql
UTF-8
2,299
2.828125
3
[]
no_license
/* SQLyog Ultimate v12.3.1 (64 bit) MySQL - 5.7.20-log ********************************************************************* */ /*!40101 SET NAMES utf8 */; create table `sys_dict` ( `id` int (11), `num` int (11), `pid` int (11), `name` varchar (765), `code` varchar (150), `tips` varchar (765) ); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('16','0','0','状态','STATUS','全局状态'); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('17','1','16','启用','STATUS_ON',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('18','2','16','禁用','STATUS_OFF',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('29','0','0','性别','SEX','性别字典'); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('30','1','29','男','SEX_MAN',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('31','2','29','女','MAN_WOMAN',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('35','0','0','账号状态','ACCOUNT_STATUS','账号状态'); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('36','1','35','启用','ACCOUNT_STATUS_ON',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('37','2','35','冻结','ACCOUNT_STATUS_freeze',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('38','3','35','已删除','ACCOUNT_STATUS_DELETE',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('42','0',NULL,'书籍上下架','BOOK_UPPER','是否上架 1:上架 0:未上架'); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('47','2','42','上架','BOOK_UPPER_ON',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('48','2','42','下架','BOOK_UPPER_OFF',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('49','0',NULL,'删除状态','DELETE',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('50','2','49','未删除','DELETE_NO',NULL); insert into `sys_dict` (`id`, `num`, `pid`, `name`, `code`, `tips`) values('51','2','49','已删除','DELETE_YES',NULL);
true
300367767929a02272921e690e80585685710990
SQL
King-01/dbmsproject
/tablegenerator.sql
UTF-8
11,045
3.609375
4
[]
no_license
-- Script written so as to be able to generate the schema tables drop database if exists `merchant-manager`; create database if not exists `merchant-manager`; use `merchant-manager`; -- Table creation script DROP TABLE IF EXISTS `user`; CREATE TABLE user ( id int not null auto_increment, displayname varchar(50) not null, username varchar(50) NOT NULL, password char(68) NOT NULL, email varchar(50) not null unique, pan varchar(50) not null unique, gstin varchar(50) not null unique, tdsaccountnumber varchar(50) default null, addressline1 varchar(100) not null default "-", addressline2 varchar(100) default null, city varchar(100) not null default "-", pincode varchar(50) not null default "-", mobilenumber1 varchar(50) not null, mobilenumber2 varchar(50) , PRIMARY KEY (id), unique(username) ); insert into user value('1', 'Aasav Badera', 'aasavbadera', '$2a$10$2yi5mea10Sm.w68No2FwHOck/Yti4InPJZPWDq6LJ5PnKi5w4w8fi', 'aasav.badera@gmail.com', 'BNZAA2318J', '06BZAHM6385P6Z2', NULL, 'h-2', NULL, 'kota', '324005', '9782565081', NULL); insert into user value('2', 'Aasav Badera', 'aasavbadera1', '$2a$10$TRnAOfWfJow8B4XR2C2OwOxbqgHAOSK.oOaro3CXT.pyxkfehzX7O', 'aasav.badera1@gmail.com', 'BNAAA2318J', '06BZAHM6485P6Z2', NULL, 'Room Number - 9, C. V. Raman Hostel,', NULL, 'Varanasi, Uttar Pradesh', '221005', '9782565081', NULL); drop table if exists role; create table role( id int not null auto_increment, name varchar(50) default "ROLE_EMPLOYEE", primary key(id) ); insert into role value(1, 'ROLE_EMPLOYEE'); -- insert into role values ("ROLE_EMPLOYEE");user_roles drop table if exists users_roles; create table users_roles( user_id int not null, role_id int not null, primary key(user_id, role_id), foreign key(user_id) references user(id), foreign key(role_id) references role(id) ); insert into users_roles value(1,1); insert into users_roles value(2,1); -- INSERT INTO `user` -- VALUES -- ('john','{bcrypt}$2a$04$eFytJDGtjbThXa80FyOOBuFdK2IwjyWefYkMpiBEFlpBwDH.5PM0K',1), -- ('mary','{bcrypt}$2a$04$eFytJDGtjbThXa80FyOOBuFdK2IwjyWefYkMpiBEFlpBwDH.5PM0K',1), -- ('susan','{bcrypt}$2a$04$eFytJDGtjbThXa80FyOOBuFdK2IwjyWefYkMpiBEFlpBwDH.5PM0K',1); DROP TABLE IF EXISTS `authorities`; CREATE TABLE authorities ( username_id int NOT NULL, authority varchar(50) NOT NULL, foreign key(username_id) references user(id) on delete cascade ); -- INSERT INTO `authorities` -- VALUES -- ('john','ROLE_EMPLOYEE'), -- ('mary','ROLE_EMPLOYEE'), -- ('mary','ROLE_MANAGER'), -- ('susan','ROLE_EMPLOYEE'), -- ('susan','ROLE_ADMIN'); -- drop table if exists companymobilenumber; -- create table companymobilenumber( -- id int not null auto_increment, -- mobileno varchar(50) not null, -- username_id varchar(50) not null, -- primary key(id), -- foreign key(username_id) references user(username) on delete cascade -- ); -- drop table if exists companyemail; -- create table companyemail( -- id int not null auto_increment, -- email varchar(50) not null, -- username_id varchar(50) not null, -- primary key(id), -- foreign key(username_id) references user(username) on delete cascade -- ); drop table if exists schedules; create table schedules( id int not null auto_increment, name varchar(50) not null, primary key(id), username_id varchar(50) not null, enabled int not null default 1, foreign key(username_id) references user(username) on delete cascade, unique(name, username_id) ); insert into schedules value(1,'kisan','aasavbadera', 1); insert into schedules value('2', 'Crops', 'aasavbadera', 1); drop table if exists group_s; create table group_s( id int not null auto_increment, groupname varchar(50) not null, schedulename int not null, primary key(id), enabled int not null default 1, foreign key(schedulename) references schedules(id) on delete cascade ); insert into group_s value('1', 'Badaud', '1', 1); insert into group_s value( '2', 'Rabi', '2', 1 ); drop table if exists accounts; create table accounts( id int not null auto_increment, accountname varchar(60) not null, guarantorname varchar(50) not null, groupname int not null, HSNnumber varchar(50) default 'NA', email varchar(50), mobilenumber1 varchar(50) not null, mobilenumber2 varchar(50), PAN varchar(50), addressline2 varchar(100) default null, addressline1 varchar(100) not null, city varchar(100) default null, pincode varchar(50) default null, enabled int not null default 1, primary key(id), foreign key(groupname) references group_s(id) on delete cascade ); insert into accounts value( '1', 'Yay', 'Pradeep Kumar', '1', NULL, NULL, '9782565081', NULL, NULL, NULL, 'Room Number - 9, C. V. Raman Hostel,', 'Varanasi, Uttar Pradesh', '221005', 1); insert into accounts value('2', 'Dharma', 'Pradeep', '1', '123', NULL, '9782565081', NULL, NULL, NULL, 'Room Number - 9, C. V. Raman Hostel,', 'Varanasi, Uttar Pradesh', '221005', 1); drop table if exists tax; create table tax( id int not null auto_increment, taxtype varchar(50) not null, username_id int not null, taxrate varchar(50) not null default 0, foreign key(username_id) references user(id) on delete cascade, primary key(id), unique(taxtype, taxrate) ); insert into tax value( '1', 'CGST', '1', '5' ); insert into tax value( '2', 'SGST', '1', '6' ); insert into tax value( '3', 'GSTIN', '1', '10' ); drop table if exists stockitem; create table stockitem( id int not null auto_increment, primary key(id), quantity int not null, itemname varchar(50) not null, hsngroup varchar(50), manditax varchar(50) not null, kkfee varchar(50) not null, commision varchar(50) not null, labourcharge varchar(50) not null, packing varchar(50) not null, groupname int not null, foreign key(groupname) references group_s(id) on delete cascade ); insert into stockitem value( '1', '1', 'Wheat', NULL, '5', '6', '4', '2', '1', '1' ); insert into stockitem value( '2', '2','Corn', NULL, '2', '4', '2', '8', '1', '2' ); drop table if exists stock_tax; create table stock_tax( id int unique not null auto_increment, stock_id int not null, tax_id int not null, primary key(id), foreign key(stock_id) references stockitem(id), foreign key(tax_id) references tax(id), unique(stock_id, tax_id) ); insert into stock_tax(id, stock_id, tax_id) values ('1', '1', '1'), ('3', '2', '1'), ('2', '2', '3'); drop table if exists journalvoucher; create table journalvoucher( jvoucherid int not null auto_increment, date date not null, credittotal varchar(50) not null default 0, debittotal varchar(50) not null default 0, accountid int not null, description text , primary key(jvoucherid), username_id varchar(50) not null, name varchar(50), foreign key(accountid) references accounts(id) on delete cascade, foreign key(username_id) references user(username) on delete cascade ); insert into journalvoucher(jvoucherid, date, credittotal, debittotal, accountid, description, username_id, name) values ('1', '2020-11-08', '24.14', '324.15', '1', 'NA', 'aasavbadera', 'Yay'), ('2', '2020-11-08', '32.24', '21.31', '1', NULL, 'aasavbadera', 'Yay'), ('3', '2020-11-14', '511.15', '21.3', '2', 'Loss', 'aasavbadera', 'Dharma'), ('4', '2020-12-30', '123.14', '0.0', '1', 'Prof', 'aasavbadera', 'Yay'), ('5', '2020-11-26', '21313.14', '123.1', '2', 'heavy profit', 'aasavbadera', 'Dharma'); drop table if exists bankvoucher; create table bankvoucher( bvoucherid int not null auto_increment, date date not null, credittotal varchar(50) not null default 0, description text , accountid int not null, debittotal varchar(50) not null default 0, name varchar(50), primary key(bvoucherid), username_id varchar(50) not null, foreign key(username_id) references user(username) on delete cascade, foreign key(accountid) references accounts(id) on delete cascade ); insert into bankvoucher(bvoucherid, date, credittotal, description, accountid, debittotal, name, username_id) values ('1', '2020-11-01', '12314.0', 'Cheque Id - 521421', '2', '0.0', 'Dharma', 'aasavbadera'), ('2', '2020-11-09', '4123.14', 'Id - 3', '2', '3162.4', 'Dharma', 'aasavbadera'), ('3', '2020-11-11', '2131.0', 'id = 4', '1', '21984.1', 'Yay', 'aasavbadera'), ('4', '2020-11-12', '348725.12', 'just random text', '2', '1.0', 'Dharma', 'aasavbadera'), ('5', '2020-11-03', '5238.0', 'NAN', '1', '1234.0', 'Yay', 'aasavbadera'); drop table if exists cashvoucher; create table cashvoucher( cvoucherid int not null auto_increment, date date not null, description text , credittotal varchar(50) not null default 0, debittotal varchar(50) not null default 0, name varchar(50), accountid int not null, primary key(cvoucherid), username_id varchar(50) not null, foreign key(username_id) references user(username) on delete cascade, foreign key(accountid) references accounts(id) on delete cascade ); drop table if exists purchasebill; create table purchasebill( pvoucherid int not null auto_increment, trucknumber varchar(50), cost Double, currdate date not null, suppliername varchar(50) not null, description text, supplierid int not null, primary key(pvoucherid), username_id varchar(50) not null, tax double, foreign key(username_id) references user(username) on delete cascade, foreign key(supplierid) references accounts(id) on delete cascade ); insert into purchasebill value ('1', NULL, '10.3', '2020-11-03', 'Yay', NULL, '1', 'aasavbadera', NULL); drop table if exists salebill; create table salebill( svoucherid int not null auto_increment, cost double, currdate date not null, username_id varchar(50) not null, suppliername varchar(50) not null, supplierid int not null, description text, foreign key(username_id) references user(username) on delete cascade, foreign key(supplierid) references accounts(id) on delete cascade, trucknumber varchar(50), tax double, primary key(svoucherid) ); drop table if exists saleitems; create table saleitems( id int not null auto_increment, primary key(id), quantity varchar(50) not null default 0, rate varchar(50) not null default 0, svoucherid int not null, itemname varchar(50) not null, totalamount double, tax double, taxbreakup text, foreign key(svoucherid) references salebill(svoucherid) on delete cascade, unique(quantity, rate, svoucherid, itemname) ); drop table if exists purchaseitems; create table purchaseitems( id int not null auto_increment, primary key(id), quantity int not null default 0, rate double not null default 0, totalamount double, taxbreakup text, tax double, pvoucherid int not null, itemname varchar(50) not null, foreign key(pvoucherid) references purchasebill(pvoucherid) on delete cascade, unique(quantity, rate, pvoucherid, itemname) ); insert into purchaseitems values ('1', '0', '1', '2.44', 'Total tax:Rs.0.44(22.00%: KKFee:6.00% Commision:4.00% Labour Charge:2.00% Mandi Tax:5% CGST:5%', '0.44', '1', 'Wheat'), ('2', '0', '2', '7.86', 'Total tax:Rs.1.86(31.00%: KKFee:4.00% Commision:2.00% Labour Charge:8.00% Mandi Tax:2% CGST:5% GSTIN:10%', '1.86', '1', 'Corn'); drop table if exists current_availability; create table current_availability( id int not null auto_increment, stock_id int not null, quantity int not null, primary key(id), foreign key(stock_id) references stockitem(id) );
true
5fa7ece78b8a1e4e2842e383a4888da0cf320494
SQL
CuriousIbrahim/bit-url
/sql/create.sql
UTF-8
1,020
3.96875
4
[ "MIT" ]
permissive
CREATE TABLE url ( id text PRIMARY KEY, original_url text NOT NULL, times_visited integer default 0 not null, created_at timestamp with time zone default current_timestamp ); create table country ( code text primary key, name text not null, iso_code_1 text, iso_code_2 text ); create table city ( name text, country_code text references country(code), unique(name, country_code), primary key (name, country_code) ); create table timezone ( name text primary key ); create table ip_address ( ip inet primary key, hostname text, zipcode text, latitude real, longitude real, timezone text references timezone(name), region text, city_name text, country_code text, foreign key (city_name, country_code) references city(name, country_code) -- unique(city_name, country_code) ); create table visit ( id serial primary key, ip inet references ip_address(ip), url_id text references url(id) );
true
be9f551bbed6831ae921b6d03232b459cb452204
SQL
autofires/DAW-SIST31A-GP2
/SistemaVentasV2/basedatos/sistema_vehiculos.sql
UTF-8
5,603
3.375
3
[]
no_license
/* SQLyog Enterprise v13.1.1 (64 bit) MySQL - 10.1.37-MariaDB : Database - sistema_vehiculos ********************************************************************* */ /*!40101 SET NAMES utf8 */; /*!40101 SET SQL_MODE=''*/; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; CREATE DATABASE /*!32312 IF NOT EXISTS*/`sistema_vehiculos` /*!40100 DEFAULT CHARACTER SET latin1 */; USE `sistema_vehiculos`; /*Table structure for table `marcas` */ DROP TABLE IF EXISTS `marcas`; CREATE TABLE `marcas` ( `id_marca` INT(255) NOT NULL AUTO_INCREMENT, `marca` VARCHAR(100) DEFAULT NULL, `marcaf` VARCHAR(255) DEFAULT NULL, PRIMARY KEY (`id_marca`) ) ENGINE=INNODB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1; /*Data for the table `marcas` */ /*Table structure for table `usuario` */ DROP TABLE IF EXISTS `usuario`; CREATE TABLE `usuario` ( `usuario` VARCHAR(100) NOT NULL, `contra` VARCHAR(10000) DEFAULT NULL, `tipo_usuario` VARCHAR(100) DEFAULT NULL, `email` VARCHAR(255) DEFAULT NULL, PRIMARY KEY (`usuario`) ) ENGINE=INNODB DEFAULT CHARSET=latin1; /*Data for the table `usuario` */ /*Table structure for table `clientes` */ DROP TABLE IF EXISTS `clientes`; CREATE TABLE `clientes` ( `DUI_cliente` VARCHAR(11) NOT NULL, `Nom_cliente` VARCHAR(75) DEFAULT NULL, `Ape_cliente` VARCHAR(75) DEFAULT NULL, `Correo_cliente` VARCHAR(100) DEFAULT NULL, `Tel_cliente` VARCHAR(25) DEFAULT NULL, `Dir_cliente` BLOB, `NIT_cliente` VARCHAR(25) DEFAULT NULL, `usuario` VARCHAR(100) DEFAULT NULL, PRIMARY KEY (`DUI_cliente`), KEY `usuario` (`usuario`), CONSTRAINT `clientes_ibfk_1` FOREIGN KEY (`usuario`) REFERENCES `usuario` (`usuario`) ) ENGINE=INNODB DEFAULT CHARSET=latin1; /*Data for the table `clientes` */ /*Table structure for table `fotos` */ DROP TABLE IF EXISTS `fotos`; CREATE TABLE `fotos` ( `Num_serie` VARCHAR(100) DEFAULT NULL, `foto` VARCHAR(200) DEFAULT NULL, KEY `Num_serie` (`Num_serie`), CONSTRAINT `fotos_ibfk_1` FOREIGN KEY (`Num_serie`) REFERENCES `vehiculos` (`Num_serie`) ) ENGINE=INNODB DEFAULT CHARSET=latin1; /*Data for the table `fotos` */ /*Table structure for table `login_attempts` */ DROP TABLE IF EXISTS `login_attempts`; CREATE TABLE `login_attempts` ( `usuario` VARCHAR(100) DEFAULT NULL, `tiempo` VARCHAR(1000) DEFAULT NULL, KEY `usuario` (`usuario`), CONSTRAINT `login_attempts_ibfk_1` FOREIGN KEY (`usuario`) REFERENCES `usuario` (`usuario`) ) ENGINE=INNODB DEFAULT CHARSET=latin1; /*Data for the table `login_attempts` */ /*Table structure for table `reservacion` */ DROP TABLE IF EXISTS `reservacion`; CREATE TABLE `reservacion` ( `id_reservacion` INT(100) NOT NULL AUTO_INCREMENT, `Num_serie` VARCHAR(100) DEFAULT NULL, `DUI_cliente` VARCHAR(11) DEFAULT NULL, `fecha_reservacion` DATE DEFAULT NULL, `fecha_fin_reserv` DATE DEFAULT NULL, PRIMARY KEY (`id_reservacion`), KEY `reservacionauto` (`Num_serie`), KEY `reservacioncliente` (`DUI_cliente`), CONSTRAINT `reservacionauto` FOREIGN KEY (`Num_serie`) REFERENCES `vehiculos` (`Num_serie`), CONSTRAINT `reservacioncliente` FOREIGN KEY (`DUI_cliente`) REFERENCES `clientes` (`DUI_cliente`) ) ENGINE=INNODB DEFAULT CHARSET=latin1; /*Data for the table `reservacion` */ INSERT INTO `usuario`(`usuario`,`contra`,`tipo_usuario`,`email`) VALUES ('juanca123','8fc2476dba04231de92077e1c118396e628fb81c1b733074e3c172e2b60a6535f3490019cc47caf63aca12c27c68fb7b439d432a75625064c6dc46e5bd3f5d38','admin','juanithows@gmail.com'), ('usuario','b9b98ac59bfb8b5be83eb88e2c90fc2c3c33e12f5731a1a9b9f208552aa21f19eef3c4ab2a520be2a8d6bc31d53a2cbcead72fdfed42066a595fa0aeeca932a0','cliente','hola@gmail.com'); /*Table structure for table `vehiculos` */ DROP TABLE IF EXISTS `vehiculos`; CREATE TABLE `vehiculos` ( `Num_serie` VARCHAR(100) NOT NULL, `id_marca` INT(250) DEFAULT NULL, `modelo` VARCHAR(50) DEFAULT NULL, `anio_vehiculo` YEAR(4) DEFAULT NULL, `matricula` VARCHAR(45) DEFAULT NULL, `kilometraje` INT(100) DEFAULT NULL, `transmision` VARCHAR(45) DEFAULT NULL, `cilindros` INT(25) DEFAULT NULL, `caballos_fuerza` INT(45) DEFAULT NULL, `caracteristicas` BLOB, `precio_compra` DECIMAL(45,0) DEFAULT NULL, `precio_venta` DECIMAL(45,0) DEFAULT NULL, `estado` VARCHAR(100) DEFAULT NULL, PRIMARY KEY (`Num_serie`), KEY `id_marca` (`id_marca`), CONSTRAINT `vehiculos_ibfk_1` FOREIGN KEY (`id_marca`) REFERENCES `marcas` (`id_marca`) ) ENGINE=INNODB DEFAULT CHARSET=latin1; /*Data for the table `vehiculos` */ /*Table structure for table `ventas` */ DROP TABLE IF EXISTS `ventas`; CREATE TABLE `ventas` ( `id_venta` INT(100) NOT NULL AUTO_INCREMENT, `Num_serie` VARCHAR(100) DEFAULT NULL, `DUI_cliente` VARCHAR(11) DEFAULT NULL, `fecha_venta` DATE DEFAULT NULL, `cantidad` INT(11) DEFAULT NULL, `total_venta` DOUBLE DEFAULT NULL, `total_iva` DOUBLE DEFAULT NULL, `total_vent_iva` DOUBLE DEFAULT NULL, `venta_exito` VARCHAR(45) DEFAULT NULL, PRIMARY KEY (`id_venta`), KEY `Num_serie` (`Num_serie`), KEY `DUI_cliente` (`DUI_cliente`), CONSTRAINT `ventas_ibfk_1` FOREIGN KEY (`Num_serie`) REFERENCES `vehiculos` (`Num_serie`), CONSTRAINT `ventas_ibfk_2` FOREIGN KEY (`DUI_cliente`) REFERENCES `clientes` (`DUI_cliente`), ) ENGINE=INNODB DEFAULT CHARSET=latin1; /*Data for the table `ventas` */ /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
true
bee3521171a09c4b885b5404b5c627441b52ac82
SQL
ASketin/Database_KIB_2021
/Week3/solutions/fourth_task.sql
UTF-8
528
4.1875
4
[]
no_license
-- Для всех треков жанра Rock и Metal, для каждого артиста подсчитать количество треков. -- Вывести имя артиста, количество треков. (artist_name, qty) SELECT art.name as artist_name, COUNT(track_id) as qty FROM artist art JOIN album a USING (artist_id) JOIN track t USING (album_id) JOIN (SELECT * FROM genre WHERE name IN ('Rock', 'Metal')) g USING (genre_id) GROUP BY art.artist_id;
true
4f7968785f8658d0e72533affd5ffd9eefd2ad64
SQL
vyesubabu/metview
/odb_api_bundle-0.17.6-Source/odb/src/ddl.CCMA/robody_min.sql
UTF-8
1,984
3.046875
3
[]
no_license
// //-- ODB/SQL file 'robody.sql' // // Last updated: 08/04/2010 A. Fouilloux Remove tcwv_fg // // Yannick: hardcoded 3 in obs_diags_* READONLY; SET $tslot = -1; SET $kset = 0; CREATE VIEW robody_min AS SELECT entryno, varno, // r/o datum_anflag UPDATED, // possibly updated datum_event1@body UPDATED, datum_status@body UPDATED, // possibly updated an_depar UPDATED, fg_depar UPDATED, // possibly updated actual_depar UPDATED, // to pass actual departure from one subroutine to another (working ODB column) actual_ndbiascorr UPDATED, // to pass normalised deviation from expected bias correction from one subroutine to another (work ODB column) hires@update[1:$NMXUPD] UPDATED, // possibly updated lores@update[1:$NMXUPD] UPDATED, // possibly updated qc_a UPDATED, // possibly updated qc_l UPDATED, // possibly updated qc_pge UPDATED, // possibly updated obs_diags_1@update[1:$NMXUPD] UPDATED, obs_diags_2@update[1:$NMXUPD] UPDATED, obs_diags_3@update[1:$NMXUPD] UPDATED, obsvalue, // r/o final_obs_error, // r/o fg_error UPDATED, // r/o fc_sens_obs UPDATED, // r/o repres_error UPDATED, // r/o obs_corr_ev[1:$NUMEV], // r/o obs_corr_mask@errstat, // r/o an_sens_obs UPDATED, // r/o vertco_reference_1, vertco_reference_2, // r/o varbc_ix, // r/o biascorr, // r/o FROM timeslot_index, index, hdr, body, update[1:$NMXUPD], errstat WHERE (($tslot == -1 AND timeslot@timeslot_index > 0) OR (timeslot@timeslot_index == $tslot)) AND kset = $kset ORDERBY seqno ;
true
682f0be22af903f3b861609ccef30811639a0574
SQL
IP-CAM/My-Blog-and-some-small-Project-with-Opencart-v.2.1.0.2
/mok/CHANGELOG/db/faq/oc_faq_product.sql
UTF-8
1,137
2.78125
3
[]
no_license
/* Navicat MySQL Data Transfer Source Server : 192.168.100.27 Source Server Version : 50515 Source Host : 192.168.100.27:3306 Source Database : mok Target Server Type : MYSQL Target Server Version : 50515 File Encoding : 65001 Date: 2016-12-25 20:05:37 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `oc_faq_product` -- ---------------------------- DROP TABLE IF EXISTS `oc_faq_product`; CREATE TABLE `oc_faq_product` ( `faq_id` int(11) NOT NULL, `related_id` int(11) NOT NULL, UNIQUE KEY `faq_id` (`faq_id`,`related_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of oc_faq_product -- ---------------------------- INSERT INTO `oc_faq_product` VALUES ('25', '28'); INSERT INTO `oc_faq_product` VALUES ('25', '41'); INSERT INTO `oc_faq_product` VALUES ('25', '42'); INSERT INTO `oc_faq_product` VALUES ('25', '47'); INSERT INTO `oc_faq_product` VALUES ('26', '41'); INSERT INTO `oc_faq_product` VALUES ('26', '48'); INSERT INTO `oc_faq_product` VALUES ('27', '28'); INSERT INTO `oc_faq_product` VALUES ('27', '48');
true
73075a7baddaf3b90fc5e379e7f0d111c5528aca
SQL
ojalaquellueva/cods
/sql/keyword.sql
UTF-8
1,319
2.96875
3
[]
no_license
-- ---------------------------------------------------------- -- Flag potentially cultivated observations by keyword -- -- Requires parameter: -- $tbl_user_data_raw --> :tbl_user_data_raw (job-specific temp table) -- ---------------------------------------------------------- UPDATE :tbl_user_data_raw SET description_unaccent=unaccent(description) ; -- This query will be slow -- Initial wild card prevents use of indexes update :tbl_user_data_raw set is_cultivated_observation=1, is_cultivated_observation_reason='Keywords in locality' WHERE description_unaccent ILIKE '%cultivated%' OR description_unaccent ILIKE '%cultivad%' OR description_unaccent ILIKE '%planted%' OR description_unaccent ILIKE '%sembrad%' OR description_unaccent ILIKE '%ornamental%' OR description_unaccent ILIKE '%garden%' OR description_unaccent ILIKE '%jardin%' OR description_unaccent ILIKE '%jardim%' OR description_unaccent ILIKE '%plantation%' OR description_unaccent ILIKE '%plantacion%' OR description_unaccent ILIKE '%plantacao%' OR description_unaccent ILIKE '%campus%' OR description_unaccent ILIKE '%urban%' OR description_unaccent ILIKE '%greenhouse%' OR description_unaccent ILIKE '%invernadero%' OR description_unaccent ILIKE '%arboretum%' OR description_unaccent ILIKE '%farm%' OR description_unaccent ILIKE '%corn field%' ;
true
314218c31e68d7c23af8c53036c070651208119d
SQL
baygoit/GoJava
/trunk/GoJava7/v.komlev/WebKikstarter/target/webkikstarter/WEB-INF/classes/DB/create_tables.ddl
UTF-8
1,038
3.421875
3
[]
no_license
CREATE TABLE payments ( id INTEGER NOT NULL PRIMARY KEY, user_name VARCHAR2(100) NOT NULL, number_card NUMBER(16) NOT NULL, amount_donation NUMBER(10) NOT NULL, project_id INTEGER NOT NULL, FOREIGN KEY (project_id) REFERENCES projects(id) ); CREATE TABLE quotes ( content VARCHAR2(500) NOT NULL, author VARCHAR2(100) NOT NULL ); CREATE TABLE categories ( id INTEGER NOT NULL PRIMARY KEY, name VARCHAR2(100) NOT NULL ); CREATE TABLE rewards ( id INTEGER NOT NULL PRIMARY KEY, amount_donation NUMBER(10) NOT NULL, reward VARCHAR2(100) NOT NULL, project_id INTEGER NOT NULL, FOREIGN KEY (project_id) REFERENCES projects(id) ); CREATE TABLE projects ( id INTEGER NOT NULL PRIMARY KEY, category_id INTEGER NOT NULL, name VARCHAR2(200) NOT NULL, general_description VARCHAR2(500) NOT NULL, full_description VARCHAR2(900), video_link VARCHAR2(200), required_sum NUMBER(10) NOT NULL, collected_sum NUMBER(10), days_left NUMBER(10) NOT NULL, FOREIGN KEY (category_id) REFERENCES categories(id) );
true
b59e642b6854ca31a1dc625e5d32c099867bcdf8
SQL
fun2vault/Team-4-Project
/update1.sql
UTF-8
1,594
3.96875
4
[]
no_license
DELIMITER $$ CREATE TRIGGER order_stock_deduction AFTER INSERT ON Order_Details FOR EACH ROW BEGIN /* CLEAN UP */ DROP TEMPORARY TABLE IF EXISTS BOM; DROP temporary TABLE IF EXISTS CBOM; /* create temp table to hold the BoM */ CREATE TEMPORARY TABLE BOM ( model_id int(11) ,part_id int(11) ,model_quantity decimal(5,2) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; /* populate with Model_Details */ INSERT INTO BOM (model_id, part_id, model_quantity) SELECT * FROM `Model_Details` WHERE model_id = new.model_id; /* account for order quantity */ UPDATE BOM SET BOM.model_quantity = BOM.model_quantity * new.order_quantity; /* take model from inventory */ UPDATE Inventory AS A RIGHT JOIN BOM AS BOM ON A.part_id = BOM.part_id SET A.units = A.units - BOM.model_quantity; IF NEW.custom_id IS NOT NULL THEN /* create temp table to hold the CBoM */ CREATE TEMPORARY TABLE CBOM ( custom_id int(11) ,part_id int(11) ,custom_quantity decimal(5,2) )ENGINE=MyISAM DEFAULT CHARSET=latin1; /* fill CBOM */ INSERT INTO CBOM (custom_id,part_id,custom_quantity) SELECT * FROM `Customization_Details` WHERE custom_id = new.custom_id; /*account for order quantity */ UPDATE CBOM SET CBOM.custom_quantity = CBOM.custom_quantity * new.order_quantity; /* Subtract Custom from inventory*/ UPDATE Inventory AS A RIGHT JOIN CBOM AS CBOM ON A.part_id = CBOM.part_id SET A.units = A.units - CBOM.custom_quantity; END IF; END$$ DELIMITER ;
true
6363b4354bb0b07cbdeb9ed1bc2beed4be4d1d5f
SQL
developer38/AmexCodingAssignment
/AmexCodingAssignment/src/main/resources/person-data-table.sql
UTF-8
468
2.703125
3
[]
no_license
DROP TABLE IF EXISTS person; create table person ( id integer NOT NULL, name varchar(25) NOT NULL, age integer(3) NOT NULL, dateOfBirth date not null, email varchar(50) NOT NULL ); INSERT INTO person VALUES (1, 'person1', 31, '1981-01-01', 'person1@gmail.com'); INSERT INTO person VALUES (2, 'person2', 32, '1982-02-02', 'person2@gmail.com'); INSERT INTO person VALUES (3, 'person1', 33, '1983-03-03', 'person3@gmail.com'); INSERT INTO person VALUES (4, 'person1', 34, '1984-04-04', 'person4@gmail.com');
true
f3981cb8d8b1e352c031315814eef02cc8743671
SQL
matrix-org/synapse
/synapse/storage/schema/main/delta/59/04_event_auth_chains.sql
UTF-8
1,689
3.609375
4
[ "Apache-2.0" ]
permissive
/* Copyright 2020 The Matrix.org Foundation C.I.C * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -- See docs/auth_chain_difference_algorithm.md CREATE TABLE event_auth_chains ( event_id TEXT PRIMARY KEY, chain_id BIGINT NOT NULL, sequence_number BIGINT NOT NULL ); CREATE UNIQUE INDEX event_auth_chains_c_seq_index ON event_auth_chains (chain_id, sequence_number); CREATE TABLE event_auth_chain_links ( origin_chain_id BIGINT NOT NULL, origin_sequence_number BIGINT NOT NULL, target_chain_id BIGINT NOT NULL, target_sequence_number BIGINT NOT NULL ); CREATE INDEX event_auth_chain_links_idx ON event_auth_chain_links (origin_chain_id, target_chain_id); -- Events that we have persisted but not calculated auth chains for, -- e.g. out of band memberships (where we don't have the auth chain) CREATE TABLE event_auth_chain_to_calculate ( event_id TEXT PRIMARY KEY, room_id TEXT NOT NULL, type TEXT NOT NULL, state_key TEXT NOT NULL ); CREATE INDEX event_auth_chain_to_calculate_rm_id ON event_auth_chain_to_calculate(room_id); -- Whether we've calculated the above index for a room. ALTER TABLE rooms ADD COLUMN has_auth_chain_index BOOLEAN;
true
97fd222603ddc651c99813f17992b8fa108e57ad
SQL
addn-d4ti/survey-kepuasan-smart
/db/db_kantin.sql
UTF-8
8,198
2.875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.7.9 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Nov 17, 2020 at 06:32 AM -- Server version: 10.1.31-MariaDB -- PHP Version: 7.2.3 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `db_kantin` -- -- -------------------------------------------------------- -- -- Table structure for table `admin` -- CREATE TABLE `admin` ( `id_admin` int(11) NOT NULL, `username` varchar(225) NOT NULL, `password` varchar(50) NOT NULL, `nama_lengkap` varchar(225) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `hasil_perhari` -- CREATE TABLE `hasil_perhari` ( `id_hasil` int(11) NOT NULL, `tampilan` varchar(225) NOT NULL, `rasa` varchar(225) NOT NULL, `variasi` varchar(225) NOT NULL, `higienis` varchar(225) NOT NULL, `pelayanan` varchar(225) NOT NULL, `saran` varchar(225) NOT NULL, `tanggal` date NOT NULL, `total` int(11) NOT NULL, `kategori` varchar(225) NOT NULL, `id_karyawan` int(11) NOT NULL, `id_menu` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `hasil_polling` -- CREATE TABLE `hasil_polling` ( `id_hasilpoling` int(11) NOT NULL, `tanggal` date NOT NULL, `menu_senin` varchar(225) NOT NULL, `manu_selasa` varchar(225) NOT NULL, `menu_rabu` varchar(225) NOT NULL, `menu_kamis` varchar(225) NOT NULL, `menu_jumat` varchar(225) NOT NULL, `id_karyawan` int(11) NOT NULL, `id_poling` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `karyawan` -- CREATE TABLE `karyawan` ( `id_karyawan` int(11) NOT NULL, `nama` varchar(50) NOT NULL, `npk` varchar(225) NOT NULL, `bidang` varchar(225) NOT NULL, `foto_karyawan` varchar(225) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `menu` -- CREATE TABLE `menu` ( `id_menu` int(11) NOT NULL, `tanggal` date NOT NULL, `makanan_pokok` varchar(225) NOT NULL, `lauk_hewani` varchar(225) NOT NULL, `lauk_nabati` varchar(225) NOT NULL, `sayur` varchar(225) NOT NULL, `buah` varchar(225) NOT NULL, `minuman` varchar(225) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `menu` -- INSERT INTO `menu` (`id_menu`, `tanggal`, `makanan_pokok`, `lauk_hewani`, `lauk_nabati`, `sayur`, `buah`, `minuman`) VALUES (2, '0000-00-00', 'sadaad', 'asdasd', 'asdasd', 'adsad', 'asdasd', 'asdada'), (3, '2020-11-01', 'sadaad', 'asdasd', 'asdasd', 'adsad', 'asdasd', 'asdada'); -- -------------------------------------------------------- -- -- Table structure for table `poling_menu` -- CREATE TABLE `poling_menu` ( `id_poling` int(11) NOT NULL, `tanggal_mulai` date NOT NULL, `tanggal_selesai` date NOT NULL, `manu_senin` varchar(225) NOT NULL, `menu_selasa` varchar(225) NOT NULL, `menu_rabu` varchar(225) NOT NULL, `menu_kamis` varchar(225) NOT NULL, `menu_jumat` varchar(225) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `t_kuisioner` -- CREATE TABLE `t_kuisioner` ( `id` int(11) NOT NULL, `responden` varchar(250) NOT NULL, `p1` varchar(500) NOT NULL, `p2` varchar(500) NOT NULL, `p3` varchar(500) NOT NULL, `p4` varchar(500) NOT NULL, `p5` varchar(500) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `t_kuisioner` -- INSERT INTO `t_kuisioner` (`id`, `responden`, `p1`, `p2`, `p3`, `p4`, `p5`) VALUES (57, 'Nugraha Eka P', 'Sangat Baik', 'Baik', 'Sangat Baik', 'Sangat Baik', 'Sangat Baik'), (58, 'aji ', 'Baik', 'Buruk', 'Buruk', 'Buruk', 'Buruk'), (59, 'dzikri', 'Sangat Baik', 'Buruk', 'Buruk', 'Buruk', 'Buruk'), (60, 'Dena', 'Cukup', 'Baik', 'Cukup', 'Cukup', 'Cukup'), (61, 'Reinaldo', 'Sangat Baik', 'Cukup', 'Baik', 'Buruk', 'Cukup'), (62, 'Bambang', 'Sangat Baik', 'Baik', 'Baik', 'Baik', 'Baik'), (63, 'reno', 'Sangat Baik', 'Baik', 'Baik', 'Sangat Baik', 'Buruk'), (64, 'Nugi', 'Baik', 'Sangat Baik', 'Baik', 'Sangat Baik', 'Baik'); -- -------------------------------------------------------- -- -- Table structure for table `t_pertanyaan` -- CREATE TABLE `t_pertanyaan` ( `id` int(11) NOT NULL, `pertanyaan` varchar(250) NOT NULL, `isi1` varchar(250) NOT NULL, `isi2` varchar(250) NOT NULL, `isi3` varchar(250) NOT NULL, `isi4` varchar(250) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `t_pertanyaan` -- INSERT INTO `t_pertanyaan` (`id`, `pertanyaan`, `isi1`, `isi2`, `isi3`, `isi4`) VALUES (1, 'Menu Hari ini', 'Sangat Baik', 'Baik', 'Cukup', 'Buruk'), (2, 'Minuman Hari Ini', 'Sangat Baik', 'Baik', 'Cukup', 'Buruk'), (3, 'Lauk Hari Ini', 'Sangat Baik', 'Baik', 'Cukup', 'Buruk'), (4, 'Karyawan Hari Ini', 'Sangat Baik', 'Baik', 'Cukup', 'Buruk'), (5, 'Pelayanan Hari Ini', 'Sangat Baik', 'Baik', 'Cukup', 'Buruk'); -- -------------------------------------------------------- -- -- Table structure for table `t_user` -- CREATE TABLE `t_user` ( `id` int(11) NOT NULL, `nama_user` varchar(250) NOT NULL, `password` varchar(250) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `t_user` -- INSERT INTO `t_user` (`id`, `nama_user`, `password`) VALUES (1, 'admin', 'admin'); -- -- Indexes for dumped tables -- -- -- Indexes for table `admin` -- ALTER TABLE `admin` ADD PRIMARY KEY (`id_admin`); -- -- Indexes for table `hasil_perhari` -- ALTER TABLE `hasil_perhari` ADD PRIMARY KEY (`id_hasil`); -- -- Indexes for table `hasil_polling` -- ALTER TABLE `hasil_polling` ADD PRIMARY KEY (`id_hasilpoling`); -- -- Indexes for table `karyawan` -- ALTER TABLE `karyawan` ADD UNIQUE KEY `id_karyawan` (`id_karyawan`) USING BTREE; -- -- Indexes for table `menu` -- ALTER TABLE `menu` ADD PRIMARY KEY (`id_menu`); -- -- Indexes for table `poling_menu` -- ALTER TABLE `poling_menu` ADD PRIMARY KEY (`id_poling`); -- -- Indexes for table `t_kuisioner` -- ALTER TABLE `t_kuisioner` ADD PRIMARY KEY (`id`); -- -- Indexes for table `t_pertanyaan` -- ALTER TABLE `t_pertanyaan` ADD PRIMARY KEY (`id`); -- -- Indexes for table `t_user` -- ALTER TABLE `t_user` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `admin` -- ALTER TABLE `admin` MODIFY `id_admin` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `hasil_perhari` -- ALTER TABLE `hasil_perhari` MODIFY `id_hasil` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `hasil_polling` -- ALTER TABLE `hasil_polling` MODIFY `id_hasilpoling` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `karyawan` -- ALTER TABLE `karyawan` MODIFY `id_karyawan` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `menu` -- ALTER TABLE `menu` MODIFY `id_menu` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `poling_menu` -- ALTER TABLE `poling_menu` MODIFY `id_poling` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `t_kuisioner` -- ALTER TABLE `t_kuisioner` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=65; -- -- AUTO_INCREMENT for table `t_pertanyaan` -- ALTER TABLE `t_pertanyaan` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `t_user` -- ALTER TABLE `t_user` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
37a33b10c4a68f8c91d55f9fe28b6d61f233ad5f
SQL
cbayonao/sql-mysql
/class2.sql
UTF-8
5,891
4.625
5
[]
no_license
-- Obtiene el campo name, email, gender de la tabla clientes -- donde el genero es F -> Female SELECT name, email, gender FROM clients WHERE gender = 'F'; -- Obtiene el campo name, email, gender de la tabla clientes -- donde el genero es M -> Male SELECT name, email, gender FROM clients WHERE gender = 'M'; -- Obtiene el año de un campo de fecha SELECT YEAR(birthdate) FROM clients; -- Obtiene el año de la fecha actual SELECT YEAR(NOW()); -- Obtiene la diferencia entre la fecha actual y la -- fecha de nacimiento por lo tanto se obtendrá la edad. SELECT name, (YEAR(NOW()) - YEAR(birthdate)) FROM clients; -- LIKE Es una funcion de cercania de terminos SELECT * FROM clients WHERE name LIKE '%Saave%'; -- Obtiene name, funcion para obtener la edad on el alias de 'age' -- de la tabla clientes donde tenga el genero F->Female y el nombre -- contenga ...Lope... SELECT name, (YEAR(NOW()) - YEAR(birthdate)) AS age, gender FROM clients WHERE gender = 'F' AND name LIKE '%Lope%'; SELECT book_id, author_id, title FROM books WHERE author_id between 1 and 5; -- JOIN unir dos tablas relacionadas -- Empezaremos por el FROM SELECT b.book_id, a.name, b.title FROM books AS b JOIN authors AS a ON a.author_id = b.author_id WHERE a.author_id between 1 and 5; SELECT b.book_id, a.name, a.author_id, b.title FROM books AS b JOIN authors AS a ON a.author_id = b.author_id WHERE a.author_id between 1 and 5; ALTER TABLE transactions MODIFY COLUMN `type` enum( 'sell', 'lend', 'return') NOT NULL AFTER client_id; UPDATE transactions SET `type` = 'return' WHERE transaction_id = 5; INSERT INTO transactions(transaction_id,book_id,client_id,`type`,`finished`) VALUES(1,12,34,'sell',1), (2,54,87,'lend',0), (3,3,14,'sell',1), (4,1,54,'sell',1), (5,12,81,'lend',1), (6,12,81,'lend',1), (7,87,29,'sell',1); -- Muestra los clientes que hayan comprado libros que sean mujeres -- Obtiene nombre cliente, titulo del libro, nombre del autor y titpo de transsaccion SELECT c.name, b.title, a.name, t.type FROM transactions AS t JOIN books AS b ON t.book_id = b.book_id JOIN clients AS c ON t.client_id = c.client_id JOIN authors AS a ON b.author_id = a.author_id WHERE c.gender = 'F' AND t.type = 'sell'; -- En la ultima linea usamos IN para elegir un rango de las opicones que queremos SELECT c.name, b.title, a.name, t.type FROM transactions AS t JOIN books AS b ON t.book_id = b.book_id JOIN clients AS c ON t.client_id = c.client_id JOIN authors AS a ON b.author_id = a.author_id WHERE c.gender = 'M' AND t.type IN ('sell', 'lend'); --ESTOS DOS JOINS HACEN EXACTAMENTE LO MISMO -- JOIN IMPLICITO SELECT b.title, a.name FROM authors AS a, books AS b WHERE a.author_id = b.author_id LIMIT 10; -- JOIN EXPLICITO SELECT b.title, a.name FROM books AS b INNER JOIN authors AS a ON a.author_id = b.author_id LIMIT 10; -- Obtengo id del autor, nombre del autor, nacionalidad del autor, titulo del libro -- LEFT JOIN implicito usando BETWEEN Y ORDER BY DESC SELECT a.author_id, a.name, a.nationality, b.title FROM authors AS a JOIN books AS b ON b.author_id = a.author_id WHERE a.author_id BETWEEN 1 AND 5 ORDER BY a.name DESC; -- Obtengo id del autor, nombre del autor, nacionalidad del autor, titulo del libro -- LEFT JOIN EXPLICITO usando BETWEEN Y ORDER BY DEFAULT SELECT a.author_id, a.name, a.nationality, b.title FROM authors AS a LEFT JOIN books AS b ON b.author_id = a.author_id WHERE a.author_id BETWEEN 1 AND 5 ORDER BY a.author_id; -- COUNT NOS SIRVE PARA CONTAR -- NOS OBLIGA A USAR GROUP BY SELECT a.author_id, a.name, a.nationality, COUNT(b.book_id) FROM authors AS a LEFT JOIN books AS b ON b.author_id = a.author_id WHERE a.author_id BETWEEN 1 AND 5 GROUP BY a.author_id ORDER BY a.author_id; -- SELECT a.author_id, a.name, a.nationality, b.title FROM authors AS a LEFT JOIN books AS b ON b.author_id = a.author_id WHERE a.name = 'Sam Altman'; -- SELECT nationality, COUNT(book_id) AS c_libros FROM books as b JOIN authors as a ON a.author_id = b.author_id GROUP BY nationality ORDER BY c_libros DESC; -- SELECT DISTINCT a.nationality, COUNT(b.title) as c_books FROM authors AS a INNER JOIN books as b ON a.author_id = b.author_id GROUP BY b.book_id; -- SELECT nationality, COUNT(book_id) AS libros, AVG(price) AS prom, STDDEV(price) AS desviacion FROM books AS b JOIN authors AS a ON a.author_id = b.author_id GROUP BY nationality ORDER BY prom DESC; -- REPORTE FINAL que muestra las transacciones -- con nombre del cliente y una concatenacion del autor -- Concat perimite concatenar strings -- La funcion TO_DAYS() recibe como parametro o un timestamp o un datetime o incluso una fecha a secas -- Lo que da es el numero de dias que han pasado desde el 1 de enero del año 0 de nuestra epoca hasta el dia de hoy SELECT c.name, t.type, b.title, CONCAT(a.name, " ", "(", a.nationality, ")") AS author, TO_DAYS(NOW()) - TO_DAYS(t.created_at) AS ago FROM transactions AS t LEFT JOIN clients AS c ON c.client_id = t.client_id LEFT JOIN books AS b ON b.book_id = t.book_id LEFT JOIN authors AS a ON b.author_id = a.author_id -- DELETE DELETE FROM tabla WHERE [conditions] LIMIT 1; -- Depende de lo que tengamos pensado eliminar -- UPDATE UPDATE tabla SET [columna = valor, ...] WHERE [consiciones] LIMIT 1; -- Depende de lo que tengamos pensado eliminar -- Actualizar clientes actives con UPDATE Y SET UPDATE clients SET active = 0 WHERE client_id = 77 limit 1; -- Actualizar varios clientes activos al misom tiempo -- Con el client_id o con un wildcard en el nombre UPDATE clients SET active = 0 WHERE client_id in (1, 6, 8, 27, 90) OR name LIKE '%Lopez%'; -- obtener client_id, name, active para validar el query de arriba SELECT client_id, name, active FROM clients WHERE client_id in (1, 6, 8, 27, 90) OR name LIKE '%Lopez%'; -- Vaciar una tabla con un solo comando SELECT * FROM transactions; TRUNCATE transactions;
true
9a502157f7e3be51fdb86539b8359000d8bf5997
SQL
praneeth34/pern_login
/database.sql
UTF-8
702
3.25
3
[]
no_license
CREATE DATABASE loginauth; CREATE TABLE users( user_id uuid DEFAULT uuid_generate_v4(), user_name VARCHAR(255) NOT NULL, user_email VARCHAR(255) NOT NULL UNIQUE, user_password VARCHAR(255) NOT NULL, PRIMARY KEY (user_id) ); CREATE TABLE employees( user_id uuid DEFAULT uuid_generate_v4(), employ_name VARCHAR(255) , gender VARCHAR(255) , designation VARCHAR(255) , city VARCHAR(255), PRIMARY KEY (user_id) ); -- fake users insert into users (user_name, user_email, user_password) values ('goku', 'goku@gmail.com', '123'); -- fake employees insert into employees (employ_name, gender, designation, city) values ('Rebbeca', 'female','lead-developer','chennai');
true
0fb5228c40f98a85fd8381e47a3aef73af4ff165
SQL
z0t0b/ISMN3830
/ClassActivities/Database Creation/CREATE_ELITE_VIDEO_DB_MySQL.sql
UTF-8
6,412
3.578125
4
[]
no_license
Create Database EliteVideo; Use EliteVideo; CREATE TABLE PRICE ( PRICE_CODE NUMERIC(2,0) PRIMARY KEY, PRICE_DESCRIPTION VARCHAR(20) NOT NULL , PRICE_RENTFEE NUMERIC(5,2) CHECK (PRICE_RENTFEE >= 0), PRICE_DAILYLATEFEE NUMERIC(5,2) CHECK (PRICE_DAILYLATEFEE >= 0) ); CREATE TABLE MOVIE ( MOVIE_NUM NUMERIC(8,0) PRIMARY KEY, MOVIE_TITLE VARCHAR(75) NOT NULL, MOVIE_YEAR NUMERIC(4,0) CHECK (MOVIE_YEAR > 1900), MOVIE_COST NUMERIC(5,2), MOVIE_GENRE VARCHAR(50), PRICE_CODE NUMERIC(2,0) REFERENCES PRICE(PRICE_CODE) ); CREATE TABLE VIDEO ( VID_NUM NUMERIC(8,0) PRIMARY KEY, VID_INDATE DATE, MOVIE_NUM NUMERIC(8,0) REFERENCES MOVIE(MOVIE_NUM) ); CREATE TABLE MEMBERSHIP ( MEM_NUM NUMERIC(8,0) PRIMARY KEY, MEM_FNAME VARCHAR(30) NOT NULL, MEM_LNAME VARCHAR(30) NOT NULL, MEM_STREET VARCHAR(120), MEM_CITY VARCHAR(50), MEM_STATE CHAR(2), MEM_ZIP CHAR(5), MEM_BALANCE NUMERIC(10,2) ); CREATE TABLE RENTAL ( RENT_NUM NUMERIC(8,0) PRIMARY KEY, RENT_DATE timestamp DEFAULT current_timestamp, MEM_NUM NUMERIC(8,0) REFERENCES MEMBERSHIP(MEM_NUM) ); CREATE TABLE DETAILRENTAL ( RENT_NUM NUMERIC(8,0), VID_NUM NUMERIC(8,0), DETAIL_FEE NUMERIC(5,2), DETAIL_DUEDATE DATE, DETAIL_RETURNDATE DATE, DETAIL_DAILYLATEFEE NUMERIC(5,2), CONSTRAINT PK_DetailRental PRIMARY KEY(RENT_NUM, VID_NUM), CONSTRAINT FK_DetailRental_Rental FOREIGN KEY(RENT_NUM) REFERENCES RENTAL(RENT_NUM), CONSTRAINT FK_DetailRental_Video FOREIGN KEY(vid_num) REFERENCES VIDEO(vid_num) ); INSERT INTO PRICE VALUES (1, 'Standard', 2, 1); INSERT INTO PRICE VALUES (2, 'New Release', 3.5, 3); INSERT INTO PRICE VALUES (3, 'Discount', 1.5, 1); INSERT INTO PRICE VALUES (4, 'Weekly Special', 1, .5); INSERT INTO MOVIE VALUES (1234, 'The Cesar Family Christmas', 2011, 39.95, 'FAMILY', 2); INSERT INTO MOVIE VALUES (1235, 'Smokey Mountain Wildlife', 2008, 59.95, 'ACTION', 1); INSERT INTO MOVIE VALUES (1236, 'Richard Goodhope', 2012, 59.95, 'DRAMA', 2); INSERT INTO MOVIE VALUES (1237, 'Beatnik Fever', 2011, 29.95, 'COMEDY', 2); INSERT INTO MOVIE VALUES (1238, 'Constant Companion', 2012, 89.95, 'DRAMA', NULL); INSERT INTO MOVIE VALUES (1239, 'Where Hope Dies', 2002, 25.49, 'DRAMA', 3); INSERT INTO MOVIE VALUES (1245, 'Time to Burn', 2009, 45.49, 'ACTION', 1); INSERT INTO MOVIE VALUES (1246, 'What He Doesnt Know', 2010, 58.29, 'COMEDY', 1); INSERT INTO VIDEO VALUES (34341, '2011-01-22', 1235); INSERT INTO VIDEO VALUES (34342, '2011-01-22', 1235); INSERT INTO VIDEO VALUES (34366, '2013-03-02', 1236); INSERT INTO VIDEO VALUES (34367, '2013-03-02', 1236); INSERT INTO VIDEO VALUES (34368, '2013-03-02', 1236); INSERT INTO VIDEO VALUES (34369, '2013-03-02', 1236); INSERT INTO VIDEO VALUES (44392, '2012-11-21', 1237); INSERT INTO VIDEO VALUES (44397, '2012-11-21', 1237); INSERT INTO VIDEO VALUES (54321, '2012-06-18', 1234); INSERT INTO VIDEO VALUES (54324, '2012-06-18', 1234); INSERT INTO VIDEO VALUES (54325, '2012-06-18', 1234); INSERT INTO VIDEO VALUES (59237, '2013-02-14', 1237); INSERT INTO VIDEO VALUES (61353, '2010-01-28', 1245); INSERT INTO VIDEO VALUES (61354, '2010-01-28', 1245); INSERT INTO VIDEO VALUES (61367, '2012-07-30', 1246); INSERT INTO VIDEO VALUES (61369, '2012-07-30', 1246); INSERT INTO VIDEO VALUES (61388, '2011-01-25', 1239); INSERT INTO MEMBERSHIP VALUES (102, 'TAMI', 'DAWSON', '2632 TAKLI CIRCLE', 'NORENE', 'TN', '37136', 11); INSERT INTO MEMBERSHIP VALUES (103, 'CURT', 'KNIGHT', '4025 CORNELL COURT', 'FLATGAP', 'KY', '41219', 6); INSERT INTO MEMBERSHIP VALUES (104, 'JAMAL', 'MELENDEZ', '788 EAST 145TH AVENUE', 'QUEBECK', 'TN', '38579', 0); INSERT INTO MEMBERSHIP VALUES (105, 'IVA', 'MCCLAIN', '6045 MUSKET BALL CIRCLE', 'SUMMIT', 'KY', '42783', 15); INSERT INTO MEMBERSHIP VALUES (106, 'MIRANDA', 'PARKS', '4469 MAXWELL PLACE', 'GERMANTOWN', 'TN', '38183', 0); INSERT INTO MEMBERSHIP VALUES (107, 'ROSARIO', 'ELLIOTT', '7578 DANNER AVENUE', 'COLUMBIA', 'TN', '38402', 5); INSERT INTO MEMBERSHIP VALUES (108, 'MATTIE', 'GUY', '4390 EVERGREEN STREET', 'LILY', 'KY', '40740', 0); INSERT INTO MEMBERSHIP VALUES (109, 'CLINT', 'OCHOA', '1711 ELM STREET', 'GREENEVILLE', 'TN', '37745', 10); INSERT INTO MEMBERSHIP VALUES (110, 'LEWIS', 'ROSALES', '4524 SOUTHWIND CIRCLE', 'COUNCE', 'TN', '38326', 0); INSERT INTO MEMBERSHIP VALUES (111, 'STACY', 'MANN', '2789 EAST COOK AVENUE', 'MURFREESBORO', 'TN', '37132', 8); INSERT INTO MEMBERSHIP VALUES (112, 'LUIS', 'TRUJILLO', '7267 MELVIN AVENUE', 'HEISKELL', 'TN', '37754', 3); INSERT INTO MEMBERSHIP VALUES (113, 'MINNIE', 'GONZALES', '6430 VASILI DRIVE', 'WILLISTON', 'TN', '38076', 0); INSERT INTO RENTAL VALUES (1001, '2013-03-01', 103); INSERT INTO RENTAL VALUES (1002, '2013-03-01', 105); INSERT INTO RENTAL VALUES (1003, '2013-03-02', 102); INSERT INTO RENTAL VALUES (1004, '2013-03-02', 110); INSERT INTO RENTAL VALUES (1005, '2013-03-02', 111); INSERT INTO RENTAL VALUES (1006, '2013-03-02', 107); INSERT INTO RENTAL VALUES (1007, '2013-03-02', 104); INSERT INTO RENTAL VALUES (1008, '2013-03-03', 105); INSERT INTO RENTAL VALUES (1009, '2013-03-03', 111); INSERT INTO DETAILRENTAL VALUES (1001, 34342, 2, '2013-03-04', '2013-03-02', NULL); INSERT INTO DETAILRENTAL VALUES (1001, 34366, 3.5, '2013-03-04', '2013-03-02', 3); INSERT INTO DETAILRENTAL VALUES (1001, 61353, 2, '2013-03-04', '2013-03-03', 1); INSERT INTO DETAILRENTAL VALUES (1002, 59237, 3.5, '2013-03-04', '2013-03-04', 3); INSERT INTO DETAILRENTAL VALUES (1003, 54325, 3.5, '2013-03-04', '2013-03-09', 3); INSERT INTO DETAILRENTAL VALUES (1003, 61369, 2, '2013-03-06', '2013-03-09', 1); INSERT INTO DETAILRENTAL VALUES (1003, 61388, 0, '2013-03-06', '2013-03-09', 1); INSERT INTO DETAILRENTAL VALUES (1004, 34341, 2, '2013-03-07', '2013-03-07', 1); INSERT INTO DETAILRENTAL VALUES (1004, 34367, 3.5, '2013-03-05', '2013-03-07', 3); INSERT INTO DETAILRENTAL VALUES (1004, 44392, 3.5, '2013-03-05', '2013-03-07', 3); INSERT INTO DETAILRENTAL VALUES (1005, 34342, 2, '2013-03-07', '2013-03-05', 1); INSERT INTO DETAILRENTAL VALUES (1005, 44397, 3.5, '2013-03-05', '2013-03-05', 3); INSERT INTO DETAILRENTAL VALUES (1006, 34366, 3.5, '2013-03-05', '2013-03-04', 3); INSERT INTO DETAILRENTAL VALUES (1006, 61367, 2, '2013-03-07', NULL, 1); INSERT INTO DETAILRENTAL VALUES (1007, 34368, 3.5, '2013-03-05', NULL, 3); INSERT INTO DETAILRENTAL VALUES (1008, 34369, 3.5, '2013-03-05', '2013-03-05', 3); INSERT INTO DETAILRENTAL VALUES (1009, 54324, 3.5, '2013-03-05', NULL, 3);
true
50b47943f9ae7b899ceb7c3ef6880ca94708bf64
SQL
lukaskolehotsky/cecky
/src/main/resources/schema.sql
UTF-8
1,292
3.03125
3
[]
no_license
CREATE TABLE files ( id varchar(100) NULL, img_path varchar(1000) NULL, file_name varchar(100) NULL, file_type varchar(100) NULL, guid varchar(100) NULL, PRIMARY KEY (id) ); CREATE TABLE items ( id varchar(100) NULL, brand varchar(100) NULL, type varchar(100) NULL, guid varchar(100) NULL, created_date_time timestamp default NULL, email varchar(100) NULL, authentication_code varchar(100) NULL, price bigint NULL, description varchar(5000) NULL, fuel_type varchar(100) NULL, speedometer_condition numeric NULL, production_year numeric NULL, mobile_number numeric NULL, PRIMARY KEY (id) ); --ALTER TABLE public.items add COLUMN mobile_number numeric null; --ALTER TABLE public.items DROP COLUMN price; --ALTER TABLE public.items DROP COLUMN speedometer_condition; --ALTER TABLE public.items DROP COLUMN mobile_number; --ALTER TABLE public.items ADD COLUMN price VARCHAR(100) null; --ALTER TABLE public.items ADD COLUMN speedometer_condition VARCHAR(100) null; --ALTER TABLE public.items ADD COLUMN mobile_number VARCHAR(100) null; --UPDATE public.items set price = '1500' where price is null; --UPDATE public.items set speedometer_condition = '150495' where speedometer_condition is null; --UPDATE public.items set mobile_number = '0907397135' where mobile_number is null;
true
d9f063789878f43145140ea35c2fb3a636e0e70f
SQL
vijaydairyf/TimelyFish
/SolomonApp/dbo/Views/dbo.cfvPigGroupRoom.sql
UTF-8
293
2.59375
3
[]
no_license
/****** Object: View dbo.cfvPigGroupRoom Script Date: 12/8/2004 8:30:00 PM ******/ CREATE View cfvPigGroupRoom AS Select pg.SiteContactID, pg.BarnNbr, pg.PigGroupID, pg.PGStatusID, rm.RoomNbr From cftPigGroup pg JOIN cftPigGroupRoom rm ON pg.PigGroupID=rm.PigGroupID
true
ad4271356126feeb25e172ca3f553db2a187504b
SQL
provingground-moe/cat
/sql/setup_storedFunctions.sql
UTF-8
4,452
3.984375
4
[]
no_license
-- LSST Data Management System -- Copyright 2008, 2009, 2010 LSST Corporation. -- -- This product includes software developed by the -- LSST Project (http://www.lsst.org/). -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the LSST License Statement and -- the GNU General Public License along with this program. If not, -- see <http://www.lsstcorp.org/LegalNotices/>. -- One-time setup actions for LSST database stored functions -- and procedures - assumes the LSST Database Schema already exists. DELIMITER // -- ========================== ADMIN ============================= -- -- returns 1 if given user has privileges to create new run -- otherwise it returns a negative number CREATE FUNCTION checkIfUserCanStartRun ( userName_ VARCHAR(30) ) RETURNS INT SQL SECURITY DEFINER BEGIN DECLARE tmpI_ SMALLINT; DECLARE tmpC_ CHAR; SELECT Table_priv INTO tmpI_ FROM mysql.tables_priv WHERE user = userName_ AND Table_name = 'RunInfo'; IF tmpI_ IS NOT NULL THEN RETURN 1; -- ok END IF; SELECT Insert_priv INTO tmpC_ FROM mysql.user WHERE user = userName_; IF tmpC_ IS NULL THEN RETURN -1; END IF; IF tmpC_ = "Y" THEN RETURN 1; -- ok END IF; RETURN -2; END // -- =========================== Time =========================== -- -- -- Function to convert UTC nanoseconds to TAI nanoseconds. -- CREATE FUNCTION utcToTai ( nsecs_ BIGINT ) RETURNS BIGINT SQL SECURITY INVOKER BEGIN DECLARE nsecsPerDay_ DOUBLE; DECLARE epochInMjd_ DOUBLE; DECLARE offset_ FLOAT; DECLARE mjdRef_ FLOAT; DECLARE drift_ FLOAT; DECLARE mjd_ DOUBLE; DECLARE leapSecs_ DOUBLE; SET nsecsPerDay_ = 86.4e12; SET epochInMjd_ = 40587.0; SELECT offset, mjdRef, drift INTO offset_, mjdRef_, drift_ FROM LeapSeconds WHERE whenUtc = ( SELECT MAX(whenUtc) FROM LeapSeconds WHERE whenUtc <= nsecs_ ); SET mjd_ = nsecs_ / nsecsPerDay_ + epochInMjd_; SET leapSecs_ = offset_ + (mjd_ - mjdRef_) * drift_; RETURN nsecs_ + CAST(leapSecs_ * 1.0e9 + 0.5 AS SIGNED INTEGER); END // -- -- Function to convert TAI nanoseconds to UTC nanoseconds. -- CREATE FUNCTION taiToUtc ( nsecs_ BIGINT ) RETURNS BIGINT SQL SECURITY INVOKER BEGIN DECLARE nsecsPerDay_ DOUBLE; DECLARE epochInMjd_ DOUBLE; DECLARE offset_ FLOAT; DECLARE mjdRef_ FLOAT; DECLARE drift_ FLOAT; DECLARE taiSecs_ DOUBLE; DECLARE leapSecs_ DOUBLE; SET nsecsPerDay_ = 86.4e12; SET epochInMjd_ = 40587.0; SELECT offset, mjdRef, drift INTO offset_, mjdRef_, drift_ FROM LeapSeconds WHERE whenTai = ( SELECT MAX(whenTai) FROM LeapSeconds WHERE whenTai <= nsecs_ ); SET taiSecs_ = nsecs_ / 1.0e9; SET leapSecs_ = taiSecs_ - (taiSecs_ - offset_ - drift_ * (epochInMjd_ - mjdRef_)) / (1.0 + drift_ * 1.0e9 / nsecsPerDay_); RETURN nsecs_ - CAST(leapSecs_ * 1.0e9 + 0.5 AS SIGNED); END // -- -- Function to convert TAI nanoseconds to Modified Julian Days (UTC). -- CREATE FUNCTION taiToMjdUtc ( nsecs_ BIGINT ) RETURNS DOUBLE SQL SECURITY INVOKER BEGIN RETURN taiToUTC(nsecs_) / 86.4e12 + 40587.0; END // -- -- Function to convert TAI nanoseconds to Modified Julian Days (TAI). -- CREATE FUNCTION taiToMjdTai ( nsecs_ BIGINT ) RETURNS DOUBLE SQL SECURITY INVOKER BEGIN RETURN nsecs_ / 86.4e12 + 40587.0; END // -- -- Function to convert Modified Julian Days (TAI) to TAI nanoseconds. -- CREATE FUNCTION mjdTaiToTai ( mjdTai_ FLOAT ) RETURNS BIGINT SQL SECURITY INVOKER BEGIN RETURN (mjdTai_ - 40587.0) * 86.4e12; END // -- -- Function to convert Modified Julian Days (UTC) to TAI nanoseconds. -- CREATE FUNCTION mjdUtcToTai ( mjdUtc_ FLOAT ) RETURNS BIGINT SQL SECURITY INVOKER BEGIN RETURN utcToTai((mjdUtc_ - 40587.0) * 86.4e12); END // DELIMITER ;
true
456dcccb3b7943908bc08612d7d755e9515a4d27
SQL
madeinsiha/qichong
/qc_server/pet.sql
UTF-8
532
2.75
3
[]
no_license
SET NAMES UTF8; DROP DATABASE IF EXISTS pet; CREATE DATABASE pet CHARSET=UTF8; USE pet; /**用户信息**/ CREATE TABLE user( uid INT PRIMARY KEY AUTO_INCREMENT, uname VARCHAR(32), upwd VARCHAR(32), email VARCHAR(64), phone VARCHAR(16) NOT NULL UNIQUE, #手机号码 avatar VARCHAR(128), #头像图片路径 user_name VARCHAR(32), #用户名,如王小明 gender INT #性别 0-女 1-男 ) INSERT INTO user VALUES(NULL,"久爱成瘾","demo1234","452788531@qq.com",18123456789,NULL,"陈曦",1);
true
e77641b56a1425af1f7667e7f9e2231fe645bb09
SQL
borisdagnon/NGM_CHOIR_PHP
/TRIGGERS.sql
UTF-8
284
2.703125
3
[]
no_license
CREATE TRIGGER après_insertion_audios AFTER INSERT ON audios FOR EACH ROW BEGIN ALTER TABLE audios AUTO_INCREMENT = 1; END; CREATE TABLE commentaire( id SMALLINT (6) PRIMARY key AUTO_INCREMENT , nom_commentateur varchar(40), prenom_commentateur varchar(40), commentaire TEXT )
true
a35229a8a9d1db68a9789b4f26490d54130a845d
SQL
mkoldaev/binklines
/dump_sql/klines_tables.sql
UTF-8
3,724
2.796875
3
[]
no_license
CREATE TABLE `kline_1d` ( `id` int(11) NOT NULL AUTO_INCREMENT, `para` varchar(45) COLLATE utf8_bin DEFAULT NULL, `time_open` varchar(45) COLLATE utf8_bin DEFAULT NULL, `time_close` varchar(45) COLLATE utf8_bin DEFAULT NULL, `price_open` varchar(45) COLLATE utf8_bin DEFAULT NULL, `max_price` varchar(45) COLLATE utf8_bin DEFAULT NULL, `low_price` varchar(45) COLLATE utf8_bin DEFAULT NULL, `price_close` varchar(45) COLLATE utf8_bin DEFAULT NULL, `volume` varchar(90) COLLATE utf8_bin DEFAULT NULL, `count_trades` varchar(90) COLLATE utf8_bin DEFAULT NULL, `open_milliseconds` bigint(15) NOT NULL, `close_milliseconds` bigint(15) NOT NULL, `price_avg` varchar(45) COLLATE utf8_bin DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; CREATE TABLE `kline_1h` ( `id` int(11) NOT NULL AUTO_INCREMENT, `para` varchar(45) COLLATE utf8_bin DEFAULT NULL, `time_open` varchar(45) COLLATE utf8_bin DEFAULT NULL, `time_close` varchar(45) COLLATE utf8_bin DEFAULT NULL, `price_open` varchar(45) COLLATE utf8_bin DEFAULT NULL, `max_price` varchar(45) COLLATE utf8_bin DEFAULT NULL, `low_price` varchar(45) COLLATE utf8_bin DEFAULT NULL, `price_close` varchar(45) COLLATE utf8_bin DEFAULT NULL, `volume` varchar(90) COLLATE utf8_bin DEFAULT NULL, `count_trades` varchar(90) COLLATE utf8_bin DEFAULT NULL, `open_milliseconds` bigint(15) NOT NULL, `close_milliseconds` bigint(15) NOT NULL, `price_avg` varchar(45) COLLATE utf8_bin DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; CREATE TABLE `kline_1m` ( `id` int(11) NOT NULL AUTO_INCREMENT, `para` varchar(45) COLLATE utf8_bin DEFAULT NULL, `time_open` varchar(45) COLLATE utf8_bin DEFAULT NULL, `time_close` varchar(45) COLLATE utf8_bin DEFAULT NULL, `price_open` varchar(45) COLLATE utf8_bin DEFAULT NULL, `max_price` varchar(45) COLLATE utf8_bin DEFAULT NULL, `low_price` varchar(45) COLLATE utf8_bin DEFAULT NULL, `price_close` varchar(45) COLLATE utf8_bin DEFAULT NULL, `volume` varchar(90) COLLATE utf8_bin DEFAULT NULL, `count_trades` varchar(90) COLLATE utf8_bin DEFAULT NULL, `open_milliseconds` bigint(15) DEFAULT NULL, `close_milliseconds` bigint(15) NOT NULL, `price_avg` varchar(45) COLLATE utf8_bin DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; CREATE TABLE `kline_1w` ( `id` int(11) NOT NULL AUTO_INCREMENT, `para` varchar(45) COLLATE utf8_bin DEFAULT NULL, `time_open` varchar(45) COLLATE utf8_bin DEFAULT NULL, `time_close` varchar(45) COLLATE utf8_bin DEFAULT NULL, `price_open` varchar(45) COLLATE utf8_bin DEFAULT NULL, `max_price` varchar(45) COLLATE utf8_bin DEFAULT NULL, `low_price` varchar(45) COLLATE utf8_bin DEFAULT NULL, `price_close` varchar(45) COLLATE utf8_bin DEFAULT NULL, `volume` varchar(90) COLLATE utf8_bin DEFAULT NULL, `count_trades` varchar(90) COLLATE utf8_bin DEFAULT NULL, `open_milliseconds` bigint(15) DEFAULT NULL, `close_milliseconds` bigint(15) NOT NULL, `price_avg` varchar(45) COLLATE utf8_bin DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; CREATE TABLE `paras` ( `id` int(11) NOT NULL AUTO_INCREMENT, `para` varchar(55) DEFAULT NULL, `status` varchar(55) DEFAULT NULL, `quoteAsset` varchar(20) DEFAULT NULL, `baseAsset` varchar(20) DEFAULT NULL, `ticksize` varchar(20) DEFAULT NULL, `stepsize` varchar(20) DEFAULT NULL, `minprice` varchar(20) DEFAULT NULL, `maxprice` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4;
true
9deee380799da305652f7625a3350a5269ce8e39
SQL
bartek3pl/CS-Studies
/SQL/lista 2/10.sql
UTF-8
340
3.609375
4
[]
no_license
with POM as ( select wybor.kod_grupy, count(distinct wybor.kod_uz) as "liczba" from wybor join grupa using (kod_grupy) join przedmiot_semestr using (kod_przed_sem) join semestr using (semestr_id) where semestr.nazwa='Semestr letni 2016/2017' and grupa.rodzaj_zajec='w' group by wybor.kod_grupy ) select avg(liczba) from POM
true
c5c9b44a8506c82d49a43497b0ac5c5613b3463f
SQL
andri000me/aplikasi_aman
/aman_ori.sql
UTF-8
6,799
3.265625
3
[ "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.7.4 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jun 12, 2019 at 01:05 PM -- Server version: 10.1.28-MariaDB -- PHP Version: 7.1.10 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `aman_ori` -- -- -------------------------------------------------------- -- -- Table structure for table `tb_barang_keluar` -- CREATE TABLE `tb_barang_keluar` ( `id` int(10) NOT NULL, `id_transaksi` varchar(50) NOT NULL, `tanggal_masuk` varchar(20) NOT NULL, `tanggal_keluar` varchar(20) NOT NULL, `lokasi` varchar(100) NOT NULL, `kode_barang` varchar(100) NOT NULL, `nama_barang` varchar(100) NOT NULL, `satuan` varchar(50) NOT NULL, `jumlah` varchar(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tb_barang_keluar` -- INSERT INTO `tb_barang_keluar` (`id`, `id_transaksi`, `tanggal_masuk`, `tanggal_keluar`, `lokasi`, `kode_barang`, `nama_barang`, `satuan`, `jumlah`) VALUES (17, 'WG-201946109278', '31/05/2019', '31/05/2019', 'Lampung', '3', 'Map Kuning', 'Pack', '2'), (18, 'WG-201902467153', '10/06/2019', '11/06/2019', 'Lampung', '7', 'Aqua', 'Dus', '3'), (19, 'WG-201981607352', '10/06/2019', '11/06/2019', 'Lampung', '5', 'Tinta', 'Pcs', '5'), (20, 'WG-201920149573', '10/06/2019', '11/06/2019', 'Lampung', '6', 'Isi Strapless', 'Pack', '5'); -- -- Triggers `tb_barang_keluar` -- DELIMITER $$ CREATE TRIGGER `TG_BARANG_KELUAR` AFTER INSERT ON `tb_barang_keluar` FOR EACH ROW BEGIN UPDATE tb_barang_masuk SET jumlah=jumlah-NEW.jumlah WHERE kode_barang=NEW.kode_barang; DELETE FROM tb_barang_masuk WHERE jumlah = 0; END $$ DELIMITER ; -- -------------------------------------------------------- -- -- Table structure for table `tb_barang_masuk` -- CREATE TABLE `tb_barang_masuk` ( `id_transaksi` varchar(50) NOT NULL, `tanggal` varchar(20) NOT NULL, `lokasi` varchar(100) NOT NULL, `kode_barang` varchar(100) NOT NULL, `nama_barang` varchar(100) NOT NULL, `satuan` varchar(50) NOT NULL, `jumlah` varchar(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tb_barang_masuk` -- INSERT INTO `tb_barang_masuk` (`id_transaksi`, `tanggal`, `lokasi`, `kode_barang`, `nama_barang`, `satuan`, `jumlah`) VALUES ('WG-201902467153', '10/06/2019', 'Lampung', '7', 'Aqua', 'Dus', '2'), ('WG-201920149573', '10/06/2019', 'Lampung', '6', 'Isi Strapless', 'Pack', '15'), ('WG-201920468537', '10/06/2019', 'Lampung', '4', 'Odner', 'Dus', '10'), ('WG-201946109278', '31/05/2019', 'Lampung', '3', 'Map Kuning', 'Pack', '8'), ('WG-201950168374', '31/05/2019', 'Lampung', '1', 'Kertas A4', 'Dus', '5'), ('WG-201962509184', '31/05/2019', 'Lampung', '2', 'Pulpen Standar', 'Pack', '12'), ('WG-201967301985', '10/06/2019', 'Lampung', '8', 'Folio', 'Pack', '15'), ('WG-201981607352', '10/06/2019', 'Lampung', '5', 'Tinta', 'Pcs', '20'); -- -------------------------------------------------------- -- -- Table structure for table `tb_satuan` -- CREATE TABLE `tb_satuan` ( `id_satuan` int(11) NOT NULL, `kode_satuan` varchar(100) NOT NULL, `nama_satuan` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tb_satuan` -- INSERT INTO `tb_satuan` (`id_satuan`, `kode_satuan`, `nama_satuan`) VALUES (1, 'Dus', 'Dus'), (2, 'Pcs', 'Pcs'), (5, 'Pack', 'Pack'); -- -------------------------------------------------------- -- -- Table structure for table `tb_upload_gambar_user` -- CREATE TABLE `tb_upload_gambar_user` ( `id` int(11) NOT NULL, `username_user` varchar(100) NOT NULL, `nama_file` varchar(220) NOT NULL, `ukuran_file` varchar(8) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tb_upload_gambar_user` -- INSERT INTO `tb_upload_gambar_user` (`id`, `username_user`, `nama_file`, `ukuran_file`) VALUES (1, 'zahidin', 'nopic5.png', '6.33'), (2, 'test', 'nopic4.png', '6.33'), (3, 'coba', 'logo_unsada1.jpg', '16.69'), (4, 'admin', '20170314233119_imam_14116131_student_itera_ac_id.jpg', '149.96'), (5, 'imamprabowo', 'nopic2.png', '6.33'); -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE `user` ( `id` int(12) NOT NULL, `username` varchar(200) NOT NULL, `email` varchar(100) NOT NULL, `password` varchar(200) NOT NULL, `role` tinyint(4) NOT NULL DEFAULT '0', `last_login` varchar(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `user` -- INSERT INTO `user` (`id`, `username`, `email`, `password`, `role`, `last_login`) VALUES (20, 'admin', 'admin@gmail.com', '$2y$10$3HNkMOtwX8X88Xb3DIveYuhXScTnJ9m16/rPDF1/VTa/VTisxVZ4i', 1, '11-06-2019 9:36'), (28, 'Bapak Adi', 'adi@ombudsman.go.id', '$2y$10$Ml2kMbL0ye/wL06yNPhvAO.Q0GRl51//0FWEdBaoj2/ehj8snIuVm', 0, '11-06-2019 8:59'), (29, 'Bapak Eko', 'eko@ombudsman.go.id', '$2y$10$FyPBGL2/X93mlY7iVxKGBexI/Pj1.sBWusfQOXoiH23B5H9Cqwk2y', 1, ''), (30, 'Bapak Hidayat', 'hidayat@ombudsman.go.id', '$2y$10$Cr8xp0TBZ6VVu7ggWKMYnOx7RVsv0B0bK1RBSRb8keM/ParACARqC', 0, '11-06-2019 6:20'), (31, 'Adi', 'adi@ombudsman.go.id', '$2y$10$cbj8RavB7iFtqzC6id1BJuaY0cRunf9kEDc.RKAib5ARruNI/aCmC', 0, '11-06-2019 9:35'); -- -- Indexes for dumped tables -- -- -- Indexes for table `tb_barang_keluar` -- ALTER TABLE `tb_barang_keluar` ADD PRIMARY KEY (`id`); -- -- Indexes for table `tb_barang_masuk` -- ALTER TABLE `tb_barang_masuk` ADD PRIMARY KEY (`id_transaksi`); -- -- Indexes for table `tb_satuan` -- ALTER TABLE `tb_satuan` ADD PRIMARY KEY (`id_satuan`); -- -- Indexes for table `tb_upload_gambar_user` -- ALTER TABLE `tb_upload_gambar_user` ADD PRIMARY KEY (`id`); -- -- Indexes for table `user` -- ALTER TABLE `user` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `tb_barang_keluar` -- ALTER TABLE `tb_barang_keluar` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21; -- -- AUTO_INCREMENT for table `tb_satuan` -- ALTER TABLE `tb_satuan` MODIFY `id_satuan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `tb_upload_gambar_user` -- ALTER TABLE `tb_upload_gambar_user` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `user` -- ALTER TABLE `user` MODIFY `id` int(12) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
de990664c19df8d46e36e364e308054291269c72
SQL
ReneNyffenegger/about-MSSQL
/administration/schemas/sys/objects/views/sql_modules/object-definitions.sql
UTF-8
334
3.171875
3
[]
no_license
select mod.definition definition, obj.modify_date obj_mod_dt from sys.objects obj join sys.sql_modules mod on obj.object_id = mod.object_id join sys.schemas sch on obj.schema_id = sch.schema_id where lower(obj.name) = 'tq84_ect' and lower(sch.name) = 'dbo' ;
true
0c29b2147212e64c87414ba707729a2a3f310e0f
SQL
stevexenios/RDM
/sql/question_2.sql
UTF-8
690
4.625
5
[]
no_license
-- For all students in their fourth year, check if they have taken courses worth of 20 credits in the department associated with their major WITH dept_course AS ( -- Get course + department table SELECT c.*, d.Major_declaration_ID FROM Courses c LEFT JOIN Departments d ON c.Department_ID = d.Department_ID -- Also all courses are associated with dept. ) SELECT s.Student_ID, SUM(d.credits) AS total_credits, CASE WHEN SUM(d.credits) >= 20 THEN Yes, ELSE `NO` END AS have_take_worth_20_creds FROM Students s LEFT JOIN dept_course d ON d.Major_declaration_ID = s.Major_Declaration WHERE s.level = 'Senior' GROUP BY 1;
true
5440ba0dd57dd1c8e1918f4ad67e231439b19b5e
SQL
gonzalob24/Learning_Central
/MySQL/SQL/sql-basics/11 Nested Queries.sql
UTF-8
739
3.890625
4
[]
no_license
-- using mutliple SELECT statments to get specific data -- Find names of all employess who have sold over 30,000 -- to a single client -- now we have all of the ids who sold > 30k SELECT works_with.emp_id FROM works_with WHERE works_with.total_sales > 30000; SELECT employee.first_name, employee.last_name FROM employee WHERE employee.emp_id IN ( SELECT works_with.emp_id FROM works_with WHERE works_with.total_sales > 30000 ); -- Find all clients who are handled by the branch -- that Michael Scott manages -- assum you know Michaels manager id, emp.id SELECT client.client_name FROM client WHERE client.branch_id = ( SELECT branch.branch_id FROM branch WHERE branch.mgr_id = 102 LIMIT 1 -- make sure I only have one );
true
c95f9edf9f70304d9880fd7c7a149aa00cbea364
SQL
alfonsuslibra/SQL-data-analysis
/Practice 4/Practice 4.sql
UTF-8
2,714
4.1875
4
[]
no_license
# Number 1 with t0 as ( select t.*, Saham_invested_amount + Pasar_Uang_invested_amount + Pendapatan_Tetap_invested_amount + Campuran_invested_amount as Total_invested_amount from transactions t ), t1 as ( select t0.*, u.user_age , case when u.user_age between 17 and 22 then "Group 17 - 22" when u.user_age between 23 and 30 then "Group 23 - 30" when u.user_age > 30 then "Group Others" end group_age from t0 inner join user_profile u on t0.user_id = u.user_id ), t2 as ( select t1.*, lag(t1.Total_invested_amount) over (partition by user_id) as prev_invested_amount, case when t1.Total_invested_amount > lag(t1.Total_invested_amount) over (partition by user_id) then "Buying" when t1.Total_invested_amount < lag(t1.Total_invested_amount) over (partition by user_id) then "Selling" when t1.Total_invested_amount = lag(t1.Total_invested_amount) over (partition by user_id) then "Maintain" end journey from t1 ) (select t2.user_id, t2.user_age, t2.group_age, count(t2.journey) as no_of_buying from t2 where t2.journey = "Buying" and t2.group_age = "Group 17 - 22" group by 1,2,3 order by no_of_buying desc limit 3) union (select t2.user_id, t2.user_age, t2.group_age, count(t2.journey) as no_of_buying from t2 where t2.journey = "Buying" and t2.group_age = "Group 23 - 30" group by 1,2,3 order by no_of_buying desc limit 3); -------------------------------------------------------------------------------------------- # Number 2 with t0 as ( select t.*, case when Saham_invested_amount - (1000000 * (Pasar_Uang_invested_amount + Pendapatan_Tetap_invested_amount + Campuran_invested_amount)) > 0 then "RD Saham Only" when Saham_invested_amount - (1000000 * (Pasar_Uang_invested_amount + Pendapatan_Tetap_invested_amount + Campuran_invested_amount)) <= 0 then "RD Others" end composition from transactions t ), t1 as ( select t0.*, u.user_gender, u.user_income_source from t0 inner join user_profile u on t0.user_id = u.user_id where t0.composition = "RD Saham Only" ), t2 as ( select t1.*, lag(t1.Saham_invested_amount) over (partition by user_id) as prev_invested_amount, case when t1.Saham_invested_amount > lag(t1.Saham_invested_amount) over (partition by user_id) then "Buying" when t1.Saham_invested_amount < lag(t1.Saham_invested_amount) over (partition by user_id) then "Selling" when t1.Saham_invested_amount = lag(t1.Saham_invested_amount) over (partition by user_id) then "Maintain" end journey from t1 ) select t2.user_id, t2.user_gender, t2.user_income_source, count(t2.journey) as no_of_selling from t2 where t2.journey = "Selling" and t2.user_gender = "Female" and t2.user_income_source <> "Keuntungan Bisnis" group by 1,2,3 order by no_of_selling desc limit 3;
true
52884a48a26663ffd03154f7a2dff6bc11d09aba
SQL
Learning2021/MIMICIII_Research
/Data Generation/genDataScripts/validICUStays.sql
UTF-8
1,172
3.96875
4
[]
no_license
with t1 as ( select ie.subject_id, ie.hadm_id, ie.icustay_id, CASE WHEN gender = 'F' THEN '0' WHEN gender = 'M' THEN '1' ELSE '-1' END AS gender_num, CASE WHEN first_careunit = 'CCU' THEN '1' WHEN first_careunit = 'CSRU' THEN '2' WHEN first_careunit = 'MICU' THEN '3' WHEN first_careunit = 'SICU' THEN '4' ELSE '-1' END AS icutype , ie.intime, ie.outtime , ROW_NUMBER() over (PARTITION BY ie.subject_id ORDER BY ie.intime) as rn , pt.dob from mimiciii.icustays ie -- filter down to only adult patients inner join mimiciii.patients pt on ie.subject_id = pt.subject_id and pt.dob < (ie.intime - interval '16' year) ) , t2 as ( select *, extract('year' from age(intime,dob)) as age from t1 -- filter to only the FIRST ICU stay where rn = 1 -- also filter to only stays >= 48 hours and (outtime-intime) >= interval '48' hour ) , t3 as ( select t2.*, heightweight.height_first, heightweight.weight_first from t2 left join mimiciii.heightweight on t2.icustay_id = heightweight.icustay_id ) select t3.*, vfd.mechvent from t3 left join ventfirstday vfd on t3.icustay_id = vfd.icustay_id order by t3.icustay_id;
true
81c5ac6b6b33c11e058523de70a3dd37ebc97c69
SQL
charlescifuentes/cwtiquetes
/database/database-1.0.0.sql
UTF-8
16,611
2.9375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.5.1 -- http://www.phpmyadmin.net -- -- Servidor: 127.0.0.1 -- Tiempo de generación: 16-04-2018 a las 17:04:38 -- Versión del servidor: 10.1.13-MariaDB -- Versión de PHP: 5.6.21 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Base de datos: `lidertrans` -- -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `lt_bodega` -- CREATE TABLE `lt_bodega` ( `fecha_venta_bod` datetime NOT NULL, `doc_cliente` int(11) NOT NULL, `id_bodega` int(11) NOT NULL, `id_servicio` int(11) NOT NULL, `valor_servicio` int(11) NOT NULL, `observaciones` varchar(200) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Volcado de datos para la tabla `lt_bodega` -- INSERT INTO `lt_bodega` (`fecha_venta_bod`, `doc_cliente`, `id_bodega`, `id_servicio`, `valor_servicio`, `observaciones`) VALUES ('2017-04-01 00:00:00', 1, 1, 1, 1000, 'asdsad'), ('2017-04-01 00:00:00', 1116245037, 2, 1, 1000, ''), ('2017-04-01 00:00:00', 1, 3, 1, 1000, ''), ('2017-04-01 00:00:00', 80793699, 4, 1, 1000, 'asdasnd asdns djklasd'), ('2017-04-04 00:00:00', 80793699, 5, 1, 1000, 'HJVHJHJVVHJ'), ('2017-05-10 17:45:52', 80793699, 6, 1, 1000, 'Una maleta verde'), ('2017-05-24 11:33:26', 1116245037, 7, 1, 1000, 'Una maleta grande y 2 bolsas\r\n'), ('2017-05-24 11:33:41', 80793699, 8, 1, 1000, '1 maletin negro'), ('2017-05-24 11:33:53', 14345543, 9, 1, 1000, 'un costal de papa'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `lt_clientes` -- CREATE TABLE `lt_clientes` ( `id_cliente` int(11) NOT NULL, `doc_cliente` int(11) DEFAULT NULL, `nom_cliente` varchar(50) NOT NULL, `apell_cliente` varchar(50) NOT NULL, `tel_cliente` varchar(20) NOT NULL, `email_cliente` varchar(50) NOT NULL, `ciudad_cliente` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Volcado de datos para la tabla `lt_clientes` -- INSERT INTO `lt_clientes` (`id_cliente`, `doc_cliente`, `nom_cliente`, `apell_cliente`, `tel_cliente`, `email_cliente`, `ciudad_cliente`) VALUES (1, 80793699, 'CHARLES', 'CIFUENTES', '3174015113', 'charlescifuentes@gmail.com', 'TULUÁ'), (3, 1, 'CLIENTE', 'GENERAL', '12345', 'N/A', 'N/A'), (6, 1116245037, 'VALERIA', 'CIFUENTES', '3145554332', 'valeriacifuentes@gmail.com', 'CALI'), (7, 14345543, 'CARLOS', 'PEREZ', '3103387665', 'carlosperez@hotmail.com', 'BOGOTÁ'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `lt_configuracion` -- CREATE TABLE `lt_configuracion` ( `id_configuracion` int(11) NOT NULL, `nombre_empresa` varchar(100) NOT NULL, `nit_empresa` varchar(100) NOT NULL, `direccion_empresa` varchar(100) NOT NULL, `telefono_empresa` varchar(100) NOT NULL, `cia_aseguradora` varchar(100) NOT NULL, `poliza_numero` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Volcado de datos para la tabla `lt_configuracion` -- INSERT INTO `lt_configuracion` (`id_configuracion`, `nombre_empresa`, `nit_empresa`, `direccion_empresa`, `telefono_empresa`, `cia_aseguradora`, `poliza_numero`) VALUES (1, 'LIDERTRANS LTDA', '821.003.072-2', 'CARRERA 20 # 25-75', '2258129 - 2243950', 'QBE SEGUROS', '706533142'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `lt_cuota_administracion` -- CREATE TABLE `lt_cuota_administracion` ( `id_cadmin` int(11) NOT NULL, `fecha_venta` datetime NOT NULL, `numero_vehiculo` varchar(10) NOT NULL, `id_ruta` int(11) NOT NULL, `pasajeros` int(11) NOT NULL, `valor_admin` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Volcado de datos para la tabla `lt_cuota_administracion` -- INSERT INTO `lt_cuota_administracion` (`id_cadmin`, `fecha_venta`, `numero_vehiculo`, `id_ruta`, `pasajeros`, `valor_admin`) VALUES (1, '2017-04-01 00:00:00', '51', 1, 4, 3000), (2, '2017-04-03 00:00:00', '85', 1, 3, 4500), (3, '2017-04-03 00:00:00', '04', 1, 4, 6500), (4, '2017-04-03 00:00:00', '51', 4, 4, 2500), (5, '2017-04-03 00:00:00', '51', 1, 4, 4500), (6, '2017-04-04 00:00:00', '51', 1, 8, 3000), (7, '2017-04-04 00:00:00', '85', 2, 1, 3000), (8, '2017-04-04 00:00:00', '51', 1, 3, 4500), (9, '2017-05-10 00:00:00', '85', 1, 1, 3000), (10, '2017-05-10 00:00:00', '51', 4, 2, 3000), (11, '2017-05-10 15:40:53', '51', 2, 2, 3000), (12, '2017-05-10 15:42:08', '85', 4, 3, 4500), (13, '2017-05-10 17:25:34', '51', 1, 4, 3000), (14, '2017-05-24 11:10:03', '85', 1, 1, 3000), (15, '2017-05-24 11:10:54', '51', 4, 4, 6500); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `lt_rutas` -- CREATE TABLE `lt_rutas` ( `id_ruta` int(11) NOT NULL, `nom_ruta` varchar(50) NOT NULL, `valor_ruta` int(11) NOT NULL, `activo_ruta` tinyint(1) NOT NULL DEFAULT '1' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Volcado de datos para la tabla `lt_rutas` -- INSERT INTO `lt_rutas` (`id_ruta`, `nom_ruta`, `valor_ruta`, `activo_ruta`) VALUES (1, 'TULUÁ - LA MARINA', 2500, 1), (2, 'LA MARINA - TULUÁ', 2500, 1), (4, 'CEILAN - TULUÁ', 3500, 1); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `lt_servicios` -- CREATE TABLE `lt_servicios` ( `id_servicio` int(11) NOT NULL, `nom_servicio` varchar(50) NOT NULL, `valor_servicio` int(11) NOT NULL, `activo_servicio` tinyint(1) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Volcado de datos para la tabla `lt_servicios` -- INSERT INTO `lt_servicios` (`id_servicio`, `nom_servicio`, `valor_servicio`, `activo_servicio`) VALUES (1, 'SERVICIO BODEGA', 1000, 1); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `lt_tiquetes` -- CREATE TABLE `lt_tiquetes` ( `fecha_venta_tiq` datetime NOT NULL, `numero_vehiculo` varchar(10) NOT NULL, `id_tiquete` int(11) NOT NULL, `doc_cliente` int(11) NOT NULL, `id_ruta` int(11) NOT NULL, `pasajeros` int(11) NOT NULL, `valor_ruta` int(11) NOT NULL, `observaciones` varchar(200) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Volcado de datos para la tabla `lt_tiquetes` -- INSERT INTO `lt_tiquetes` (`fecha_venta_tiq`, `numero_vehiculo`, `id_tiquete`, `doc_cliente`, `id_ruta`, `pasajeros`, `valor_ruta`, `observaciones`) VALUES ('2017-04-01 00:00:00', '51', 1, 1, 1, 3, 2500, NULL), ('2017-04-01 00:00:00', '51', 2, 1, 1, 1, 2500, NULL), ('2017-04-01 00:00:00', '85', 3, 1, 2, 1, 2500, NULL), ('2017-04-01 00:00:00', '85', 4, 1, 1, 1, 2500, NULL), ('2017-04-03 00:00:00', '85', 5, 80793699, 2, 1, 2500, NULL), ('2017-04-03 00:00:00', '04', 6, 1, 2, 2, 2500, NULL), ('2017-04-03 00:00:00', '04', 7, 1, 2, 2, 2500, NULL), ('2017-04-03 00:00:00', '51', 8, 1, 4, 1, 3500, NULL), ('2017-04-03 00:00:00', '51', 10, 1, 1, 2, 2500, NULL), ('2017-04-03 00:00:00', '51', 11, 1, 1, 1, 2500, NULL), ('2017-04-03 00:00:00', '51', 12, 1, 1, 1, 2500, NULL), ('2017-04-04 00:00:00', '51', 15, 1, 1, 3, 2500, NULL), ('2017-04-04 00:00:00', '51', 16, 1, 1, 1, 2500, NULL), ('2017-04-04 00:00:00', '85', 17, 1, 2, 1, 2500, NULL), ('2017-04-04 00:00:00', '51', 18, 1, 1, 3, 2500, NULL), ('2017-04-04 00:00:00', '51', 22, 1, 1, 1, 2500, NULL), ('2017-04-05 00:00:00', '04', 23, 1, 1, 1, 2500, NULL), ('2017-04-05 00:00:00', '04', 24, 1, 2, 1, 2500, NULL), ('2017-04-05 00:00:00', '04', 25, 1, 1, 1, 2500, NULL), ('2017-04-17 00:00:00', '04', 26, 1, 1, 1, 2500, NULL), ('2017-04-17 00:00:00', '51', 27, 1, 2, 1, 2500, NULL), ('0000-00-00 00:00:00', '51', 28, 1, 2, 1, 0, NULL), ('0000-00-00 00:00:00', '51', 29, 1, 2, 1, 2500, NULL), ('0000-00-00 00:00:00', '51', 30, 1, 1, 1, 2500, NULL), ('2017-05-09 23:59:44', '51', 31, 1, 2, 1, 2500, NULL), ('2017-05-10 12:19:29', '51', 32, 1, 1, 1, 2500, NULL), ('2017-05-10 17:24:06', '51', 33, 1116245037, 1, 2, 2500, NULL), ('2017-05-10 17:24:44', '51', 34, 80793699, 1, 1, 2500, NULL), ('2017-05-10 17:25:01', '51', 35, 14345543, 1, 1, 2500, NULL), ('2017-05-24 11:09:48', '85', 36, 1, 1, 1, 2500, NULL), ('2017-05-24 11:10:24', '51', 37, 1, 4, 2, 3500, NULL), ('2017-05-24 11:10:38', '51', 38, 1, 4, 1, 3500, NULL), ('2017-05-24 11:10:45', '51', 39, 1, 4, 1, 3500, NULL), ('2017-05-27 18:26:23', '51', 40, 1, 2, 1, 2500, NULL), ('2017-05-27 18:27:26', '51', 41, 1, 1, 1, 2500, NULL), ('2017-05-27 18:42:04', '51', 42, 1, 2, 1, 2500, NULL), ('2017-05-31 10:39:00', '51', 43, 1, 1, 1, 2500, NULL), ('2017-05-31 11:40:07', '51', 44, 1, 1, 1, 2500, NULL), ('2017-05-31 11:44:52', '51', 45, 1, 1, 1, 2500, NULL), ('2017-05-31 11:46:27', '51', 46, 1, 1, 1, 2500, NULL), ('2017-10-30 19:48:10', '51', 47, 1, 1, 1, 2500, NULL), ('2017-10-30 19:50:27', '51', 48, 1, 1, 1, 2500, NULL), ('2017-10-30 19:51:11', '51', 49, 1, 1, 1, 2500, NULL), ('2017-10-30 19:51:58', '51', 50, 1, 1, 1, 2500, NULL), ('2017-10-30 19:54:05', '51', 51, 1, 1, 1, 2500, NULL), ('2017-10-30 20:23:48', '51', 52, 1, 1, 1, 2500, NULL); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `lt_users` -- CREATE TABLE `lt_users` ( `user_id` int(11) NOT NULL, `user_name` varchar(60) NOT NULL, `user_password` varchar(60) NOT NULL, `user_nombres` varchar(250) NOT NULL, `user_email` varchar(100) NOT NULL, `user_active` tinyint(1) NOT NULL DEFAULT '1' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Volcado de datos para la tabla `lt_users` -- INSERT INTO `lt_users` (`user_id`, `user_name`, `user_password`, `user_nombres`, `user_email`, `user_active`) VALUES (1, 'admin', 'admin', 'Usuario Demo', 'charlescifuentes@colombia-web.com', 1); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `lt_vehiculos` -- CREATE TABLE `lt_vehiculos` ( `numero_vehiculo` varchar(10) NOT NULL, `placa_vehiculo` varchar(10) NOT NULL, `nombres_conductor` varchar(50) NOT NULL, `apellidos_conductor` varchar(50) NOT NULL, `telefono_conductor` varchar(50) NOT NULL, `numero_licencia` varchar(50) NOT NULL, `categoria_licencia` varchar(5) NOT NULL, `venc_licencia` date NOT NULL, `numero_soat` varchar(50) NOT NULL, `venc_soat` date NOT NULL, `num_tarjeta_operacion` varchar(50) NOT NULL, `venc_tarjeta_operacion` date NOT NULL, `extracto_contractual` varchar(50) NOT NULL, `venc_extracto_contractual` date NOT NULL, `num_tecnico_mecanica` varchar(50) NOT NULL, `venc_tecnico_mecanica` date NOT NULL, `clase_vehiculo` varchar(20) NOT NULL, `capacidad_pasajeros` int(11) NOT NULL, `pasajeros_asignados` int(11) NOT NULL DEFAULT '0', `enturnar` tinyint(1) NOT NULL DEFAULT '0', `nombres_propietario` varchar(50) NOT NULL, `apellidos_propietario` varchar(50) NOT NULL, `telefono_propietario` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Volcado de datos para la tabla `lt_vehiculos` -- INSERT INTO `lt_vehiculos` (`numero_vehiculo`, `placa_vehiculo`, `nombres_conductor`, `apellidos_conductor`, `telefono_conductor`, `numero_licencia`, `categoria_licencia`, `venc_licencia`, `numero_soat`, `venc_soat`, `num_tarjeta_operacion`, `venc_tarjeta_operacion`, `extracto_contractual`, `venc_extracto_contractual`, `num_tecnico_mecanica`, `venc_tecnico_mecanica`, `clase_vehiculo`, `capacidad_pasajeros`, `pasajeros_asignados`, `enturnar`, `nombres_propietario`, `apellidos_propietario`, `telefono_propietario`) VALUES ('04', 'CDF-34C', 'JUANA', 'MARIA', '123123123', 'SADSAD', 'B1', '2017-03-16', 'SDFDSF123213', '2017-03-08', 'ASDDASD12321', '2017-04-21', 'DSDF213213', '2017-04-21', 'SDFDSF123213', '2017-04-27', 'AUTOMOVIL', 4, 0, 0, 'PABLO', 'PEREZ', '123123123'), ('07', 'CCD-12C', 'CASJDJKS', 'SAKLDSAKD', '21312', 'ASDSALKD', 'SADSA', '2017-05-18', 'ASDSAD', '2017-05-18', '', '0000-00-00', '', '0000-00-00', '', '0000-00-00', '', 0, 0, 0, 'ASDSAD', 'ASDASD', '23123'), ('51', 'CQW858', 'CHARLES', 'CIFUENTES', '3174015113', '675767SDASD', 'C1', '2018-06-20', '2545ASDE2', '2017-03-31', '225SSDFE', '2017-03-28', 'ASD254', '2017-03-30', 'QWE213', '2017-03-30', 'TAXI', 4, 13, 1, 'JUAN', 'DE LA CRUZ', '3123432343'), ('85', 'NCT13C', 'LEIDY', 'GUEVARA', '3103381276', '', '', '0000-00-00', '25SDA', '2017-04-12', '12321SADASD', '2017-03-08', 'ASDAS23132', '2017-03-08', 'ASDASD123', '2017-03-31', 'MOTO', 1, 0, 0, 'JUANA', 'DE ARCO', '876675654'); -- -- Índices para tablas volcadas -- -- -- Indices de la tabla `lt_bodega` -- ALTER TABLE `lt_bodega` ADD PRIMARY KEY (`id_bodega`), ADD KEY `doc_cliente` (`doc_cliente`), ADD KEY `id_servicio` (`id_servicio`); -- -- Indices de la tabla `lt_clientes` -- ALTER TABLE `lt_clientes` ADD PRIMARY KEY (`id_cliente`), ADD UNIQUE KEY `doc_cliente` (`doc_cliente`); -- -- Indices de la tabla `lt_configuracion` -- ALTER TABLE `lt_configuracion` ADD PRIMARY KEY (`id_configuracion`); -- -- Indices de la tabla `lt_cuota_administracion` -- ALTER TABLE `lt_cuota_administracion` ADD PRIMARY KEY (`id_cadmin`), ADD KEY `numero_vehiculo` (`numero_vehiculo`), ADD KEY `id_ruta` (`id_ruta`); -- -- Indices de la tabla `lt_rutas` -- ALTER TABLE `lt_rutas` ADD PRIMARY KEY (`id_ruta`), ADD UNIQUE KEY `id_ruta` (`id_ruta`); -- -- Indices de la tabla `lt_servicios` -- ALTER TABLE `lt_servicios` ADD PRIMARY KEY (`id_servicio`); -- -- Indices de la tabla `lt_tiquetes` -- ALTER TABLE `lt_tiquetes` ADD PRIMARY KEY (`id_tiquete`), ADD UNIQUE KEY `id_tiquete` (`id_tiquete`), ADD KEY `id_ruta` (`id_ruta`), ADD KEY `valor_ruta` (`valor_ruta`), ADD KEY `doc_cliente` (`doc_cliente`), ADD KEY `numero_vehiculo` (`numero_vehiculo`) USING BTREE; -- -- Indices de la tabla `lt_users` -- ALTER TABLE `lt_users` ADD PRIMARY KEY (`user_id`), ADD KEY `user_name` (`user_nombres`); -- -- Indices de la tabla `lt_vehiculos` -- ALTER TABLE `lt_vehiculos` ADD PRIMARY KEY (`numero_vehiculo`), ADD UNIQUE KEY `numero_vehiculo` (`numero_vehiculo`), ADD KEY `placa_vehiculo` (`placa_vehiculo`) USING BTREE; -- -- AUTO_INCREMENT de las tablas volcadas -- -- -- AUTO_INCREMENT de la tabla `lt_bodega` -- ALTER TABLE `lt_bodega` MODIFY `id_bodega` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; -- -- AUTO_INCREMENT de la tabla `lt_clientes` -- ALTER TABLE `lt_clientes` MODIFY `id_cliente` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT de la tabla `lt_cuota_administracion` -- ALTER TABLE `lt_cuota_administracion` MODIFY `id_cadmin` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16; -- -- AUTO_INCREMENT de la tabla `lt_rutas` -- ALTER TABLE `lt_rutas` MODIFY `id_ruta` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT de la tabla `lt_servicios` -- ALTER TABLE `lt_servicios` MODIFY `id_servicio` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT de la tabla `lt_tiquetes` -- ALTER TABLE `lt_tiquetes` MODIFY `id_tiquete` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=53; -- -- AUTO_INCREMENT de la tabla `lt_users` -- ALTER TABLE `lt_users` MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- Restricciones para tablas volcadas -- -- -- Filtros para la tabla `lt_bodega` -- ALTER TABLE `lt_bodega` ADD CONSTRAINT `lt_bodega_ibfk_1` FOREIGN KEY (`doc_cliente`) REFERENCES `lt_clientes` (`doc_cliente`) ON UPDATE CASCADE, ADD CONSTRAINT `lt_bodega_ibfk_2` FOREIGN KEY (`id_servicio`) REFERENCES `lt_servicios` (`id_servicio`) ON UPDATE CASCADE; -- -- Filtros para la tabla `lt_cuota_administracion` -- ALTER TABLE `lt_cuota_administracion` ADD CONSTRAINT `lt_cuota_administracion_ibfk_1` FOREIGN KEY (`numero_vehiculo`) REFERENCES `lt_vehiculos` (`numero_vehiculo`) ON UPDATE CASCADE, ADD CONSTRAINT `lt_cuota_administracion_ibfk_2` FOREIGN KEY (`id_ruta`) REFERENCES `lt_rutas` (`id_ruta`) ON UPDATE CASCADE; -- -- Filtros para la tabla `lt_tiquetes` -- ALTER TABLE `lt_tiquetes` ADD CONSTRAINT `lt_tiquetes_ibfk_2` FOREIGN KEY (`doc_cliente`) REFERENCES `lt_clientes` (`doc_cliente`) ON UPDATE CASCADE, ADD CONSTRAINT `lt_tiquetes_ibfk_3` FOREIGN KEY (`id_ruta`) REFERENCES `lt_rutas` (`id_ruta`) ON UPDATE CASCADE, ADD CONSTRAINT `lt_tiquetes_ibfk_4` FOREIGN KEY (`numero_vehiculo`) REFERENCES `lt_vehiculos` (`numero_vehiculo`) ON UPDATE CASCADE; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
88ab6e58295d8613af781944b9f1826e9518df78
SQL
SoloshenkoVeronika/flower
/src/main/resources/first_script.sql
UTF-8
4,372
3.296875
3
[]
no_license
CREATE TABLE flower( id int(3) NOT NULL AUTO_INCREMENT, species varchar(60) NOT NULL, sort varchar(100) NOT NULL, color varchar(30) NOT NULL, length float(2) NOT NULL, amount int(3) NOT NULL, price float(2) NOT NULL, picture varchar(256) NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; INSERT INTO flower (species, sort, color, length, amount, price, picture) VALUES ('Роза', 'Blanche Moreau', 'Белый', 90, 50, 3.9, null); INSERT INTO flower (species, sort, color, length, amount, price, picture) VALUES ('Роза', 'Leonardo da Vinci', 'Розовый', 60, 30, 4, null); INSERT INTO flower (species, sort, color, length, amount, price, picture) VALUES ('Роза', 'Мисс Пигги (Miss Piggy)', 'Розовый', 45, 50, 4.2, null); INSERT INTO flower (species, sort, color, length, amount, price, picture) VALUES ('Тюльпан', 'Christmas Dream', 'Розовый', 35, 60, 1.8, null); CREATE TABLE `user` ( `id` int(2) NOT NULL AUTO_INCREMENT, `login` varchar(50) NOT NULL, `password` varchar(256) NOT NULL, `status` int(2) NULL, PRIMARY KEY (`id`), UNIQUE KEY `login` (`login`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE sender( id_s int(3) NOT NULL AUTO_INCREMENT, name varchar(50) NOT NULL, surname varchar(256) NOT NULL, phone varchar(256) NOT NULL, e_mail varchar(256) NULL, PRIMARY KEY (id_s), UNIQUE KEY phone (phone) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE recipient( id_r int(3) NOT NULL AUTO_INCREMENT, name varchar(50) NOT NULL, surname varchar(256) NOT NULL, phone varchar(256) NOT NULL, PRIMARY KEY (id_r), UNIQUE KEY phone (phone) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE address( id_a int(3) NOT NULL AUTO_INCREMENT, city varchar(50) NOT NULL, street varchar(256) NOT NULL, house int(3) NOT NULL, corps int(3) NOT NULL, flat int(3) NOT NULL, PRIMARY KEY (id_a) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE payment ( id_p int(3) NOT NULL AUTO_INCREMENT, namr_payment varchar(50) NOT NULL, PRIMARY KEY (id_p) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE size( id_sz int(3) NOT NULL AUTO_INCREMENT, length int(3) NOT NULL, width int(3) NOT NULL, diagonal int(3) NOT NULL, volume int(3) NOT NULL, PRIMARY KEY (id_sz) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE bouquet( id INT(3) NOT NULL AUTO_INCREMENT, name VARCHAR(60) NOT NULL, composition VARCHAR(256) NOT NULL, length FLOAT(2) NOT NULL, diameter FLOAT(2) NOT NULL, weight FLOAT(2) NOT NULL, amount INT(3) NOT NULL, price FLOAT(2) NOT NULL, picture VARCHAR(256) NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE decoration( id int(3) NOT NULL AUTO_INCREMENT, name varchar(50) NOT NULL, amount INT(3) NOT NULL, price FLOAT(2) NOT NULL, picture VARCHAR(256) NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE composition( id INT(3) NOT NULL AUTO_INCREMENT, name VARCHAR(60) NOT NULL, composition VARCHAR(256) NOT NULL, pack VARCHAR(256) NOT NULL, amount INT(3) NOT NULL, price FLOAT(2) NOT NULL, picture VARCHAR(256) NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE pack( id INT(3) NOT NULL AUTO_INCREMENT, name VARCHAR(60) NOT NULL, amount INT(3) NOT NULL, price FLOAT(2) NOT NULL, picture VARCHAR(256) NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE order ( id_o int(3) NOT NULL AUTO_INCREMENT, id_s int(3) NOT NULL, id_r int(3) NOT NULL, id_pr int(3) NOT NULL, id_a int(3) NOT NULL, id_p int(3) NOT NULL, data varchar(50) NOT NULL, postcard varchar(50) NULL, addinforn varchar(50) NULL, anonymity boolean NULL, cost float NOT NULL, PRIMARY KEY (id_o), CONSTRAINT user FOREIGN KEY (id_s) REFERENCES sender (id_s), CONSTRAINT user FOREIGN KEY (id_r) REFERENCES recipient (id_r), CONSTRAINT user FOREIGN KEY (id_a) REFERENCES address(id_a), CONSTRAINT user FOREIGN KEY (id_p) REFERENCES payment (id_p) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE product( id_pr int(3) NOT NULL, id_o int(3) NOT NULL, ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
true
15738b1e6dd9ce436a148fffc896df538f3cf3f6
SQL
PDOK/brt2mvt
/create_spoorbaandeellijn.sql
UTF-8
911
2.828125
3
[]
no_license
CREATE TABLE spoorbaanlijn AS ( SELECT type_spoorbaan, spoorbreedte, aantal_sporen, status, hoogteniveau, vervoerfunctie, elektrificatie, fysiek_voorkomen, viscode, ST_Transform(shape, 3857)::geometry(MULTILINESTRING, 3857) AS geom , ARRAY[12,13,14] AS zoomlevel FROM fgdb_brt.spoorbaandeellijn_6_8 UNION SELECT type_spoorbaan, spoorbreedte, aantal_sporen, status, hoogteniveau, vervoerfunctie, elektrificatie, fysiek_voorkomen, viscode, ST_Transform(shape, 3857)::geometry(MULTILINESTRING, 3857) AS geom , ARRAY[15,16,17,18,19] AS zoomlevel FROM fgdb_brt.spoorbaandeellijn_9_14 ORDER BY zoomlevel ); ALTER TABLE spoorbaanlijn ADD COLUMN fid SERIAL PRIMARY KEY; CREATE INDEX spoorbaanlijn_gix ON public.spoorbaanlijn USING gist (geom); CLUSTER spoorbaanlijn USING spoorbaanlijn_gix; CREATE INDEX gin_spoorbaanlijn ON public.spoorbaanlijn USING gin (zoomlevel);
true
fa3111f4c3420baa0d6c61fc3fa637afda5952c7
SQL
LINLUOOO/AWS2test
/backend/db/seed/db_with_data.sql
UTF-8
18,238
3.28125
3
[]
no_license
CREATE DATABASE IF NOT EXISTS `medsec` /*!40100 DEFAULT CHARACTER SET utf8 */; USE `medsec`; -- MySQL dump 10.13 Distrib 5.7.22, for osx10.13 (x86_64) -- -- Host: 127.0.0.1 Database: medsec -- ------------------------------------------------------ -- Server version 5.7.22 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `Appointment` -- DROP TABLE IF EXISTS `Appointment`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `Appointment` ( `id` int(11) NOT NULL, `uid` int(11) NOT NULL, `did` int(11) NOT NULL, `title` varchar(255) NOT NULL, `detail` longtext DEFAULT NULL, `date_create` datetime NOT NULL, `date_change` datetime NOT NULL, `date` datetime NOT NULL, `duration` int(45) NOT NULL, `note` longtext DEFAULT NULL, `user_note` longtext DEFAULT NULL, `status` enum('UNCONFIRMED','CONFIRMED','CANCELLED') DEFAULT 'UNCONFIRMED', PRIMARY KEY (`id`), KEY `fk_Appointment_Patient1_idx` (`uid`), KEY `did` (`did`), CONSTRAINT `Appointment_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `User` (`id`), CONSTRAINT `Appointment_ibfk_3` FOREIGN KEY (`did`) REFERENCES `Doctor` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `Appointment` (`id`, `uid`, `did`, `title`, `detail`, `date_create`, `date_change`, `date`, `duration`, `note`, `user_note`, `status`) VALUES (1, 1, 1, 'Day Oncology Unit', 'Education session', '2020-05-01 00:00:00', '2020-05-18 04:05:16', '2020-06-20 14:15:00', 15, 'Looking after yourself during chemotherapy - Watch Patient Health History Sheet - Please fill in and email back to daychemo.wrp@ramsayhealth.com.au Parking Information - ReadQuestions Sheet - Read', NULL, 'UNCONFIRMED'), (2, 2, 2, 'Day Oncology Unit', 'Education session', '2020-05-01 00:00:00', '2020-05-18 04:05:16', '2020-06-22 14:15:00', 15, 'Looking after yourself during chemotherapy - Watch Patient Health History Sheet - Please fill in and email back to daychemo.wrp@ramsayhealth.com.au Parking Information - ReadQuestions Sheet - Read', 'test', 'CONFIRMED'), (3, 2, 2, 'Day Oncology Unit', 'Education session', '2020-05-01 00:00:00', '2020-05-18 04:05:16', '2020-06-30 14:15:00', 15, 'Looking after yourself during chemotherapy - Watch Patient Health History Sheet - Please fill in and email back to daychemo.wrp@ramsayhealth.com.au Parking Information - ReadQuestions Sheet - Read', NULL, 'CONFIRMED'), (131828, 4598, 5, 'PICKERING Susan', 'CS', '2020-09-14 00:00:00', '2020-09-14 04:15:07', '2020-09-10 10:20:00', 20, 'Treatment at 12:30pm at Day Onc. Appt in 3 mths with CT/PET scan and bloods prior.', 'ask about scan also resul5s', 'CONFIRMED'), (131829, 5774, 5, 'SMITH Christopher', 'Chemo', '2020-09-14 00:00:00', '2020-09-14 04:14:34', '2020-09-10 09:40:00', 20, 'Appt in 3 weeks with bloods prior. Appt with Dr Lontos next week. Email bloods.', NULL, 'UNCONFIRMED'), (131830, 5774, 5, 'SMITH Christopher', 'CS', '2020-09-14 00:00:00', '2020-09-14 04:22:31', '2020-09-17 09:50:00', 10, 'Review next week.', NULL, 'UNCONFIRMED'), (131832, 4598, 5, 'PICKERING Susan', 'CS', '2020-09-14 00:00:00', '2020-09-14 04:22:40', '2020-09-17 10:30:00', 10, 'Review with bloods in 2 weeks', NULL, 'CONFIRMED'); DROP TABLE IF EXISTS `Doctor`; CREATE TABLE `Doctor` ( `id` int(11) NOT NULL, `name` varchar(45) NOT NULL, `bio` varchar(255) DEFAULT NULL, `address` varchar(255) DEFAULT NULL, `phone` varchar(45) DEFAULT NULL, `fax` varchar(45) DEFAULT NULL, `email` varchar(45) DEFAULT NULL, `website` varchar(255) DEFAULT NULL, `expertise` mediumtext DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `Doctor` (`id`, `name`, `bio`, `address`, `phone`, `fax`, `email`, `website`, `expertise`) VALUES (1, 'Prof Niall Tebbutt', 'http://www.darebinstspecialistcentre.com.au/prof-niall-tebbutt', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', 'Medical Oncologist'), (2, 'Dr Yvonne Yeung', 'http://www.darebinstspecialistcentre.com.au/dr-yvonne-yeung', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', 'Medical Oncologist'), (3, 'A/Prof Andrew Weickhardt', 'http://www.darebinstspecialistcentre.com.au/aprof-andrew-weickhardt', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', 'Medical Oncologist'), (4, 'Dr Sagun Parakh', 'http://www.darebinstspecialistcentre.com.au/dr-sagun-parakh', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', 'Medical Oncologist'), (5, 'Dr Belinda Yeo', 'http://www.darebinstspecialistcentre.com.au/dr-belinda-yeo', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', 'Medical Oncologist'), (6, 'Dr Ruwani Mendis', NULL, '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', 'Medical Oncologist/Palliative Care Physician'), (7, 'Dr Mark Goodwin', 'http://www.darebinstspecialistcentre.com.au/dr-mark-goodwin', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', 'Intervential Radiologist'), (8, 'Dr Dinesh Ranatunga', 'http://www.darebinstspecialistcentre.com.au/dr-dinesh-ranatunga', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', 'Intervential Radiologist'), (9, 'Sharon Turner', 'http://www.darebinstspecialistcentre.com.au/sharon-turner', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', NULL), (10, 'Sophie Skalkos', 'http://www.darebinstspecialistcentre.com.au/sophie-skalkos', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', NULL), (11, 'Dale Ishcia', 'http://www.darebinstspecialistcentre.com.au/dale-ischia', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', NULL), (12, 'Lauren Young', 'http://www.darebinstspecialistcentre.com.au/lauren-young', '66 Darebin Street, Heidelberg VIC 3084', '(03) 9458 5100', '(03) 9458 5199', 'reception@66darebinst.com.au', 'www.darebinstspecialistcentre.com.au', NULL); DROP TABLE IF EXISTS `File`; CREATE TABLE `File` ( `id` int(11) NOT NULL, `apptid` int(11) NOT NULL, `title` varchar(255) NOT NULL, `link` varchar(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `link` (`link`), KEY `apptid` (`apptid`), CONSTRAINT `File_ibfk_2` FOREIGN KEY (`apptid`) REFERENCES `Appointment` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- INSERT INTO `File` (`id`, `apptid`, `title`, `link`) VALUES -- (1, 1, 'File-sample-1.pdf', '/result/1/File-sample-1.pdf'), -- (2, 2, 'File-sample-2.pdf', '/result/2/File-sample-2.pdf'), -- (3, 3, 'File-3.pdf', '/result/3/File-3.pdf'), -- (131828, 131828, 'File-sample-131828.pdf', '/result/131828/File-sample-131828.pdf'), -- (131829, 131829, 'File-sample-131829.pdf', '/result/131829/File-sample-131829.pdf'); DROP TABLE IF EXISTS `Hospital`; CREATE TABLE `Hospital` ( `id` int(11) NOT NULL, `name` varchar(255) NOT NULL, `address` varchar(255) DEFAULT NULL, `emergencyDept` varchar(255) DEFAULT NULL, `phone` varchar(45) DEFAULT NULL, `aftPhone` varchar(45) DEFAULT NULL, `fax` varchar(45) DEFAULT NULL, `email` varchar(45) DEFAULT NULL, `website` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `Hospital` (`id`, `name`, `address`, `emergencyDept`, `phone`, `aftPhone`, `fax`, `email`, `website`) VALUES (1, 'Warringal Private Hospital', '216 burgundy Street, Heidelberg VIC 3084', 'No', '(03) 9274 1300', NULL, '(03) 9459 7606', NULL, 'https://www.warringalprivate.com.au'), (2, 'Warringal Day Oncology Unit', '8 Martin Street, Heidelberg VIC 3084', 'No', '(03) 9274 1423', NULL, NULL, 'daychemo.wrp@ramsayhealth.com.au', 'https://www.warringalprivate.com.au/Our-Services/Day-Oncology-Centre'), (3, 'Austin Hospital', '145 Studley Rd, Heidelberg VIC 3084', 'Yes. Open 24 hours', '(03) 9496 5000', NULL, '(03) 9458 4779', NULL, 'https://www.austin.org.au'), (4, 'Austin Repatriation Hospital', '300 Waterdale Road, Ivanhoe Victoria 3079', 'No', '(03) 9496 5000', NULL, '(03) 9496 2541', NULL, 'https://www.austin.org.au/heidelberg-repatriation-hospital'), (5, 'Olivia Newton-John Cancer Wellness and Research Centre', '145 Studley Road, Heidelberg Victoria 3084', 'No', '(03) 9496 5000', NULL, '(03) 9458 4779', NULL, 'https://www.onjcancercentre.org'); DROP TABLE IF EXISTS `NotificationToken`; CREATE TABLE `NotificationToken` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL, `fcm_token` varchar(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uid_fcm_token` (`uid`,`fcm_token`), KEY `fk_NotificationToken_User_idx` (`uid`), CONSTRAINT `NotificationToken_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `User` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `NotificationToken` (`id`, `uid`, `fcm_token`) VALUES (115, 1, 'c981zn0iXnc:APA91bF-cXpzA3v2Uk2de746joKRB73OLjj0RJMq8iGRVhr0w4pSMWsC6by3TSleD2NbK3iMJ0DHjlAitK52jdnYbfW5vSDvMatkTBizYLBtYPHkBhLS9AiwK5rrEPmJ79uzidf2i8Lr'), (186, 1, 'cAp6VHNhQR8:APA91bFbzJbA2HXzYLN733O2V7A3b4AocQl-OuloEiJnfqAM12PvggBym5pN0AwhGuEMfhc5QGTciSOR9um1FReNrjBv-uhWPTg7ZG92kM0deYNHLAI3aecJq77SbsDYFWGMXI2T90hR'), (135, 1, 'cbQq3biBdcY:APA91bGenWLe9VSq4P7fQB8f2TdnLiuQhOeXUSxEtsXdYKmExJ4jlLkn6APc2GvcgG3Om59L7SP0tWr89Yfjo25AdhJgGrhbrv3a_MUEg2aKuEX1iMvZfDqyWJchTX_7RCEMahvA4wfw'), (140, 1, 'cKc8WtM40A4:APA91bEWap50UqiBaqpj6hTU4_VsX_qccT1i-tDnsYbK_23KZiGOKF5LIHnbQNetuL_dqsJtxRByIh3zCHrjPV5bdK7y7q0dgLfAfV-ykXxZ-q0IjJPiltXVI0574NUkDuTY6PCj1Rqc'), (114, 1, 'cTt68GCxobs:APA91bEksB-nhK7ZrIu1l91l2I3-JMwX-QvJ7uFAMK3WKzOltY2GX5z1tgN69xjW1CYTy9koUWKgBO-DZ-rLHq0UbLCVdrHbjU_KkxY6RlYq4Jj6-T3ZPSsXvUseABaLAip7J78VR0qq'), (198, 1, 'cvGRhK8mwt0:APA91bGQHRmiWMVSXy2izu2ex2FTZYOFJiHPgkJQKHFKgzy80toX35roe3l473qY3Ql_hVgC_gcj8qfWVHZ-vy4rw1kwGUUg8IK7G5yhrXeDl1XlzkYgAJ1ths7AH742rYRyT9fXusKr'), (249, 1, 'cvWXN5FUY5g:APA91bE7u9DXTcXmpbIRc9Hkur3phpgtbvqvOhuYZzY4n_I5jR4QoUecOE4dZGnHkfPGMU6eP83Elq1s6cjIP6vTHRjpoNQITY-ycHSj06VOG05ok6NLiRO1_Yx-YNWkGtRy8pp_8yXj'), (117, 1, 'dGZf4E4WBB4:APA91bELZZP8_t1HVnn_dNg7XypyNzpOobs_qBm45txOctLUzJrekZsjGVBlLBAf6oFQXQbd2x5tNB056hXNI-B8-5Ht4T2qZ3P7mTMonxdN8_NwHEB4pXqM88uACEMh2ogpTfyiEqw4'), (211, 1, 'dme1fbmqu3I:APA91bEpVHe0GiNy6la2v3zgiyjn4rziMJ-Wn7vDPIMTwg1zY55eXFcQz4kPnO9ZFYNU0_st4ExGuDb5jBZgMjKS3mRAjw4PBP9c4pQn395tTelTtoaxa6NhRhhZkmQ-IAmb_smTrk7n'), (287, 1, 'dZpS10iVJCc:APA91bE1iMW_0AyDmUHINv1o28NFhzwh7t0mL2LNxz2--ZDar4ZTninCZv8Yu7xgcLuMBO98iRof4IyC8xREzsSz-DJA8UoPtmzKOc42YZ2C5GTAl9q6ezuJAtbGIDd1NZIPbxYp7_Pg'), (243, 1, 'dZpS10iVJCc:APA91bErH2hPInJAnP2kuZXMrg-5wI-AqgjS2a0sEjnQDiOG57JkV6q8-WdeISF6wSA_IkG_O8NoWKCBWc-WXvzCK4tsCXk6PnptbWssdvcChY6mrdVjhs_KMCjmTwSIimt4tEBvHmuI'), (247, 1, 'eNBD_AAenWw:APA91bHHmRZWBCs61CJ37tgMZtBJ5gZL9KvpNdNDuXaehSgtzNeXSuz2R3ROmsKydT2jmBjs-NWgzReSdz0srkXCNthTr6BNQb53X5LQgWCHcIQcI_Iq31qDfeLLZSACd0-VkZVbbrFJ'), (176, 1, 'eNBD_AAenWw:APA91bHr7m28C5l9JuS8vk8c8phsskoGLIJ-TfaGVOiFGZT_qb0gMmnzwGU6Yk62KAlcdOy5uwfFkKHmIZyvgI8HizmZ6x3RuEffKsnEOcp-PtNcHA5kYU0E2tx69YRWXu8MV-55o9Yh'), (118, 1, 'ew1JGnBiCAg:APA91bGH1DM23BEav8aSUd_YX8jauEFsSLftVO7FL3j9VW3lrxMbzDHRArL6uH4z1CjA4KaC_USSqVV4Z7v0ZUJDs-lQkHA44hNzaRoj_e9WNNZHgIQ9nE48qAad0B639jaT-HUXwTwC'), (168, 1, 'eZe7h4nJ7eg:APA91bEYGQUfrcISorBnvzKBxIutzm66BRpqmRRsIWtEhle6sUG-8ZmSwtnICy_zCKbR-zDGYd0h5fFznIkL3Kt2N2fD3_aCCQf2_OTqgUfD8UHB3KqLoS2jBBWoTL0DMRB15QlWTZXV'), (119, 1, 'fC7huI8eLn8:APA91bEcFpN-5u_xVW07j60vmX1QxKR0n6UZAdI-RRi81iynH0acyIz5L_7JefF9MNYqfBCGvWPscLRFxghAV2dYu6PyGTYDce6X7qmcoln6KzvqvbmusgfGdv2OXL37XAOhZn4s7d0P'), (164, 1, 'fJXmC2wUMc0:APA91bFOctx84QFeWE1q2WnVHHkFPEJjmruwIr-XsOUqgWxgbCe_KsnekzxJ_MpuBTFdmMTucBa5R8rnfSjwapqMlChGkimXgMuM7EvKZIGgLguhjn9DIWf35KHICAeEIc4FV83leGh7'), (232, 1, 'fXK0m8q4-ZQ:APA91bFQIrYxqFP-dqL21PE6FWN0WiAUqZ1-n5J2GHAEonbnm-3_v22J0joybk3cTudg0zn3cRpIphcLJu6LwOlnVMJ8175h3M3s9io_k1y9qqIraeiHXE8kwtrbjX0FkkpYPr7ozGBq'), (150, 2, 'c2npw5McqF0:APA91bGh91cZubzNVKKQgHxsXx7zdWTgHzBI8_bKV06u-Z1kQRS3LPr-w-T-4V77OKuV2byNfFXJ2DuYTHUqNF7sOdPu32ZXpf9HHGYRORYig_VuMMCPsHsissK-ONf4eSF8U3gCbVKe'), (201, 2, 'c2X7G50qKKw:APA91bHSCA4-6jwPxsOgRC7scGlHoahlxyqByNErpfWcXG_bU4Xt-9ZmiV4XUKcFgdI4bJ5OJ8_AoSJ09Rrhsyqf7hFEANck-qczDBJoCwZMHf6sEDVgrJ7rjCXJ6HC-pH32xv-0fpII'), (120, 2, 'c981zn0iXnc:APA91bF-cXpzA3v2Uk2de746joKRB73OLjj0RJMq8iGRVhr0w4pSMWsC6by3TSleD2NbK3iMJ0DHjlAitK52jdnYbfW5vSDvMatkTBizYLBtYPHkBhLS9AiwK5rrEPmJ79uzidf2i8Lr'), (190, 2, 'cAp6VHNhQR8:APA91bFbzJbA2HXzYLN733O2V7A3b4AocQl-OuloEiJnfqAM12PvggBym5pN0AwhGuEMfhc5QGTciSOR9um1FReNrjBv-uhWPTg7ZG92kM0deYNHLAI3aecJq77SbsDYFWGMXI2T90hR'), (132, 2, 'cbQq3biBdcY:APA91bGenWLe9VSq4P7fQB8f2TdnLiuQhOeXUSxEtsXdYKmExJ4jlLkn6APc2GvcgG3Om59L7SP0tWr89Yfjo25AdhJgGrhbrv3a_MUEg2aKuEX1iMvZfDqyWJchTX_7RCEMahvA4wfw'), (336, 2, 'cDlokelT5uw:APA91bFxO1Eta0PAAveeHZedb70k-faQhpGwrFFJmHDIuLdIJ-nFvvBBaKME33FrwqGp8oh5M2oAEKrpYgzzySZ_7UgpClE62-n-9aj0cBMTofULfT0HKKH7VcD8ArCyxLOCYR7mfQ0B'), (246, 2, 'cDWky4QQqSo:APA91bFvxptwUqgv8rWofW97xx8tfzTfC9-Z3-6Bt-m6cuITUU9vAnA8PNJ2-oQ8MpB0YI9pEGkeiFWYFon5i920JlVPk5r_V1RDLgVcqUCMS-JgZUj58Z0kAF19K5hWCAWFlR92ykCN'), (215, 2, 'cFvsGS8sRQE:APA91bGFYKdGYM6XPy5jUHmCX2blbRVm5sV2ok0DbCUtv23aQScCp7xsZTXw59_7CXIL7vvbiarunP6rmljcK7f55dGsUyguI9CsZwBwtPvP-LNNY4XgYW8Src6nEk463OCCQpFoWmAI'), (141, 2, 'cKc8WtM40A4:APA91bEWap50UqiBaqpj6hTU4_VsX_qccT1i-tDnsYbK_23KZiGOKF5LIHnbQNetuL_dqsJtxRByIh3zCHrjPV5bdK7y7q0dgLfAfV-ykXxZ-q0IjJPiltXVI0574NUkDuTY6PCj1Rqc'), (169, 2, 'ctjQJ0_zbEw:APA91bEtBP1kKk0Hay6sSx5__pJn5NJf9f19747PBhxfNabdGcDO_rBtHiA5cEKXsJEJmJ0_hbXicnAUw9yHCSrrH0Ek0PVq9rt5anCHYwr7IsKx8ClpqQr8zAIDo-wwP5z-I_udedzE'), (187, 2, 'cvGRhK8mwt0:APA91bGQHRmiWMVSXy2izu2ex2FTZYOFJiHPgkJQKHFKgzy80toX35roe3l473qY3Ql_hVgC_gcj8qfWVHZ-vy4rw1kwGUUg8IK7G5yhrXeDl1XlzkYgAJ1ths7AH742rYRyT9fXusKr'), (252, 2, 'cvWXN5FUY5g:APA91bE7u9DXTcXmpbIRc9Hkur3phpgtbvqvOhuYZzY4n_I5jR4QoUecOE4dZGnHkfPGMU6eP83Elq1s6cjIP6vTHRjpoNQITY-ycHSj06VOG05ok6NLiRO1_Yx-YNWkGtRy8pp_8yXj'), (251, 2, 'cwiXzp1yuVM:APA91bEELVopqZPSH9JvhDz-fRpK_WZkhhBljUSC0Sk7sfZUTgIhVNHV6cLqZFTx0wk8ylZaDn13uO_MCVeCRsjUeRp1XmRUoefBq6AZoQNAgqW5AE9WAgOsHjpGwSWvY5psBZTiEs0p'), (295, 2, 'd-mkSGI5_04:APA91bHwK8kTCoBu3D8iO8FHztfrpCcKDWmd4ayKFVU5F5F0Drbu6WAZn7OVKRfrVWhy8xyki5_naHUbEvzfoVym4QO0BFvxFN9RzhsetECgu-5JAgOsCp0lLADjJ5jpfcZN0-1Y4Ixy'), (134, 2, 'd7FLYlCtyCs:APA91bFFY6Dl70DKB22-sLrgdoYA5zRxUmUJt_qbWh3vtDp1dAhPvmMIoy7hXifZvFZTwVHpKy3vPxbAgdHoWbh3M2M8wsel3rBpQQ9CrTPDTnqPY3b3YZ3GE0zpeKP2E_-iqcKoDSuU'), (152, 2, 'ddANRE_ZOGI:APA91bHzRtSVuneMblITQvJtxadcrbUvcWXTkEP7ib-xAdkET3R1tNdtObAZ7b3y1eSQyZrokEcn4QCrO0gYfX9oeWZMubZ0Ssz-hcLRlwY5lIcIRDkFC4Shnt3vWz46-rHXh_np06v5'), (203, 2, 'dDR8_fie5sg:APA91bFsuMcK11IAkoTd8gMva6owoXPtfrBWZe-38vj3-HfwCOgT8xOldNA9RiSQkq-6c6Na-f57vDiWGnnpvY95t5B9GGj8NpKwZPFfhjynwAiQDWqu0qeB1xSS7kLz_OYECnz-5kWJ'), (122, 2, 'dGZf4E4WBB4:APA91bELZZP8_t1HVnn_dNg7XypyNzpOobs_qBm45txOctLUzJrekZsjGVBlLBAf6oFQXQbd2x5tNB056hXNI-B8-5Ht4T2qZ3P7mTMonxdN8_NwHEB4pXqM88uACEMh2ogpTfyiEqw4'), (216, 2, 'dhhRdxLE6ZA:APA91bEpOAMM9v636JJYTWNe14UJghBL3Ve5Jy9gy_M0CdS9TzBHUp1RNpQmWnV7BgbJG1r6mPCwUH5uDsqhr216tu7XiasmNtnNiLgWVNH7c5ZmE-6RAcynWwtjGiJjEbI1MxTuQiGt'), (210, 2, 'dme1fbmqu3I:APA91bEpVHe0GiNy6la2v3zgiyjn4rziMJ-Wn7vDPIMTwg1zY55eXFcQz4kPnO9ZFYNU0_st4ExGuDb5jBZgMjKS3mRAjw4PBP9c4pQn395tTelTtoaxa6NhRhhZkmQ-IAmb_smTrk7n'), (178, 2, 'dNMZ-fkZNiA:APA91bEd1Xam4odF-n5aeF3fEJQqCZBBKOQ9tUy_Db2MoU_2bt81KTLTyC0yV5QpdH5h11O7rYPizm74_4ZxPES0c867cZAMzoDo9-7XYhUb3ZYa32jHU9E4QvZrHMfyY94WTQB7jniz'), (200, 2, 'duF_VylouFk:APA91bHTmUO9we3gAAuBF9XXOtLzZNgnWFlYzyWgshBtpEbZbgdkBQfcwgtNsfpje8BhKczxqD38Dr9X74mmbGyU-V-CFqtsn3VtorJdBr3w7FGqr1wcV4zKoOlveFXRoOARaTv79PH0'), (305, 2, 'dvf3Au3qdVw:APA91bGLVFNFUUTjOEHgo5UeSBLifrMlhs0QpSsgcxCJaPMp5BNlcR8rinnMR1r8oYjTWIncNZ378g0ulyW5XyIkBwOA4rdDabf17Zg4_4tLw52xNfkXj2fhEkGpCYt9fXW0thGONRBn'), (280, 2, 'dZpS10iVJCc:APA91bE1iMW_0AyDmUHINv1o28NFhzwh7t0mL2LNxz2--ZDar4ZTninCZv8Yu7xgcLuMBO98iRof4IyC8xREzsSz-DJA8UoPtmzKOc42YZ2C5GTAl9q6ezuJAtbGIDd1NZIPbxYp7_Pg'), (241, 2, 'dZpS10iVJCc:APA91bErH2hPInJAnP2kuZXMrg-5wI-AqgjS2a0sEjnQDiOG57JkV6q8-WdeISF6wSA_IkG_O8NoWKCBWc-WXvzCK4tsCXk6PnptbWssdvcChY6mrdVjhs_KMCjmTwSIimt4tEBvHmuI'), (331, 2, 'e8T4bSpKdk-FnayTfFp-4b:APA91bFpF8ACWVvXRlz-EbAFvZZDnWI4IhmKl68fagnvo6I6i6dv9-3EJodfGq7fBCMyu8_h_EpVUyOubkdIULhEn01JHC8lqYY3QhRP1f4MVHT8wQp4GesDfmB2_poPp6US6S7WONsi'), (300, 2, 'eGD8fwBzKdY:APA91bE1N0qtAIttxci6S3asR_v1UqnY3Un_aoWNiWODpjA6z9nJ5SpUht8856036exCkIQY8zvC1pBrBfUR5DUhc7QerZx9WFNPMYW8GpD4F_xpLjKo9GBSjEbRjgqypocAxO50zyN7'), (170, 2, 'egUgWOzYoh0:APA91bHy_ogy1XVzv2fAHDmC8RIuaPNoI49mNDLZWmBoDr3mNDTcTQdBFnXV1EKERnjWgh6PrvBxFDfp8kPUq-N1l74fPh2uhzCYiFjT3maXo15HDm4-mer3HuE4VXRgrMa7Voe26P78'), (204, 2, 'eHN24aPXXb4:APA91bGA9LUiXmsPc3vmoxFD1U0RA7na9mexDQn9PS3N2cP-ToR_zmbYvG_IQelJw9WKIO3wkzL2AEG_2U1-13Qn9j4BR95n7CWFi_Mw6f-J_q1TBIlcyqJarTYyxIh8n_B3Mgdhh69u'), (161, 2, 'eMNXJQ0KbsA:APA91bEo4wMUoC13E2deGbuSD43EuaCoWarQVS4Bbl1Gtxqle8wUkTB0U1xeaxqtf4-vC5UuUp8RDZJOA4UVV5kiKPyHYUDc5iRODwXWYFXOYmS2iDKyIy6ksJPmMDk27Jq4Y8sSk50x'), (155, 2, 'eNBD_AAenWw:APA91bHr7m28C5l9JuS8vk8c8phsskoGLIJ-TfaGVOiFGZT_qb0gMmnzwGU6Yk62KAlcdOy5uwfFkKHmIZyvgI8HizmZ6x3RuEffKsnEOcp-PtNcHA5kYU0E2tx69YRWXu8MV-55o9Yh'), (160, 2, 'eNpRc9A4WQE:APA91bHDn9iiK8ejdfY-zF_Yyx3Tgnbn1diTJJkEk8Lg3NB9E5JirbnJ1xs0GQ6pLTtM_bwFc64X_Uurx9DqMH4-fhcXv2KncMNc9CV6n_Fll8LHkCJyFenZOsEwBh_AzmqA6QtFvHAX'), (202, 2, 'eqHcZKEroRg:APA91bHVl_rzkT6qVSSalZc0YXumOBEIu_4VPHk2EWivZihWiRgaaQ7MTXlyjOoTWf5cGXG7KCj9gYq9-gWdVEGQYELIPxT4fXFdokZ2PKxkFHu11HQpO0YmHTUiO9XIdkW0aO2m7tDy'), (293, 2, 'eQLBIoJKVPo:APA91bFjAATm5HnxOl41d20bfzGFBSgkU_o7HoU2B_KqIOPvP5zBu9UMHA2KondnjKn_h9gonRIioGlryfX6qA-DviMi5wozqX_2Bonbh27NQG-TBOmPZKImeYIJ4pwjGXd3lq-4se46'), (121, 2, 'ew1JGnBiCAg:APA91bGH1DM23BEav8aSUd_YX8jauEFsSLftVO7FL3j9VW3lrxMbzDHRArL6uH4z1CjA4KaC_USSqVV4Z7v0ZUJDs-lQkHA44hNzaRoj_e9WNNZHgIQ9nE48qAad0B639jaT-HUXwTwC'), (245, 2, 'eYQjaw0nePI:APA91bFVXt4hvQcA7AluzmGPesriLcCbrMgAZcqAv2TbQ0M7uqBFjWZQURrL__-a3VG_7ljqjcVX5mzeCJYcornDlE1yEYIylHG2h5MUO3OYXJsrIH5xNByKCyIlwsFAvY6wconpN21-'), (165, 2, 'eZe7h4nJ7eg:APA91bEYGQUfrcISorBnvzKBxIutzm66BRpqmRRsIWtEhle6sUG-8ZmSwtnICy_zCKbR-zDGYd0h5fFznIkL3Kt2N2fD3_aCCQf2_OTqgUfD8UHB3KqLoS2jBBWoTL0DMRB15QlWTZXV'), (242, 2, 'falNOjQjREI:APA91bE6QcJgUA30ZqNfa569xjl8SlmYs-4UU-wGtS9ceLFXrWqMrcz98puFxBUGGoDN3UgcsLNIWQWQgIgTRA1PgADwK78BuOyaJ_r7PyYlP7COT0XUUp2_jE4kR7jY3A7aU7sFC6Ax'), (130, 2, 'fC7huI8eLn8:APA91bEcFpN-5u_xVW07j60vmX1QxKR0n6UZAdI-RRi81iynH0acyIz5L_7JefF9MNYqfBCGvWPscLRFxghAV2dYu6PyGTYDce6X7qmcoln6KzvqvbmusgfGdv2OXL37XAOhZn4s7d0P'), (322, 2, 'fdigzWdrydE:APA91bGETyqoB7GVEEqASEqJx-h-9AQbl54Fh-G9v6B0xqjas7HNL5SIRNunOHcwPSm9DO6CExKH1l6b3VjjaxMNRaI3-bINJTAa7YgWk_pg8W3NX0Ffxw4WBjlJ1JIFvWV3jJMRy6LH'), (321, 2, 'fi_C1i8GeHU:APA91bE2FggLgQeixqBWRZp6rwt7UIXb3EofAURXD0ziEExFeY7QR0Rf3qV__B2sIOvVUvLIh1pqG1eVWxbvN9lsHmqsqYgLObjQRo1jNG605L3X3T3dqNpioNgrTXHq3g3EGcY3JXf_'), (250, 2, 'fJNAqYpq-ss:APA91bFAT5Sh4twOU9sB5DMYihWqCmVADsdasI3EJDd9BncADOpwQu3fS73o8jw9-K_dFHXrPyNWQmHDaIP6RoTwczH2G2p__IkLd-EsMVOzzEmwfvmRax8Uz0ZqtC3D4BYve5z9MVxS'), (142, 2, 'fJXmC2wUMc0:APA91bFOctx84QFeWE1q2WnVHHkFPEJjmruwIr-XsOUqgWxgbCe_KsnekzxJ_MpuBTFdmMTucBa5R8rnfSjwapqMlChGkimXgMuM7EvKZIGgLguhjn9DIWf35KHICAeEIc4FV83leGh7'), (181, 2, 'fPpA2IFh4sA:APA91bGDkLv1gGueQ5vpgkylZBpfQn4DhCqwav9ULyZPj0ObV7LGJv7e8YeQg8TuCXuqjpfHW1dyUBampTaTW0WxY4O-8eQK-T-egbkNsqRbz80bCwmYHbFbZa5EoppCGGlJV0cV-DWL'), (301, 2, 'fUNjUkVHCsk:APA91bFfkJa5X2-wWoCjgS9tROD89fYM-_Kg3a02_juhWgQddaLnfGEID1O8ThL1FJptw7iV_5bgLrCrcGjsteFvcbO3u-qW05Zhz3GTvVl4zaKXQscIhZG6PG5D_B65OM0xCVONgsh_'), (228, 2, 'fXK0m8q4-ZQ:APA91bFQIrYxqFP-dqL21PE6FWN0WiAUqZ1-n5J2GHAEonbnm-3_v22J0joybk3cTudg0zn3cRpIphcLJu6LwOlnVMJ8175h3M3s9io_k1y9qqIraeiHXE8kwtrbjX0FkkpYPr7ozGBq'), (254, 3, 'cDWky4QQqSo:APA91bFvxptwUqgv8rWofW97xx8tfzTfC9-Z3-6Bt-m6cuITUU9vAnA8PNJ2-oQ8MpB0YI9pEGkeiFWYFon5i920JlVPk5r_V1RDLgVcqUCMS-JgZUj58Z0kAF19K5hWCAWFlR92ykCN'), (213, 3, 'cFvsGS8sRQE:APA91bGFYKdGYM6XPy5jUHmCX2blbRVm5sV2ok0DbCUtv23aQScCp7xsZTXw59_7CXIL7vvbiarunP6rmljcK7f55dGsUyguI9CsZwBwtPvP-LNNY4XgYW8Src6nEk463OCCQpFoWmAI'), (329, 3, 'd-mkSGI5_04:APA91bHwK8kTCoBu3D8iO8FHztfrpCcKDWmd4ayKFVU5F5F0Drbu6WAZn7OVKRfrVWhy8xyki5_naHUbEvzfoVym4QO0BFvxFN9RzhsetECgu-5JAgOsCp0lLADjJ5jpfcZN0-1Y4Ixy'), (217, 3, 'dhhRdxLE6ZA:APA91bEpOAMM9v636JJYTWNe14UJghBL3Ve5Jy9gy_M0CdS9TzBHUp1RNpQmWnV7BgbJG1r6mPCwUH5uDsqhr216tu7XiasmNtnNiLgWVNH7c5ZmE-6RAcynWwtjGiJjEbI1MxTuQiGt'), (327, 3, 'e8T4bSpKdk-FnayTfFp-4b:APA91bFpF8ACWVvXRlz-EbAFvZZDnWI4IhmKl68fagnvo6I6i6dv9-3EJodfGq7fBCMyu8_h_EpVUyOubkdIULhEn01JHC8lqYY3QhRP1f4MVHT8wQp4GesDfmB2_poPp6US6S7WONsi'), (191, 3, 'eNBD_AAenWw:APA91bHr7m28C5l9JuS8vk8c8phsskoGLIJ-TfaGVOiFGZT_qb0gMmnzwGU6Yk62KAlcdOy5uwfFkKHmIZyvgI8HizmZ6x3RuEffKsnEOcp-PtNcHA5kYU0E2tx69YRWXu8MV-55o9Yh'), (333, 3, 'eNpRc9A4WQE:APA91bHDn9iiK8ejdfY-zF_Yyx3Tgnbn1diTJJkEk8Lg3NB9E5JirbnJ1xs0GQ6pLTtM_bwFc64X_Uurx9DqMH4-fhcXv2KncMNc9CV6n_Fll8LHkCJyFenZOsEwBh_AzmqA6QtFvHAX'), (146, 3, 'fJXmC2wUMc0:APA91bFOctx84QFeWE1q2WnVHHkFPEJjmruwIr-XsOUqgWxgbCe_KsnekzxJ_MpuBTFdmMTucBa5R8rnfSjwapqMlChGkimXgMuM7EvKZIGgLguhjn9DIWf35KHICAeEIc4FV83leGh7'), (220, 3, 'fmdvqoM1soE:APA91bE2bg0x__4xjpuPXy5QMICrG6tKHqH8ejv8IKvvuq2iAu0f-r_N7gH1hmhwU0Hlqak06d5Q0bgPg9rq8iRSQ-QHCSkWC5v-W9F3L9O-MfJs3nwQrAQ0ese0P44ZnlS8A2-BnBd_'), (192, 4, 'dGZf4E4WBB4:APA91bELZZP8_t1HVnn_dNg7XypyNzpOobs_qBm45txOctLUzJrekZsjGVBlLBAf6oFQXQbd2x5tNB056hXNI-B8-5Ht4T2qZ3P7mTMonxdN8_NwHEB4pXqM88uACEMh2ogpTfyiEqw4'), (326, 4, 'e8T4bSpKdk-FnayTfFp-4b:APA91bFpF8ACWVvXRlz-EbAFvZZDnWI4IhmKl68fagnvo6I6i6dv9-3EJodfGq7fBCMyu8_h_EpVUyOubkdIULhEn01JHC8lqYY3QhRP1f4MVHT8wQp4GesDfmB2_poPp6US6S7WONsi'), (162, 4, 'eNBD_AAenWw:APA91bHr7m28C5l9JuS8vk8c8phsskoGLIJ-TfaGVOiFGZT_qb0gMmnzwGU6Yk62KAlcdOy5uwfFkKHmIZyvgI8HizmZ6x3RuEffKsnEOcp-PtNcHA5kYU0E2tx69YRWXu8MV-55o9Yh'), (323, 4, 'fdigzWdrydE:APA91bGETyqoB7GVEEqASEqJx-h-9AQbl54Fh-G9v6B0xqjas7HNL5SIRNunOHcwPSm9DO6CExKH1l6b3VjjaxMNRaI3-bINJTAa7YgWk_pg8W3NX0Ffxw4WBjlJ1JIFvWV3jJMRy6LH'), (271, 4598, 'cDWky4QQqSo:APA91bFvxptwUqgv8rWofW97xx8tfzTfC9-Z3-6Bt-m6cuITUU9vAnA8PNJ2-oQ8MpB0YI9pEGkeiFWYFon5i920JlVPk5r_V1RDLgVcqUCMS-JgZUj58Z0kAF19K5hWCAWFlR92ykCN'), (310, 4598, 'd7DnP3FhxZQ:APA91bEKDUZvjazvHpfTUlHV5OoOt7cdKM0MLIVnJOIzx_oAWto6uTOtmMlJtzfggwqxeE4ZG4YycoST3GTO6R67HvyREI8vXzrAjwS7kt7Blw0DBPJO26FoLv6bM8iqZ6LhhzlY-5PM'), (306, 4598, 'dOy57wdpOak:APA91bGouglz79b5SBJ5EPVkCKOLcH1o3HIOSaN-x39xJZT-VZczWYHzRh4uasymwBhlsmWIKaLeLZ8mmVaE22cnaS1kpdSxkj1TqDI1FZHR1C9t9xnEcvbOAH0nXxQYc5-_oRAjw9Qc'), (313, 4598, 'fBd1T9u2C2k:APA91bESh64lVlYB3-KSaK4dt0zLHSQ1XGgCebmwd_MkkxyOQXFEccS1vdRQDvX9hI5l7RpTQI5acdZEkciyTnbeQ6IkIJVJccQjDBpq49xIRVijogJzjKg5eZKyQcrJnKY78qe_jdUM'), (276, 5774, 'cDWky4QQqSo:APA91bFvxptwUqgv8rWofW97xx8tfzTfC9-Z3-6Bt-m6cuITUU9vAnA8PNJ2-oQ8MpB0YI9pEGkeiFWYFon5i920JlVPk5r_V1RDLgVcqUCMS-JgZUj58Z0kAF19K5hWCAWFlR92ykCN'); DROP TABLE IF EXISTS `Pathology`; CREATE TABLE `Pathology` ( `id` int(11) NOT NULL, `name` varchar(45) NOT NULL, `address` varchar(255) DEFAULT NULL, `phone` varchar(45) DEFAULT NULL, `hours` varchar(255) DEFAULT NULL, `website` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `Pathology` (`id`, `name`, `address`, `phone`, `hours`, `website`) VALUES (1, 'Dorevitch Pathology', '66 Darebin Street, HEIDELBERG VIC 3084', '(03) 9457 2200', 'Monday Closed\nTuesday 12-5pm\nWednesday 9am-1pm\nThursday 9am-1pm\nFriday 9am-1pm\nSaturday Closed\nSunday Closed ', 'https://www.dorevitch.com.au/patients/find-a-collection-centre/'), (2, 'Melbourne Pathology', NULL, NULL, NULL, 'https://www.mps.com.au/locations/'), (3, 'Austin Pathology', 'Level 6, Harold Stokes Building, Austin Hospital Studley Road, Heidelberg, VIC 3084', '9496-3100 (24/7)', NULL, 'https://www.austinpathology.org.au'), (4, 'Australian Clinical Labs', NULL, NULL, NULL, 'https://www.clinicallabs.com.au'); DROP TABLE IF EXISTS `Radiology`; CREATE TABLE `Radiology` ( `id` int(11) NOT NULL, `name` varchar(45) NOT NULL, `address` varchar(255) DEFAULT NULL, `phone` varchar(45) DEFAULT NULL, `fax` varchar(45) DEFAULT NULL, `hours` varchar(255) DEFAULT NULL, `email` varchar(45) DEFAULT NULL, `website` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `Radiology` (`id`, `name`, `address`, `phone`, `fax`, `hours`, `email`, `website`) VALUES (1, 'I-MED ', 'Level 1/10 Martin St, Heidelberg VIC 3084', '(03) 9450 1800', '(03) 9450 1888', 'Monday - Friday, 8:30am - 5:30pm', NULL, 'https://i-med.com.au/clinics/clinic/Heidelberg'), (2, 'I-MED Warringal Radiology', 'Warringal Medical Centre Level 2, 214 Burgundy Street Heidelberg VIC 3084', '(03) 9450 2100', '(03) 9450 2114', 'Monday - Friday, 8:30am - 5:30pm', NULL, 'https://i-med.com.au/clinics/clinic/Warringal'), (3, 'Austin Nuclear Medicine and PET', 'Level 1, Harold Stoke Building, 145 Studley Road', '(03) 9496 5718', '(03) 9457 6605', NULL, 'enquiries.miat@austin.org.au', 'https://www.austin.org.au/MIaT_Contact_Us/'), (4, 'Austin Radiology - Repatriation Hospital', '300 Waterdale Road, Ivanhoe Victoria 3079', '(03) 9496 5000', '(03) 9496 2541', NULL, 'enquiries.radiology@austin.org.au', 'https://www.austin.org.au/heidelberg-repatriation-hospital'); DROP TABLE IF EXISTS `Resource`; CREATE TABLE `Resource` ( `id` int(11) NOT NULL, `uid` int(11) NOT NULL, `name` varchar(45) NOT NULL, `date` date NOT NULL, `content` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), KEY `uid` (`uid`), CONSTRAINT `Resource_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `User` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `Resource` (`id`, `uid`, `name`, `date`, `content`) VALUES (1, 4598, 'Colorectal cancer', '2020-09-30', 'https://www.eviq.org.au/medical-oncology/colorectal/adjuvant-and-neoadjuvant/637-colorectal-adjuvant-folfox6-modified-fluoro'); -- (2, 2, 'bilibili', '2020-09-30', 'https://www.bilibili.com/'), -- (3, 1, 'bilibili', '2020-09-30', 'https://www.bilibili.com/'), -- (4, 3, 'test', '2020-09-30', 'testtesttest'), -- (5, 3, 'test', '2020-09-30', 'https://www.apple.com/au/'), -- (6, 2, 'test0929', '2020-09-30', '123456789'); DROP TABLE IF EXISTS `ResourceFile`; CREATE TABLE `ResourceFile` ( `id` int(11) NOT NULL, `uid` int(11) NOT NULL, `title` varchar(255) NOT NULL, `date` date NOT NULL, `link` varchar(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `link` (`link`), KEY `uid` (`uid`), CONSTRAINT `ResourceFile_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `User` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; DROP TABLE IF EXISTS `User`; CREATE TABLE `User` ( `id` int(11) NOT NULL, `password` varchar(255) DEFAULT NULL, `firstname` varchar(45) NOT NULL, `middlename` varchar(45) DEFAULT NULL, `surname` varchar(45) NOT NULL, `dob` date NOT NULL, `email` varchar(255) NOT NULL, `street` varchar(45) DEFAULT NULL, `suburb` varchar(45) DEFAULT NULL, `state` varchar(45) DEFAULT NULL, `token` varchar(255) DEFAULT NULL, `token_valid_from` datetime DEFAULT NULL, `token_expire_date` datetime DEFAULT NULL, `role` enum('PATIENT','ADMIN') DEFAULT 'PATIENT', PRIMARY KEY (`id`), UNIQUE KEY `email` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `User` (`id`, `password`, `firstname`, `middlename`, `surname`, `dob`, `email`, `street`, `suburb`, `state`, `token`, `token_valid_from`, `token_expire_date`, `role`) VALUES (1, '123', 'Alex', NULL, 'Williamson', '1996-05-01', 'williamson@example.com', '97 Masthead Drive', 'ROCKHAMPTON', 'QLD', 'eyJhbGciOiJIUzUxMiJ9.eyJyb2xlIjoiUEFUSUVOVCIsImp0aSI6ImlnZDIxZHQ2ZjFnczNnNDRlMXM3dWo3M29tIiwiZXhwIjoxNjAwOTE5ODYyLCJpYXQiOjE2MDA4MzM0NjIsInN1YiI6IjEifQ.QMGZ0M-9AxoOJzHJQ0i9BB0bE-aYUcY1P6YgfK3seccW2EZ6JLdz9-vqG3IiwuEixZqr7jCVXnXGxE7qdHDoQQ', '2020-09-23 03:57:42', '2020-09-24 03:57:42', 'PATIENT'), (2, '123', 'Matthew', NULL, 'Chen', '1994-09-08', '123@qq.com', 'Unimelb Drive', 'Parkville', 'VIC', 'eyJhbGciOiJIUzUxMiJ9.eyJyb2xlIjoiUEFUSUVOVCIsImp0aSI6Ijk1dm1zOHZtcjY5ZGNiZnZ2ZmhnM2cwZDIiLCJleHAiOjE2MDE1NDYzMDUsImlhdCI6MTYwMTQ1OTkwNSwic3ViIjoiMiJ9.Rk6jg0P7dnkTL-Ylky2V9S3yJCZTegODTkqOwv2HXI5MhZF-MXgxlbFPuBqLGPLgjtMQEMsmpVac102P-nFFlg', '2020-09-30 09:58:25', '2020-10-01 09:58:25', 'PATIENT'), (3, '123', 'client', NULL, 'client', '1994-09-08', '1234@qq.com', 'Unimelb Drive', 'Parkville', 'VIC', 'eyJhbGciOiJIUzUxMiJ9.eyJyb2xlIjoiUEFUSUVOVCIsImp0aSI6ImJqNWdiNnRrM3I5ZHU3MTM0aHQ3MHA4aWE4IiwiZXhwIjoxNjAxNDQyNzc0LCJpYXQiOjE2MDEzNTYzNzQsInN1YiI6IjMifQ.RFefVhNe7skLSlklLSDeS8H5FlVnLzMcxWfYUr316OuaxvbOEt6g0MTvMojnMR1d09ijMjH5hDxojeqqYC-T2g', '2020-09-29 05:12:54', '2020-09-30 05:12:54', 'PATIENT'), (4, '1234', 'user4', NULL, 'wombat', '2020-09-07', 'user4@qq.com', 'Unimelb Drive', 'Parkville', 'VIC', 'eyJhbGciOiJIUzUxMiJ9.eyJyb2xlIjoiUEFUSUVOVCIsImp0aSI6ImR0YzQ1cnZnamlyMG10Mm43Z2pwcGcza29iIiwiZXhwIjoxNjAxMzE0NjcwLCJpYXQiOjE2MDEyMjgyNzAsInN1YiI6IjQifQ.W3bybFCxt8KF1zqOwOmUbthOZwkSCb94qKUtgcrre3tYQA8f_8SU-S39XnvhkjIT7d7wyFkPYvHgYgLmQJxxww', '2020-09-27 17:37:50', '2020-09-28 17:37:50', 'PATIENT'), (4598, 'Point21', 'Susan', NULL, 'Pickering', '1981-07-02', 'suepickering81@hotmail.com', '6 Crowe Court', 'Eltham', 'VIC', 'eyJhbGciOiJIUzUxMiJ9.eyJyb2xlIjoiUEFUSUVOVCIsImp0aSI6InB0bzE4OTBrOGVkcHA0ajNhamloNWRwZnE3IiwiZXhwIjoxNjAxMzYzMDgxLCJpYXQiOjE2MDEyNzY2ODEsInN1YiI6IjQ1OTgifQ.6S5mQX1Dvv6q47-s9tZyS9q1k57tv6C0Z2Aas_x_wS7RDR_lzRUWScJ5FOh22x_iL_u8HpAxdHnSMtz__e48ow', '2020-09-28 07:04:41', '2020-09-29 07:04:41', 'PATIENT'), (5774, 'susan', 'Christopher', NULL, 'Smith', '1980-12-09', 'cwsmith190@gmail.com', '6 Crowe Court', 'Eltham', 'VIC', 'eyJhbGciOiJIUzUxMiJ9.eyJyb2xlIjoiUEFUSUVOVCIsImp0aSI6ImliaW1mM2loaDQ1azk0dm9wZXIxaWF2OGIiLCJleHAiOjE2MDA0MjExNTgsImlhdCI6MTYwMDMzNDc1OCwic3ViIjoiNTc3NCJ9.PNaMWwlWrgxNY4GV4_kQf26LBkIRO5GdC2koZq4oG6IQWhsKJcUZ8-RNWemg15p4nrgyo9DXr1yk9f5TurSnIw', '2020-09-21 06:14:32', '2020-09-18 09:25:58', 'PATIENT'); -- 2020-09-30 12:36:01
true
314182c04ad5d657145641a728874e5229e44b68
SQL
StephanGrochowina/footballprediction
/football-prediction-backend/sql/model/poisson/queries/determine_estimated_total_goals_by_odds.sql
UTF-8
2,527
4.0625
4
[]
no_license
-- Odds: (1.92, 2.08) SELECT matching_total_goals_id, threshold, expected_total_goals, probability_less_than_threshold, probability_greater_than_threshold, odd_less_than_threshold, odd_greater_than_threshold, sqrt(power(odd_less_than_threshold - 1.92, 2) + power(odd_greater_than_threshold - 2.08, 2)) as proximity FROM `fp_model_poisson`.`matching_total_goals_p_threshold` m where odd_less_than_threshold between 1.87 and 1.97 and odd_greater_than_threshold between 2.03 and 2.13 order by sqrt(power(odd_less_than_threshold - 1.92, 2) + power(odd_greater_than_threshold - 2.08, 2)) limit 1 ; -- Determine estimated total goals by odd group and threshold SELECT round(min(expected_total_goals), 2) as minimum, avg(expected_total_goals) as averageUnrounded, round(avg(expected_total_goals), 2) as average, round(max(expected_total_goals), 2) as maximum, count(*) as size, round(avg(probability_less_than_threshold), 13) as probability_less_than_threshold, round(avg(probability_greater_than_threshold), 13) as probability_greater_than_threshold, round(avg(probability_less_than_threshold), 13) + round(avg(probability_greater_than_threshold), 13) as checksum, proximity as proximity, round(exp(proximity * count(*) * -2.564664719) , 13) as confidentiality FROM ( SELECT expected_total_goals, probability_less_than_threshold, probability_greater_than_threshold, round(sqrt(power(odd_less_than_threshold - 1.92, 2) + power(odd_greater_than_threshold - 2.08, 2)), 4) as proximity FROM `fp_model_poisson`.`matching_total_goals_p_threshold` m WHERE threshold = 2.5 -- and odd_less_than_threshold between 1.87 and 1.97 -- and odd_greater_than_threshold between 2.03 and 2.13 ) AS PreSelectedTotalGoals GROUP BY proximity -- having size > 1 ORDER BY proximity LIMIT 1 ;
true
5a6a2c6d9d7032c6442bec64235af93564233687
SQL
nowksu/DataBase
/func_ex4.sql
UTF-8
325
2.71875
3
[]
no_license
SELECT empno, ename, mgr, CASE WHEN mgr IS NULL THEN '0000' WHEN SUBSTR( mgr, 1, 2 ) = '75' THEN '5555' WHEN SUBSTR( mgr, 1, 2 ) = '76' THEN '6666' WHEN SUBSTR( mgr, 1, 2 ) = '77' THEN '7777' WHEN SUBSTR( mgr, 1, 2 ) = '78' THEN '8888' ELSE TO_CHAR( mgr ) END AS CHG_MG FROM emp;
true
2d3a642f5aee9013e1067fd0c215ead07c0322a9
SQL
phoenix110/works2
/modules/core/db/update/postgres/17/170705-1-createStockItem.sql
UTF-8
504
2.5625
3
[]
no_license
create table WORKS_STOCK_ITEM ( ID uuid, VERSION integer not null, CREATE_TS timestamp, CREATED_BY varchar(50), UPDATE_TS timestamp, UPDATED_BY varchar(50), DELETE_TS timestamp, DELETED_BY varchar(50), DTYPE varchar(31), -- CODE varchar(30) not null, DESCRIPTION varchar(100), REORDER decimal(19, 2) not null, MAX_STOCK decimal(19, 2) not null, UNIT varchar(50) not null, CURRENT_STATUS varchar(50) not null, -- primary key (ID) );
true
85fef114bd1e6b1c6f261f68ee3fc9b779360414
SQL
xingzhixi/SocialSemanticServer
/sss/src/main/resources/conf/sss_schema_upgrade_6.0.0_6.0.1.sql
UTF-8
5,648
3.234375
3
[ "Apache-2.0" ]
permissive
ALTER TABLE `sss`.`activityentities` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`categoryass` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`circleentities` DROP FOREIGN KEY `entityIdFKcircleentities`; ALTER TABLE `sss`.`circleentities` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`circleentities` ADD CONSTRAINT `entityIdFKcircleentities` FOREIGN KEY (`entityId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`collentrypos` DROP FOREIGN KEY `collEntryIdFKcollentrypos`; ALTER TABLE `sss`.`collentrypos` CHANGE COLUMN `entryId` `entryId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`collentrypos` ADD CONSTRAINT `collEntryIdFKcollentrypos` FOREIGN KEY (`entryId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`comment` CHANGE COLUMN `commentContent` `commentContent` VARCHAR(1000) NOT NULL ; ALTER TABLE `sss`.`comments` DROP FOREIGN KEY `entityIdFKcomments`; ALTER TABLE `sss`.`comments` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`comments` ADD CONSTRAINT `entityIdFKcomments` FOREIGN KEY (`entityId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`disc` DROP FOREIGN KEY `entityIdFKdisc`; ALTER TABLE `sss`.`disc` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`disc` ADD CONSTRAINT `entityIdFKdisc` FOREIGN KEY (`entityId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`entities` DROP FOREIGN KEY `attachedEntityIdFKentities`, DROP FOREIGN KEY `entityIdFKentities`; ALTER TABLE `sss`.`entities` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL , CHANGE COLUMN `attachedEntityId` `attachedEntityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`entities` ADD CONSTRAINT `attachedEntityIdFKentities` FOREIGN KEY (`attachedEntityId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, ADD CONSTRAINT `entityIdFKentities` FOREIGN KEY (`entityId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`entity` CHANGE COLUMN `id` `id` VARCHAR(255) NOT NULL , CHANGE COLUMN `label` `label` VARCHAR(255) NOT NULL , CHANGE COLUMN `description` `description` VARCHAR(1000) NOT NULL ; ALTER TABLE `sss`.`evernotenote` DROP FOREIGN KEY `notebookIdFKevernotenote`, DROP FOREIGN KEY `noteIdFKevernotenote`; ALTER TABLE `sss`.`evernotenote` CHANGE COLUMN `noteId` `noteId` VARCHAR(255) NOT NULL , CHANGE COLUMN `notebookId` `notebookId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`evernotenote` ADD CONSTRAINT `notebookIdFKevernotenote` FOREIGN KEY (`notebookId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, ADD CONSTRAINT `noteIdFKevernotenote` FOREIGN KEY (`noteId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`evernoteresource` DROP FOREIGN KEY `entityIdFKevernoteresource`, DROP FOREIGN KEY `noteIdFKevernoteresource`; ALTER TABLE `sss`.`evernoteresource` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL , CHANGE COLUMN `noteId` `noteId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`evernoteresource` ADD CONSTRAINT `entityIdFKevernoteresource` FOREIGN KEY (`entityId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, ADD CONSTRAINT `noteIdFKevernoteresource` FOREIGN KEY (`noteId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`files` DROP FOREIGN KEY `entityIdFKfiles`, DROP FOREIGN KEY `fileIdFKfiles`; ALTER TABLE `sss`.`files` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL , CHANGE COLUMN `fileId` `fileId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`files` ADD CONSTRAINT `entityIdFKfiles` FOREIGN KEY (`entityId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, ADD CONSTRAINT `fileIdFKfiles` FOREIGN KEY (`fileId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`flags` DROP FOREIGN KEY `entityId`; ALTER TABLE `sss`.`flags` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`flags` ADD CONSTRAINT `entityId` FOREIGN KEY (`entityId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`learnepentity` DROP FOREIGN KEY `entityIdFKlearnepentity`; ALTER TABLE `sss`.`learnepentity` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`learnepentity` ADD CONSTRAINT `entityIdFKlearnepentity` FOREIGN KEY (`entityId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`locations` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`ratingass` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`tagass` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`thumbnails` DROP FOREIGN KEY `entityIdFKthumbnails`; ALTER TABLE `sss`.`thumbnails` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL ; ALTER TABLE `sss`.`thumbnails` ADD CONSTRAINT `entityIdFKthumbnails` FOREIGN KEY (`entityId`) REFERENCES `sss`.`entity` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; ALTER TABLE `sss`.`ues` CHANGE COLUMN `entityId` `entityId` VARCHAR(255) NOT NULL , CHANGE COLUMN `content` `content` VARCHAR(100) NOT NULL ;
true
657af44111c250046ba3239d1b46e850956c7c61
SQL
DBRisinajumi/d2company
/data/tables.sql
UTF-8
4,783
3.359375
3
[ "MIT" ]
permissive
/* SQLyog Ultimate v11.24 (32 bit) MySQL - 5.5.29-MariaDB : Database - p3_02 ********************************************************************* */ /*!40101 SET NAMES utf8 */; /*!40101 SET SQL_MODE=''*/; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; CREATE DATABASE /*!32312 IF NOT EXISTS*/`p3_02` /*!40100 DEFAULT CHARACTER SET latin1 */; /*Table structure for table `ccbr_branch` */ DROP TABLE IF EXISTS `ccbr_branch`; CREATE TABLE `ccbr_branch` ( `ccbr_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ccbr_ccmp_id` int(10) unsigned NOT NULL, `ccbr_name` varchar(350) NOT NULL, `ccrb_code` varchar(50) DEFAULT NULL, `ccbr_notes` text, `ccbr_hide` tinyint(3) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`ccbr_id`), KEY `ccbr_ccmp_id` (`ccbr_ccmp_id`), CONSTRAINT `ccbr_branch_ibfk_1` FOREIGN KEY (`ccbr_ccmp_id`) REFERENCES `ccmp_company` (`ccmp_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `ccbr_branch` */ /*Table structure for table `ccgr_group` */ DROP TABLE IF EXISTS `ccgr_group`; CREATE TABLE `ccgr_group` ( `ccgr_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, `ccgr_name` varchar(20) NOT NULL, `ccgr_notes` text, `ccgr_hide` tinyint(3) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`ccgr_id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*Data for the table `ccgr_group` */ insert into `ccgr_group`(`ccgr_id`,`ccgr_name`,`ccgr_notes`,`ccgr_hide`) values (1,'SysComapny',NULL,0),(2,'Gas station',NULL,0); /*Table structure for table `ccmp_company` */ DROP TABLE IF EXISTS `ccmp_company`; CREATE TABLE `ccmp_company` ( `ccmp_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ccmp_name` varchar(200) NOT NULL, `ccmp_ccnt_id` smallint(6) unsigned DEFAULT NULL COMMENT 'contry', `ccmp_registrtion_no` varchar(20) DEFAULT NULL, `ccmp_vat_registrtion_no` varchar(20) DEFAULT NULL, `ccmp_registration_address` varchar(200) DEFAULT NULL, `ccmp_official_address` varchar(200) DEFAULT NULL, `ccmp_statuss` enum('ACTIVE','CLOSED') DEFAULT 'ACTIVE', `ccmp_description` text, PRIMARY KEY (`ccmp_id`), KEY `ccmp_ccnt_id` (`ccmp_ccnt_id`), KEY `ccmp_name` (`ccmp_name`(4)), CONSTRAINT `ccmp_company_ibfk_1` FOREIGN KEY (`ccmp_ccnt_id`) REFERENCES `ccnt_country` (`ccnt_id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*Data for the table `ccmp_company` */ insert into `ccmp_company`(`ccmp_id`,`ccmp_name`,`ccmp_ccnt_id`,`ccmp_registrtion_no`,`ccmp_vat_registrtion_no`,`ccmp_registration_address`,`ccmp_official_address`,`ccmp_statuss`,`ccmp_description`) values (1,'Company 1a',1,'4000333333a','LV400033333a','Brīvības 5, Rīgaa','Brīvības 5, Rīgaa','ACTIVE','Company onea'),(2,'Company 2',2,'400022222','LV400022222','Brīības 1, Rīga, LV-1010','Brīības 1, Rīga, LV-1010','ACTIVE','Piezimes'),(3,'Company3',2,'111111','11111101','Visbijas 5, Rīga','Visbijas 5, Rīga','ACTIVE','nav piezīmes'); /*Table structure for table `ccnt_country` */ DROP TABLE IF EXISTS `ccnt_country`; CREATE TABLE `ccnt_country` ( `ccnt_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `ccnt_name` varchar(200) NOT NULL, `ccnt_code` char(3) CHARACTER SET ascii DEFAULT NULL, PRIMARY KEY (`ccnt_id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*Data for the table `ccnt_country` */ insert into `ccnt_country`(`ccnt_id`,`ccnt_name`,`ccnt_code`) values (1,'Latvija','LV'),(2,'Lietuva','LT'),(3,'Igaunija','EE'); /*Table structure for table `ccxg_company_x_group` */ DROP TABLE IF EXISTS `ccxg_company_x_group`; CREATE TABLE `ccxg_company_x_group` ( `ccxg_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ccxg_ccmp_id` int(10) unsigned NOT NULL, `ccxg_ccgr_id` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`ccxg_id`), KEY `ccxg_ccmp_id` (`ccxg_ccmp_id`), KEY `ccxg_ccgr_id` (`ccxg_ccgr_id`), CONSTRAINT `ccxg_company_x_group_ibfk_1` FOREIGN KEY (`ccxg_ccmp_id`) REFERENCES `ccmp_company` (`ccmp_id`), CONSTRAINT `ccxg_company_x_group_ibfk_2` FOREIGN KEY (`ccxg_ccgr_id`) REFERENCES `ccgr_group` (`ccgr_id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*Data for the table `ccxg_company_x_group` */ insert into `ccxg_company_x_group`(`ccxg_id`,`ccxg_ccmp_id`,`ccxg_ccgr_id`) values (5,1,1); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
true
4b19ec18fdf123304be5c6182933ea0787e4971d
SQL
danielyan2013/sql_homework
/table_creation.sql
UTF-8
806
3.671875
4
[]
no_license
create table departments( dept_no varchar() primary key, dept_name varchar() ); create table employees( emp int primary key, birth_date date, first_name varchar(), last_name varchar(), gender varchar(), hire_date date ); create table dept_emp( foreign key (emp_no) references employees(emp_no), foreign key (dept_no) references departments(dept_no), from_date date, to_date date ); create table dept_managers( foreign key dept_no references departments(dept_no), foreign key emp_no references employees(emp_no), from_date date, to_date date ) create table titles ( foreign key emp_no references employees(emp_no), title varchar(), from_date date, to_date date ) create table salaries( foreign key emp_no references employees(emp_no), salary int, from_date date, to_date date )
true
62db1d6b95c250a8bb2039a3d6cdffbf2041fa96
SQL
camilotobon18/BD_NoSQL
/Cassandra/consultas_cassandra.cql
UTF-8
6,286
2.671875
3
[]
no_license
-- Cliente INSERT INTO cliente(id_cliente, nombre_cliente, apellido_cliente, telefono, direccion, correo, estado_civil, fecha_nacimiento,ciudad) VALUES(1, 'Tatiana', 'Uribe', '46546546', 'CL 021 095 045', 'tatiana@gmail.com', 'soltera', '1995-01-01', 'Medellin'); INSERT INTO cliente(id_cliente, nombre_cliente, apellido_cliente, telefono, direccion, correo, estado_civil, fecha_nacimiento,ciudad) VALUES(2, 'Juan', 'Ortiz', '312156465', 'CL 095 015 045', 'juan@gmail.com', 'divorciado', '1991-01-01', 'Medellin'); INSERT INTO cliente(id_cliente, nombre_cliente, apellido_cliente, telefono, direccion, correo, estado_civil, fecha_nacimiento,ciudad) VALUES (3, 'Carlos', 'Madrid', ' 469654786', 'CQ 010 095 045', 'carlos@gmail.com', 'casado', '1984-07-08', 'Bello'); -- Sedes INSERT INTO sedes(id_sede, nombre_sede, direccion, horario_apertura, horario_cierre, capacidad_aforo, telefono, ciudad) VALUES(1, 'Nuevo Occidente', 'Cl 045 011 021', '7:00:00', '19:00:00',25, '3112525', 'Medellin'); INSERT INTO sedes(id_sede, nombre_sede, direccion, horario_apertura, horario_cierre, capacidad_aforo, telefono, ciudad) VALUES(2, 'Centro', 'CR 065 011 021', '8:00:00', '20:00:00',34, '4012521', 'Envigado'); INSERT INTO sedes(id_sede, nombre_sede, direccion, horario_apertura, horario_cierre, capacidad_aforo, telefono, ciudad) VALUES(3, 'Norte', 'TV 071 011 021', '9:00:00', '21:00:00',31, '4251125', 'Bello'); -- Recurso_humano INSERT INTO recurso_humano(id_empleado, nombre_empleado, telefono, direccion, fecha_nacimiento, id_sede, salario, cargo,ciudad) VALUES(1, 'Fabian Patino', '5645642', 'CQ 02 012 016', '1985-01-02',1,1500000, 'Auxiliar de cocina', 'Medellin'); INSERT INTO recurso_humano(id_empleado, nombre_empleado, telefono, direccion, fecha_nacimiento, id_sede, salario, cargo,ciudad) VALUES(2, 'Anderson Jimenez', '15565545', 'CR 012 065 025', '1984-03-02',2,2500000, 'Cajero', 'Envigado'); INSERT INTO recurso_humano(id_empleado, nombre_empleado, telefono, direccion, fecha_nacimiento, id_sede, salario, cargo,ciudad) VALUES(3, 'Camilo Tobon', '895645455', 'CQ 095 065 025', '1993-03-02',3,1300000, 'Mesero', 'Bello'); -- Menu INSERT INTO menu(id_producto, nombre_producto, precio, especialidad, medida, unidad_medida, impuesto) VALUES(1, 'Hamburguesa BBQ',20000, 'Comida rapida',150, 'grs',0.08); INSERT INTO menu(id_producto, nombre_producto, precio, especialidad, medida, unidad_medida, impuesto) VALUES(2, 'Pastas Napolitana' ,22000, 'Comida italiana',200, 'grs',0.08); INSERT INTO menu(id_producto, nombre_producto, precio, especialidad, medida, unidad_medida, impuesto) VALUES(3, 'Soda Michelada',7000, 'Bebidas',400, 'ml',0.08); INSERT INTO menu(id_producto, nombre_producto, precio, especialidad, medida, unidad_medida, impuesto) VALUES(4, 'Limonada',6000, 'Bebidas',400, 'ml',0.08); -- Facturacion INSERT INTO facturacion(id_factura, id_cliente, id_empleado, id_sede, subtotal,impuesto, total) VALUES(1, 1,3,1,31280,2720,34000); INSERT INTO facturacion(id_factura, id_cliente, id_empleado, id_sede, subtotal,impuesto, total) VALUES(2, 2,2,1,51520,4480,56000); INSERT INTO facturacion(id_factura, id_cliente, id_empleado, id_sede, subtotal,impuesto, total) VALUES(3, 3,2,2,42320,3680,46000); INSERT INTO facturacion(id_factura, id_cliente, id_empleado, id_sede, subtotal,impuesto, total) VALUES(4, 2,1,3,53360,4640,58000); -- Productos_por_factura INSERT INTO productos_por_factura(id_item, id_producto, id_factura, cantidad, precio) VALUES(1, 1,1,1,20000); INSERT INTO productos_por_factura(id_item, id_producto, id_factura, cantidad, precio) VALUES(2, 3,1,2,7000); INSERT INTO productos_por_factura(id_item, id_producto, id_factura, cantidad, precio) VALUES(3, 2,2,2,22000); INSERT INTO productos_por_factura(id_item, id_producto, id_factura, cantidad, precio) VALUES(4, 4,2,2,6000); INSERT INTO productos_por_factura(id_item, id_producto, id_factura, cantidad, precio) VALUES(5, 1,3,2,20000); INSERT INTO productos_por_factura(id_item, id_producto, id_factura, cantidad, precio) VALUES(6, 4,3,1,6000); INSERT INTO productos_por_factura(id_item, id_producto, id_factura, cantidad, precio) VALUES(7, 2,4,2,22000); INSERT INTO productos_por_factura(id_item, id_producto, id_factura, cantidad, precio) VALUES(8, 3,4,2,7000); -- productos vencidos select * from inventario where fecha_caducidad < now() order by fecha_caducidad ASC; -- productos proximos a vencer select * from inventario where fecha_caducidad > CURDATE() order by fecha_caducidad ASC; -- menus mas vendidos select m.nombre_producto, sum(pf.cantidad) as 'cantidad', (sum(pf.cantidad) * sum(pf.precio)) as valor_total from productos_por_factura pf inner join menu m on m.id_producto = pf.id_producto group by m.id_producto order by valor_total DESC; -- los trabajadores que menos venden select rh.nombre_empleado, sum(f.total) as venta from recurso_humano rh inner join facturacion f on rh.id_empleado = f.id_empleado group by rh.id_empleado order by venta ASC; -- los clientes mas frecuentes select c.nombre_cliente, c.apellido_cliente, count(f.id_factura) as numero_de_visitas from cliente c inner join facturacion f on c.id_cliente = f.id_cliente group by c.id_cliente order by numero_de_visitas DESC; -- horarios y dias con mas ventas y con mas visitas -- por dias select dayofweek(fecha_hora) as dia, sum(total) as numero_de_visitas from facturacion group by dia order by numero_de_visitas DESC; -- por horas select HOUR(fecha_hora) as hora, sum(total) as numero_de_visitas from facturacion group by hora order by numero_de_visitas DESC; -- trabajadores por sede select s.nombre_sede, count(rh.id_empleado) as num_empleados from sedes s inner join recurso_humano rh on s.id_sede = rh.id_sede group by s.id_sede order by num_empleados DESC; -- total de salarios por sede select s.nombre_sede, SUM(rh.salario) as salario_sede from sedes s inner join recurso_humano rh on s.id_sede = rh.id_sede group by s.id_sede order by salario_sede DESC; -- ventas por sede y ciudad -- por sede select s.nombre_sede, SUM(f.total) as ventas from sedes s inner join facturacion f on s.id_sede = f.id_sede group by s.id_sede order by ventas DESC; -- por ciudad select s.ciudad, SUM(f.total) as ventas from sedes s inner join facturacion f on s.id_sede = f.id_sede group by s.ciudad order by ventas DESC;
true
58cd5628751c2ec10b3ed7d96b529e8713921cbe
SQL
Enterprise-System-Management-Solutions/Analytics
/dwhnode02/database/procedures/R_USSD_TRANSACTION_TYPE_WISE_SUMMARY.sql
UTF-8
1,006
3.453125
3
[]
no_license
-- -- R_USSD_TRANSACTION_TYPE_WISE_SUMMARY (Procedure) -- CREATE OR REPLACE PROCEDURE DWH_USER.R_USSD_TRANSACTION_TYPE_WISE_SUMMARY IS VDATE_KEY VARCHAR2(64 BYTE); BEGIN SELECT DATE_KEY INTO VDATE_KEY FROM DATE_DIM WHERE TO_CHAR(DATE_VALUE,'RRRRMMDD')=TO_CHAR(SYSDATE-1,'RRRRMMDD'); --EXECUTE IMMEDIATE 'TRUNCATE TABLE PKPI DROP STORAGE'; --EXECUTE IMMEDIATE 'ALTER TABLE PKPI TRUNCATE PARTITION PKPI_||VDATE_KEY DROP STORAGE'; DELETE USSD_TRANSACTION_TYPE_WISE_SUMMARY WHERE DATE_KEY=VDATE_KEY; COMMIT; INSERT INTO USSD_TRANSACTION_TYPE_WISE_SUMMARY SELECT /*+PARALLEL(P,8)*/ /*+PARALLEL(Q,8)*/ P.USSD28_ACCOUNTNAME,Q.TR_TYPE,Q.UNIT_BILL, COUNT(*) SUCCESSOUNT, VDATE_KEY FROM L3_USSD P, USSD_BKASH_DIM Q WHERE USSD28_ACCOUNTNAME='bkashP' AND USSD10_CALLBEGINTIME_KEY=(SELECT DATE_KEY FROM DATE_DIM WHERE DATE_VALUE = TO_DATE(sysdate-1,'DD/MM/RRRR')) AND P.USSD39_LASTSPCONTENT LIKE Q.MSG GROUP BY P.USSD28_ACCOUNTNAME,Q.TR_TYPE,Q.UNIT_BILL; COMMIT; END; /
true
58fcbe8d099b2b0efa8f892609d075a955945315
SQL
SolarNetwork/killbill-easytax-plugin
/src/main/resources/ddl.sql
UTF-8
1,211
3.609375
4
[ "Apache-2.0" ]
permissive
/*! SET default_storage_engine=INNODB */; /* NOTE record_id serial primary key suffers from MySQL bug * https://bugs.mysql.com/bug.php?id=37130 */ SELECT @@global.time_zone, @@session.time_zone; drop table if exists easytax_taxations; create table easytax_taxations ( record_id serial , kb_tenant_id char(36) not null , kb_account_id char(36) not null , kb_invoice_id char(36) not null , kb_invoice_item_ids mediumtext default null , total_tax numeric(15,9) default null , created_date datetime not null , primary key(record_id) ) /*! CHARACTER SET utf8 COLLATE utf8_bin */; create index easytax_taxations_account_invoice_idx on easytax_taxations(kb_account_id, kb_invoice_id); drop table if exists easytax_tax_codes; create table easytax_tax_codes ( record_id serial , kb_tenant_id char(36) not null , tax_zone varchar(36) not null , product_name varchar(255) not null , tax_code varchar(255) not null , tax_rate numeric(15,9) not null , valid_from_date datetime not null , valid_to_date datetime , created_date datetime not null , primary key(record_id) ) /*! CHARACTER SET utf8 COLLATE utf8_bin */; create index easytax_tax_codes_product_idx on easytax_tax_codes(tax_zone, product_name, tax_code);
true
9428af8f8312afde012c30423d526e3fe6b0eb09
SQL
TrellixVulnTeam/demo_L223
/sql/AllInOneFormTypeCount.sql
UTF-8
1,823
3.53125
4
[]
no_license
DECLARE v_tab VARCHAR2(50); v_forms_type VARCHAR(25); v_forms_count INTEGER; forms_cursor SYS_REFCURSOR; BEGIN --one script overview to work in all env. --check if the user is schema owner --select get_oasis_user from dual; --select PM_TABLE_OWNER from dual; --check if table exists SELECT t.tname INTO v_tab from tab t where upper(t.tname) = 'OS_FORM_INTERFACE' and t.tabtype = 'TABLE'; dbms_output.put_line('Table : ' || v_tab); IF v_tab = 'OS_FORM_INTERFACE' THEN --ufe / crystal / Ghostdraft / eloquence OPEN forms_cursor FOR SELECT DECODE(ofi.doc_gen_prd_name, 'ELOQUENCE', 'ELOQUENCE', 'GHOSTDRAFT', 'GHOSTDRAFT', decode(nvl(f.ufe_b, 'N'), 'Y', 'UFE', 'CRYSTAL') ) AS formstype, count(DISTINCT f.form_id) AS formcount FROM os_form f, os_form_interface ofi WHERE f.form_id = ofi.form_id group by DECODE(ofi.doc_gen_prd_name, 'ELOQUENCE', 'ELOQUENCE', 'GHOSTDRAFT', 'GHOSTDRAFT', decode(nvl(f.ufe_b, 'N'), 'Y', 'UFE', 'CRYSTAL') ) ORDER BY 1; ELSE --ufe / crystal OPEN forms_cursor FOR SELECT decode(nvl(f.ufe_b, 'N'), 'Y', 'UFE', 'CRYSTAL') AS formstype, count(f.form_id) AS formcount FROM os_form f group by decode(nvl(f.ufe_b, 'N'), 'Y', 'UFE', 'CRYSTAL') ORDER BY formstype; END IF; LOOP FETCH forms_cursor INTO v_forms_type, v_forms_count; EXIT WHEN forms_cursor%NOTFOUND; dbms_output.put_line(v_forms_type || '-' || v_forms_count); END LOOP; CLOSE forms_cursor; EXCEPTION WHEN NO_DATA_FOUND THEN v_tab := NULL; END; /
true
005527c1a3e23e6fc4d8f65ed95d9c57688a16c4
SQL
rexenpub/rest-framework-core
/src/main/resources/rest-framework.sql
UTF-8
1,979
3.140625
3
[]
no_license
/* Navicat MySQL Data Transfer Source Server : 172.17.2.194 Source Server Version : 50720 Source Host : 172.17.2.194:3306 Source Database : dse Target Server Type : MYSQL Target Server Version : 50720 File Encoding : 65001 Date: 2018-05-16 17:20:15 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for system_operation_log -- ---------------------------- DROP TABLE IF EXISTS `system_operation_log`; CREATE TABLE `system_operation_log` ( `id` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '主键', `user_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '用户主键', `operation_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '操作时间', `client_ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '客户端IP', `module` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '功能模块', `operation_type` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '操作类型', `user_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '用户名', PRIMARY KEY (`id`), KEY `idx_operation_time` (`operation_time`) USING BTREE, KEY `idx_user_name` (`user_name`) USING BTREE, KEY `idx_module` (`module`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统操作日志'; -- ---------------------------- -- Table structure for system_operation_param -- ---------------------------- DROP TABLE IF EXISTS `system_operation_param`; CREATE TABLE `system_operation_param` ( `id` varchar(50) NOT NULL COMMENT '主键', `log_id` varchar(50) NOT NULL COMMENT '日志主键', `request_param` text COMMENT '请求参数', `response_param` text COMMENT '响应结果', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统操作参数记录';
true
100714dcbb296bb74504e1f8730ff00760e822d6
SQL
dabadieng/Ligue1
/creation_base_ligue.sql
UTF-8
971
3.65625
4
[]
no_license
-- -- base de donn�es: 'baseavion' -- create database if not exists baseligue default character set utf8 collate utf8_general_ci; use baseligue; -- -------------------------------------------------------- -- creation des tables set foreign_key_checks =0; -- table equipe drop table if exists equipe; create table equipe ( eq_id int not null auto_increment primary key, eq_nom varchar(50) not null, eq_point int )engine=innodb; -- table rencontre drop table if exists rencontre; create table rencontre ( re_id int not null auto_increment primary key, re_equipe1 int not null, re_equipe2 int not null, re_numero int, re_but1 int, re_but2 int, unique key renc_equipe (re_equipe1,re_equipe2) )engine=innodb; -- contraintes alter table rencontre add constraint cs1 foreign key (re_equipe1) references equipe(eq_id); alter table rencontre add constraint cs2 foreign key (re_equipe2) references equipe(eq_id); set foreign_key_checks = 1; -- jeu de données
true
b990137f563d281bbcb757d6fdbd274cf6fc289a
SQL
andervyd/SQL-course
/SQL course/08 SUBQUERY/Homework_part_08.sql
UTF-8
3,963
4.375
4
[]
no_license
-- task 01: SELECT * FROM employees WHERE LENGTH(first_name) = ( SELECT MAX(LENGTH(first_name)) FROM employees); -- task 02: SELECT * FROM employees WHERE salary > ( SELECT AVG(salary) FROM employees) ORDER BY salary DESC; -- task 03: SELECT MIN(SUM(salary)) FROM employees GROUP BY manager_id; SELECT 'City: ' || city AS city_min_salary FROM locations WHERE location_id IN ( SELECT location_id FROM departments WHERE manager_id IN ( SELECT employee_id FROM employees WHERE salary < ( SELECT MIN(SUM(salary)) FROM employees GROUP BY manager_id))); -- NOT CORRECT ---- -- 01: SELECT 'City: ' || city AS city_min_salary, SUM(salary) FROM employees e JOIN departments d ON (e.department_id = d.department_id) JOIN locations l ON (d.location_id = l.location_id) GROUP BY city; -- 02: SELECT MIN(SUM(salary)) FROM employees e JOIN departments d ON (e.department_id = d.department_id) JOIN locations l ON (d.location_id = l.location_id) GROUP BY city; -- 03: (connect) SELECT 'City: ' || city AS city_min_salary FROM employees e JOIN departments d ON (e.department_id = d.department_id) JOIN locations l ON (d.location_id = l.location_id) GROUP BY city HAVING SUM(salary) = ( SELECT MIN(SUM(salary)) FROM employees e JOIN departments d ON (e.department_id = d.department_id) JOIN locations l ON (d.location_id = l.location_id) GROUP BY city); -- task 04: SELECT job_id FROM jobs WHERE UPPER(job_title) LIKE '%MANAGER'; SELECT salary FROM employees WHERE job_id = ANY( SELECT job_id FROM jobs WHERE UPPER(job_title) LIKE '%MANAGER'); ---- SELECT * FROM employees WHERE manager_id IN( SELECT employee_id FROM employees WHERE salary > 1500); -- task 05: SELECT * FROM employees WHERE department_id IS NULL; ---- SELECT * FROM departments WHERE department_id NOT IN( SELECT DISTINCT department_id FROM employees WHERE department_id IS NOT NULL); -- task 06: SELECT DISTINCT manager_id, first_name FROM employees WHERE manager_id IS NULL; SELECT * FROM employees WHERE employee_id NOT IN( SELECT DISTINCT manager_id FROM employees WHERE manager_id IS NOT NULL); ---- SELECT * FROM employees WHERE manager_id IS NULL; -- task 07: SELECT DISTINCT manager_id FROM employees WHERE manager_id IS NOT NULL; SELECT * FROM employees e WHERE ( SELECT COUNT(*) FROM employees WHERE manager_id = e.manager_id) > 6; -- task 08: SELECT * FROM employees WHERE job_id = ALL( SELECT job_id FROM employees WHERE UPPER(job_id) LIKE '%IT%'); ---- SELECT * FROM employees WHERE department_id = ( SELECT department_id FROM departments WHERE department_name = 'IT'); -- task 09: SELECT * FROM employees WHERE manager_id IN( SELECT employee_id FROM employees WHERE TO_CHAR(hire_date, 'YYYY') = '1995') AND hire_date < TO_DATE('010195', 'DDMMYY'); -- WORK SELECT emp.* FROM employees emp JOIN employees man ON (emp.manager_id = man.employee_id) WHERE TO_CHAR(man.hire_date, 'YYYY') = '1995' AND emp.hire_date < TO_DATE('01-01-2005', 'DD-MM-YYYY'); SELECT emp.* FROM employees emp WHERE TO_CHAR(hire_date, 'YYYY') = '1995'; -- task 10: SELECT * FROM employees e WHERE manager_id IN( SELECT employee_id FROM employees WHERE TO_CHAR(hire_date, 'MON') = 'JAN') AND (SELECT LENGTH(job_title) FROM jobs WHERE job_id = e.job_id) > 5; -- WORK ---- SELECT employee_id, TO_CHAR(hire_date, 'Month') FROM employees WHERE TO_CHAR(hire_date, 'MON') = 'JAN';
true
0a34862f8b2c14eb7b0e0dfb4bf2f0c845ebde5e
SQL
shawnsp/clowdr
/hasura/migrations/1611153226982_more_permission_view_indexes/up.sql
UTF-8
263
2.578125
3
[ "BSD-3-Clause" ]
permissive
CREATE INDEX FlatUserPermission_index_userid_slug on "mat_FlatUserPermission" (user_id, slug); CREATE INDEX FlatUnauthPermission_index_slug on "mat_FlatUnauthPermission" (slug); CREATE INDEX FlatUserPermission_index_userid on "mat_FlatUserPermission" (user_id);
true
fb1121f8fb7c37a2aa8d19d24b1e7b5336d89a37
SQL
jchenedu/Lab10
/Tutorial4.sql
UTF-8
3,019
4.34375
4
[]
no_license
/* Tutorial 4 */ SELECT name FROM world WHERE population > (SELECT population FROM world WHERE name='Russia'); /* For this query, we are outputting all the countries where the population is bigger than Russia from the table 'world' */ SELECT name FROM world WHERE gdp/population > (SELECT gdp/population FROM world WHERE name = 'United Kingdom') AND continent = 'Europe'; /* For this query, we are outputting all the countries in Europe that has a higher GDP than the United Kingdom from the table 'world' */ SELECT name, continent FROM world WHERE continent IN (SELECT continent FROM world WHERE name IN ('Argentina', 'Australia')) ORDER BY name; /*For this query, we are outputting the countries and continent in the continents where Argentina and Australia are in from the table 'world' */ SELECT name, population FROM world WHERE population > (SELECT population FROM world WHERE name = 'Canada') AND population < (SELECT population FROM world WHERE name = 'Poland'); /* For this query, we are outputting the country and population, where it's population is more than Canada, but less than Poland from the table 'world' */ SELECT name, CONCAT(ROUND(100*population/(SELECT population FROM world WHERE name='Germany')),'%') FROM world WHERE continent='Europe' /* For this query, we are outputting all the countries and population as a percentage of Germany's population in Europe from the table 'world' */ SELECT name FROM world WHERE gdp >= ALL(SELECT gdp FROM world WHERE gdp >=0 AND continent = 'Europe') AND continent != 'Europe'; /* For this query, we are outputting all the countries that have a higher GDP than all the countries in Europe and not in Europe from the table 'world' */ SELECT continent, name, area FROM world x WHERE area >= ALL (SELECT area FROM world y WHERE y.continent=x.continent AND area>0); /* For this query, we are outputting the continent, country and area where it is the largest country in that continent from the table 'world' */ SELECT continent, name FROM world x WHERE name <= ALL(SELECT name FROM world y WHERE y.continent = x.continent); /* For this query, we are outputting alphabetically the continent and the country in the continent from the table 'world' */ SELECT name, continent, population FROM world x WHERE 25000000 > ALL(SELECT population FROM world y WHERE x.continent = y.continent AND y.population > 0); /* For this query, we are outputting the country, continent and population where the country has a population greater than 25,000,000 from the table 'world' */ SELECT name, continent FROM world x WHERE population > ALL(SELECT population*3 FROM world y WHERE x.continent = y.continent AND population > 0 AND y.name != x.name); /* For this query, we are outputting the country and continent where the country has three times the amount of population than other countries in their continent from the table 'world' */
true
fc762e1d26d3d5512c46abeef0e6d74a399a071f
SQL
neostreet/poker_session_data
/view_sum_delta.sql
UTF-8
173
2.546875
3
[]
no_license
use poker drop view if exists sum_delta; create view sum_delta as select poker_session_date,sum(delta) as sum_delta from poker_sessions group by poker_session_date; quit
true
eb264e16ae01499c7ec64040650b3413a0c3ae72
SQL
mvardas/Stack-Over-Flowers
/kidspiration/out/production/resources/Tickets.sql
UTF-8
1,627
3.84375
4
[]
no_license
DROP TABLE IF EXISTS kidspiration.OldTickets; DROP TABLE IF EXISTS kidspiration.Tickets; CREATE TABLE kidspiration.Tickets ( `ticket_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `parent_id` INT(10) UNSIGNED NOT NULL, `event_id` INT(10) UNSIGNED NOT NULL, PRIMARY KEY (`ticket_id`), FOREIGN KEY(`parent_id`) REFERENCES kidspiration.Parents(`id`) ON DELETE CASCADE ON UPDATE NO ACTION, FOREIGN KEY (`event_id`) REFERENCES kidspiration.CurrentEvents(`event_id`) ON DELETE CASCADE ON UPDATE NO ACTION ) AUTO_INCREMENT = 1; CREATE TABLE kidspiration.OldTickets ( /* ADDED */ `ticket_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `parent_id` INT(10) UNSIGNED NOT NULL, `event_id` INT(10) UNSIGNED NOT NULL, PRIMARY KEY (`ticket_id`), FOREIGN KEY (`parent_id`) REFERENCES kidspiration.Parents(`id`) ON DELETE CASCADE ON UPDATE NO ACTION, FOREIGN KEY (`event_id`) REFERENCES kidspiration.OldEvents(`event_id`) ON DELETE CASCADE ON UPDATE NO ACTION ) AUTO_INCREMENT = 1; /* Check foreign key constraints */ /* ADDED */ /* testing tickets insertion */ INSERT INTO kidspiration.Tickets(parent_id, event_id) VALUES (1, 1), (1, 2), (2, 2), (2, 3); INSERT INTO kidspiration.OldTickets(parent_id, event_id) VALUES (1, 2), (1, 3), (2, 2), (2, 3); /*SELECT sub.ticket_id, sub.parent_id, sub.event_id, CurrentEvents.title, Providers.businessName, CurrentEvents.date, CurrentEvents.ticket_cost FROM (((SELECT * FROM Tickets WHERE Tickets.parent_id = ?) sub INNER JOIN CurrentEvents ON sub.event_id = CurrentEvents.event_id) INNER JOIN Providers ON CurrentEvents.provider_id = Providers.id) */
true
c971b0276879de85e204a80345939a1a0f5e8ce8
SQL
NiharikaReddyD/assesment
/TableSchemas.sql
UTF-8
2,698
4.25
4
[]
no_license
Create table dim_product( product_id VARCHAR(255) , product_name VARCHAR(255), business_unit VARCHAR(255), file_name VARCHAR(255) ); Create table public.fct_rx_dispense( npi_id VARCHAR(255) , business_unit VARCHAR(255), product_id VARCHAR(255), true_week_end date, rx_packs float(25), file_name VARCHAR(255) ); Create table public.dim_hcp( npi_id VARCHAR(255) , business_unit VARCHAR(255), territory_id VARCHAR(255), target_status VARCHAR(255), date_updated date, file_name VARCHAR(255) ); --4) Write a query that will output the total number of Epinephrine --packs written between January 2018 and June 2018 split by product. select product_id, ROUND(cast(sum(rx_packs) as numeric),2) from public.fct_rx_dispense where business_unit = 'Epinephrine' and true_week_end between '2018-01-01' and '2018-06-01' group by 1; -- 5) How many Auvi-Q packs were dispensed by product each week? Select a.product_name,b.true_week_end,ROUND(cast(sum(b.rx_packs) as numeric),2) as rx_packs from public.dim_product a left join public.fct_rx_dispense b on a.product_id=b.product_id where a.product_name like '%AUVI-Q%' group by 1,2 order by a.product_name,b.true_week_end; -- 6) Examine Auvi-Q products against all Epinephrine products -- in territory V0101 in this same time period. -- How much Auvi-Q is dispensed in this territory, -- how much of that total was dispensed by targeted HCPs? Select 'Auvi-Q' as Product_name,ROUND(cast(sum(rx_packs) as numeric),2) as rx_packs,target_status from( Select product_name, ROUND(cast(sum(rx_packs) as numeric),2) as rx_packs,target_status,territory_id from( Select a.* ,c.target_status,c.territory_id from( Select a.product_name, b.rx_packs ,round(cast(b.npi_id as numeric),0) as npi_id from (Select * from public.dim_product where product_name like '%AUVI-Q%')a join (Select * from public.fct_rx_dispense where true_week_end between '2018-01-01' and '2018-06-01' )b on a.product_id=b.product_id union Select a.product_name, b.rx_packs ,round(cast(b.npi_id as numeric),0) as npi_id from (Select * from public.dim_product where product_name like '%EPINEPHRINE%')a join (Select * from public.fct_rx_dispense where true_week_end between '2018-01-01' and '2018-06-01' )b on a.product_id=b.product_id )a join (Select round(cast(npi_id as numeric),0) as npi_id,business_unit,target_status,territory_id, date_updated from public.dim_hcp where territory_id='V0101') c on a.npi_id=c.npi_id )d group by 1,3,4 order by product_name )e where e.product_name like '%AUVI-Q%' group by 1,3 ;
true
baa23c085b0fdf9baa94dcba35d34f5bca68f422
SQL
thepearldream/Britec
/DB/consultas/ControleAplicacao/Resumo.sql
UTF-8
614
3.21875
3
[]
no_license
select COALESCE(round(sum(i.toneladas), 2), 0) as CargaAcumulada, COALESCE(avg(i.espessura), 0) as EspessuraMedia, COALESCE(round(sum(i.comprimento * i.largura), 2), 0) As AreaTotal, count(*) as QuantidadeCaminhoes, COALESCE(avg(o.ValorPorToneladaFrete), 0) as ValorTonelada, COALESCE(round(sum(i.toneladas) * avg(o.ValorPorToneladaFrete), 2), 0) As ValorTotalBrutoFrete from itemaplicacao i inner join fasedaobra f on f.id = i.Fase_id inner join obra o on o.id = f.Obra_id inner join motorista m on i.Motorista_id = m.id where i.data between '2015-10-08 00:00:00' and '2015-10-08 00:00:00'
true
1398630d9330b70179cecdd074de9e89b5cac010
SQL
bmcclelland/comp440
/sql/data.sql
UTF-8
1,904
3.46875
3
[]
no_license
INSERT INTO Users (username,password,email,firstname,lastname) VALUES ('alice','aaa','alice@email.com', 'Alice', 'A'), ('bob','bbb', 'bob@email.com', 'Bob', 'B'), ('charlie','ccc', 'charlie@email.com', 'Charlie', 'C'), ('david','ddd', 'david@email.com', 'David', 'D'), ('eve','eee','eve@email.com', 'Eve', 'E'); INSERT INTO Follows (leader, follower) VALUES ('alice', 'bob'), ('alice', 'charlie'), ('alice', 'david'), ('alice', 'eve'), ('bob', 'charlie'), ('bob', 'eve'), ('charlie', 'bob'), ('charlie', 'eve'), ('david', 'eve'); INSERT INTO Hobbies (username, hobby) VALUES ('alice', 'movie'), ('alice', 'swimming'), ('bob', 'bowling'), ('bob', 'cooking'), ('david', 'calligraphy'), ('david', 'dancing'), ('david', 'movie'), ('eve', 'hiking'), ('eve', 'swimming'); INSERT INTO Blogs (author, blogdate, subject, description) VALUES ('eve', '2019-09-10', "First post", 'Something'), ('david', '2020-01-01', "2020", 'Happy new year'), ('alice', '2020-01-01', "New year", 'Happy new year'), ('eve', '2020-09-10', "One year later", 'Stuff'), ('alice', '2020-10-10', "Got a dog", "This dog is cute"), ('bob', '2020-10-10', "SQL Tutorial", 'SELECT * FROM table;'); INSERT INTO Tags (blogid,tag) VALUES (3, "New Year"), (3, "2020"), (5, "dogs"), (5, "pets"), (6, "SQL"), (6, "Databases"), (2, "2020"); INSERT INTO Comments (blogid, author, commentdate, sentiment, description) VALUES (1, 'alice', '2019-09-09', 'negative', "Nope"), (3, 'david', '2020-01-01', 'positive', "You too"), (3, 'eve', '2020-01-01', 'positive', "Happy new year"), (5, 'charlie', '2020-11-07', 'negative', "I don't like dogs"), (6, 'charlie', '2020-11-15', 'negative', "Not helpful"), (6, 'alice', '2020-11-20', 'positive', "Very helpful");
true
bb11ae04aa67c9f96fca50e85fe7845508a1762f
SQL
silence-do-good/stress-test-Postgres-and-MySQL
/dump/low/day16/select1854.sql
UTF-8
191
2.703125
3
[]
no_license
SELECT timeStamp, temperature FROM ThermometerObservation WHERE timestamp>'2017-11-15T18:54:00Z' AND timestamp<'2017-11-16T18:54:00Z' AND SENSOR_ID='7a8cf57a_f445_451c_a2f7_78d3fdfb2b9b'
true
06c901aaf83bbb88139ecbe80be4bb14bc8af9d4
SQL
sheli16/Final-Project-SG
/up2measure/db/tn_schema.sql
UTF-8
752
3.109375
3
[]
no_license
DROP DATABASE IF EXISTS topNotchdb; CREATE DATABASE IF NOT EXISTS topNotchdb; USE topNotchdb; DROP TABLE IF EXISTS tblUsers; CREATE TABLE IF NOT EXISTS tblUsers( userId INTEGER PRIMARY KEY AUTO_INCREMENT, username VARCHAR(100) UNIQUE, password VARCHAR(100) ); CREATE TABLE jobs( id INTEGER PRIMARY KEY AUTO_INCREMENT, userId integer(10) NOT NULL DEFAULT '{}', jobNumb integer(10) UNIQUE, jobName varchar(25) NOT NULL DEFAULT '{}', jobAddress varchar(50) NOT NULL DEFAULT '{}', jobMaterial varchar(30) NOT NULL DEFAULT '{}', jobSink varchar(30) NOT NULL DEFAULT '{}', jobEdge varchar(30) NOT NULL DEFAULT '{}', jobSqft integer(10) NOT NULL DEFAULT '{}', jobImage blob -- PRIMARY KEY (id) );
true
a95ac2930d4a70f5f059eaecca69759a8085426f
SQL
MpoyiMmg/Projet-itot
/bdd/db_rdv.sql
UTF-8
8,596
3.078125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.8.5 -- https://www.phpmyadmin.net/ -- -- Hôte : localhost -- Généré le : lun. 22 avr. 2019 à 14:30 -- Version du serveur : 10.1.38-MariaDB -- Version de PHP : 7.3.3 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Base de données : `db_rdv` -- -- -------------------------------------------------------- -- -- Structure de la table `tb_agent` -- CREATE TABLE `tb_agent` ( `idAgent` int(11) NOT NULL, `idEntreprise` int(11) NOT NULL, `nomAgent` varchar(50) NOT NULL, `telephone` int(11) NOT NULL, `email` varchar(50) NOT NULL, `photo` varchar(50) DEFAULT NULL, `idDept` int(11) NOT NULL, `username` varchar(50) NOT NULL, `pwd` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `tb_agent` -- INSERT INTO `tb_agent` (`idAgent`, `idEntreprise`, `nomAgent`, `telephone`, `email`, `photo`, `idDept`, `username`, `pwd`) VALUES (1, 1, 'lola bamsly', 123456, 'lola@gmail.com', 'lola.png', 2, 'lola', 'lola je t\'aime'); -- -------------------------------------------------------- -- -- Structure de la table `tb_client` -- CREATE TABLE `tb_client` ( `idClient` int(11) NOT NULL, `nomClient` varchar(50) NOT NULL, `telephone` int(11) NOT NULL, `email` varchar(50) DEFAULT NULL, `genre` varchar(2) DEFAULT NULL, `age` varchar(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Structure de la table `tb_commentaire_client` -- CREATE TABLE `tb_commentaire_client` ( `idCommentaire` int(11) NOT NULL, `idRdv` int(11) NOT NULL, `contenu` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Structure de la table `tb_departement` -- CREATE TABLE `tb_departement` ( `idDept` int(11) NOT NULL, `nomDept` varchar(50) NOT NULL, `idEntreprise` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `tb_departement` -- INSERT INTO `tb_departement` (`idDept`, `nomDept`, `idEntreprise`) VALUES (2, 'loladepartement', 1); -- -------------------------------------------------------- -- -- Structure de la table `tb_entreprise` -- CREATE TABLE `tb_entreprise` ( `idEntreprise` int(11) NOT NULL, `nomEntreprise` varchar(50) NOT NULL, `secteur` varchar(50) NOT NULL, `telephone` int(11) NOT NULL, `email` varchar(50) NOT NULL, `adresse` varchar(50) NOT NULL, `description` varchar(100) NOT NULL, `logo` varchar(50) NOT NULL, `pays` varchar(50) NOT NULL, `codePostal` varchar(50) NOT NULL, `siteWeb` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `tb_entreprise` -- INSERT INTO `tb_entreprise` (`idEntreprise`, `nomEntreprise`, `secteur`, `telephone`, `email`, `adresse`, `description`, `logo`, `pays`, `codePostal`, `siteWeb`) VALUES (1, 'carole', 'carole', 422526272, 'carole@gmail.com', 'blabla', 'carole est jolie', 'carole.png', 'le pays de carole', 'carole1234', 'carole.com'); -- -------------------------------------------------------- -- -- Structure de la table `tb_horaire` -- CREATE TABLE `tb_horaire` ( `idHoraire` int(11) NOT NULL, `idAgent` int(11) NOT NULL, `jour` varchar(50) NOT NULL, `heureDebut` time NOT NULL, `heureFin` time NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `tb_horaire` -- INSERT INTO `tb_horaire` (`idHoraire`, `idAgent`, `jour`, `heureDebut`, `heureFin`) VALUES (1, 1, '2019-04-19', '12:00:00', '13:00:00'); -- -------------------------------------------------------- -- -- Structure de la table `tb_rdv` -- CREATE TABLE `tb_rdv` ( `idRdv` int(11) NOT NULL, `idClient` int(11) NOT NULL, `idEntreprise` int(11) NOT NULL, `motif` varchar(100) NOT NULL, `date` date NOT NULL, `heure` time NOT NULL, `duree` varchar(25) NOT NULL, `etat` varchar(25) NOT NULL, `commentaire` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Structure de la table `tb_reponse_commentaire` -- CREATE TABLE `tb_reponse_commentaire` ( `idReponse` int(11) NOT NULL, `id_comment` int(11) NOT NULL, `contenu` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Index pour les tables déchargées -- -- -- Index pour la table `tb_agent` -- ALTER TABLE `tb_agent` ADD PRIMARY KEY (`idAgent`), ADD KEY `fk_idDep` (`idDept`), ADD KEY `fk_idEntreprise` (`idEntreprise`); -- -- Index pour la table `tb_client` -- ALTER TABLE `tb_client` ADD PRIMARY KEY (`idClient`); -- -- Index pour la table `tb_commentaire_client` -- ALTER TABLE `tb_commentaire_client` ADD PRIMARY KEY (`idCommentaire`), ADD KEY `fk_commentaire` (`idRdv`); -- -- Index pour la table `tb_departement` -- ALTER TABLE `tb_departement` ADD PRIMARY KEY (`idDept`), ADD KEY `fk_Entreprise` (`idEntreprise`); -- -- Index pour la table `tb_entreprise` -- ALTER TABLE `tb_entreprise` ADD PRIMARY KEY (`idEntreprise`); -- -- Index pour la table `tb_horaire` -- ALTER TABLE `tb_horaire` ADD PRIMARY KEY (`idHoraire`), ADD KEY `fk_idAgent` (`idAgent`); -- -- Index pour la table `tb_rdv` -- ALTER TABLE `tb_rdv` ADD PRIMARY KEY (`idRdv`), ADD KEY `fk_idClient` (`idClient`), ADD KEY `fk_idEnt` (`idEntreprise`); -- -- Index pour la table `tb_reponse_commentaire` -- ALTER TABLE `tb_reponse_commentaire` ADD PRIMARY KEY (`idReponse`), ADD KEY `fk_reponse` (`id_comment`); -- -- AUTO_INCREMENT pour les tables déchargées -- -- -- AUTO_INCREMENT pour la table `tb_agent` -- ALTER TABLE `tb_agent` MODIFY `idAgent` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT pour la table `tb_client` -- ALTER TABLE `tb_client` MODIFY `idClient` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT pour la table `tb_commentaire_client` -- ALTER TABLE `tb_commentaire_client` MODIFY `idCommentaire` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT pour la table `tb_departement` -- ALTER TABLE `tb_departement` MODIFY `idDept` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT pour la table `tb_entreprise` -- ALTER TABLE `tb_entreprise` MODIFY `idEntreprise` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT pour la table `tb_horaire` -- ALTER TABLE `tb_horaire` MODIFY `idHoraire` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT pour la table `tb_rdv` -- ALTER TABLE `tb_rdv` MODIFY `idRdv` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT pour la table `tb_reponse_commentaire` -- ALTER TABLE `tb_reponse_commentaire` MODIFY `idReponse` int(11) NOT NULL AUTO_INCREMENT; -- -- Contraintes pour les tables déchargées -- -- -- Contraintes pour la table `tb_agent` -- ALTER TABLE `tb_agent` ADD CONSTRAINT `fk_idDep` FOREIGN KEY (`idDept`) REFERENCES `tb_departement` (`idDept`), ADD CONSTRAINT `fk_idEntreprise` FOREIGN KEY (`idEntreprise`) REFERENCES `tb_entreprise` (`idEntreprise`); -- -- Contraintes pour la table `tb_commentaire_client` -- ALTER TABLE `tb_commentaire_client` ADD CONSTRAINT `fk_commentaire` FOREIGN KEY (`idRdv`) REFERENCES `tb_rdv` (`idRdv`); -- -- Contraintes pour la table `tb_departement` -- ALTER TABLE `tb_departement` ADD CONSTRAINT `fk_Entreprise` FOREIGN KEY (`idEntreprise`) REFERENCES `tb_entreprise` (`idEntreprise`); -- -- Contraintes pour la table `tb_horaire` -- ALTER TABLE `tb_horaire` ADD CONSTRAINT `fk_idAgent` FOREIGN KEY (`idAgent`) REFERENCES `tb_agent` (`idAgent`); -- -- Contraintes pour la table `tb_rdv` -- ALTER TABLE `tb_rdv` ADD CONSTRAINT `fk_idClient` FOREIGN KEY (`idClient`) REFERENCES `tb_client` (`idClient`), ADD CONSTRAINT `fk_idEnt` FOREIGN KEY (`idEntreprise`) REFERENCES `tb_entreprise` (`idEntreprise`); -- -- Contraintes pour la table `tb_reponse_commentaire` -- ALTER TABLE `tb_reponse_commentaire` ADD CONSTRAINT `fk_reponse` FOREIGN KEY (`id_comment`) REFERENCES `tb_commentaire_client` (`idCommentaire`); COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
7135eccdc45fd3bc59671d107485a3bf76a90948
SQL
pauloholiveira/store
/src/main/resources/schema.sql
UTF-8
256
2.78125
3
[]
no_license
USE `store`; DROP TABLE IF EXISTS `produto`; CREATE TABLE `produto` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nome_descricao` varchar(200) NOT NULL, `valor` decimal(7,2) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
true
82d2a5f24c8e1a3874f963178e695edb46a789ec
SQL
spopp20/MusicProgram
/prisma/migrations/20210724213317_schema_cleanup/migration.sql
UTF-8
2,196
3.546875
4
[]
no_license
/* Warnings: - You are about to drop the `EventSongList` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `SheetMusic` table. If the table is not empty, all the data it contains will be lost. */ -- DropForeignKey ALTER TABLE `EventSongList` DROP FOREIGN KEY `EventSongList_ibfk_1`; -- DropForeignKey ALTER TABLE `EventSongList` DROP FOREIGN KEY `EventSongList_ibfk_2`; -- DropForeignKey ALTER TABLE `SheetMusic` DROP FOREIGN KEY `SheetMusic_ibfk_2`; -- DropForeignKey ALTER TABLE `SheetMusic` DROP FOREIGN KEY `SheetMusic_ibfk_1`; -- AlterTable ALTER TABLE `Event` MODIFY `endDateTime` TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP(0); -- DropTable DROP TABLE `EventSongList`; -- DropTable DROP TABLE `SheetMusic`; -- CreateTable CREATE TABLE `EventSong` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `eventId` INTEGER, `songId` INTEGER, `published` INTEGER NOT NULL DEFAULT 0, `description` TEXT, `createdAt` TIMESTAMP(0) NOT NULL DEFAULT ('0000-00-00 00:00:00'), `updatedAt` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateTable CREATE TABLE `InstrumentSong` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `notes` VARCHAR(128), `words` TEXT, `mimeType` VARCHAR(128), `file` TEXT, `songId` INTEGER, `instrumentId` INTEGER, `createdAt` TIMESTAMP(0) NOT NULL DEFAULT ('0000-00-00 00:00:00'), `updatedAt` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- AddForeignKey ALTER TABLE `EventSong` ADD FOREIGN KEY (`eventId`) REFERENCES `Event`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `EventSong` ADD FOREIGN KEY (`songId`) REFERENCES `Song`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `InstrumentSong` ADD FOREIGN KEY (`songId`) REFERENCES `Song`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `InstrumentSong` ADD FOREIGN KEY (`instrumentId`) REFERENCES `Instrument`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
true
c690534e7880d8373039ba6543c3624410c407a2
SQL
astoeff/Programming-101-Python-2020
/week09/WEDNESDAY/PC/query7.sql
UTF-8
160
3.4375
3
[]
no_license
SELECT AVG(price) as avg_price FROM product JOIN (SELECT * FROM pc UNION ALL SELECT * FROM laptop) AS subq ON product.model = subq.model WHERE maker = 'B'
true
f45ffdba0f9ff68fe91b933ae25a080d9a918db7
SQL
overbrim/postgresql
/general_challenge_solution.sql
UTF-8
380
3
3
[]
no_license
-- SELECT COUNT(amount) -- FROM payment -- WHERE amount > 5; -- SELECT COUNT(*) -- FROM actor -- WHERE first_name LIKE 'P%'; -- SELECT COUNT(DISTINCT(district)) -- FROM address; -- SELECT DISTINCT(district) -- FROM address; -- SELECT COUNT(*) -- FROM film -- WHERE rating = 'R' -- AND replacement_cost BETWEEN 5 AND 15; SELECT COUNT(*) FROM film WHERE title LIKE '%Truman%';
true
b79d6d3666d8ef2422f2918d4aa9053ddb0ec226
SQL
BestSoft/surgalt
/sites/lmsdb.sql
UTF-8
19,266
3.1875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.0.3 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Oct 05, 2013 at 12:02 PM -- Server version: 5.6.11-log -- PHP Version: 5.5.0 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `lmsdb` -- -- -------------------------------------------------------- -- -- Table structure for table `adteacherjournal` -- CREATE TABLE IF NOT EXISTS `adteacherjournal` ( `ClsID` int(11) NOT NULL, `StdID` int(11) NOT NULL, `FldID` int(11) NOT NULL, `Val` varchar(50) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`ClsID`,`StdID`,`FldID`), KEY `FldID` (`FldID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Зөвлөх багшийн журнал'; -- -------------------------------------------------------- -- -- Table structure for table `adteacherjournalfld` -- CREATE TABLE IF NOT EXISTS `adteacherjournalfld` ( `JFldID` int(11) NOT NULL AUTO_INCREMENT, `FldNm` varchar(25) NOT NULL, `ClsID` int(11) NOT NULL, `Prmtr` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`JFldID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Зөвлөх багшийн журналын талбар' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `attendance` -- CREATE TABLE IF NOT EXISTS `attendance` ( `LsnCntID` int(11) NOT NULL, `UsrID` int(11) NOT NULL, `AttSta` int(11) NOT NULL, `InsID` int(11) NOT NULL, `IsnDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`LsnCntID`,`UsrID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Ирц'; -- -------------------------------------------------------- -- -- Table structure for table `calendar` -- CREATE TABLE IF NOT EXISTS `calendar` ( `CalID` int(11) NOT NULL AUTO_INCREMENT, `Title` varchar(25) NOT NULL, `Location` varchar(200) NOT NULL, `Tag` text NOT NULL, `StrtDt` datetime NOT NULL, `EndDt` datetime NOT NULL, `Status` int(11) NOT NULL, `IsDay` tinyint(1) NOT NULL, `TpUsrID` int(11) NOT NULL, `Desc` text NOT NULL, `Rpt` text NOT NULL, `RptEndDt` datetime NOT NULL, `IsPrsnl` tinyint(1) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`CalID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Цаглабар' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `class` -- CREATE TABLE IF NOT EXISTS `class` ( `ClsID` int(11) NOT NULL AUTO_INCREMENT, `ClsNm` varchar(50) NOT NULL, `TchID` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`ClsID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Анги' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `classstudent` -- CREATE TABLE IF NOT EXISTS `classstudent` ( `ClsID` int(11) NOT NULL, `StdID` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`ClsID`,`StdID`), KEY `StdID` (`StdID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Ангийн оюутан'; -- -------------------------------------------------------- -- -- Table structure for table `homework` -- CREATE TABLE IF NOT EXISTS `homework` ( `LsnCntID` int(11) NOT NULL, `StdID` int(11) NOT NULL, `HWork` text NOT NULL, `Pnt` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Даалгавар'; -- -------------------------------------------------------- -- -- Table structure for table `information` -- CREATE TABLE IF NOT EXISTS `information` ( `InfID` int(11) NOT NULL AUTO_INCREMENT, `Info` text NOT NULL, `TpUsrID` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`InfID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Мэдээлэл' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `lesson` -- CREATE TABLE IF NOT EXISTS `lesson` ( `LsnID` int(11) NOT NULL AUTO_INCREMENT, `LsnNm` varchar(50) NOT NULL, `LsnCd` varchar(25) NOT NULL, `LsnCrd` int(11) NOT NULL, `LsnYear` int(11) NOT NULL, `AttPnt` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`LsnID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хичээл' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `lessoncontent` -- CREATE TABLE IF NOT EXISTS `lessoncontent` ( `LsnCntID` int(11) NOT NULL AUTO_INCREMENT, `Title` varchar(50) NOT NULL, `LsnTpID` int(11) NOT NULL, `Desc` varchar(200) NOT NULL, `UseMtrl` text NOT NULL, `Attachment` text NOT NULL, `Week` int(11) NOT NULL, `Sort` int(11) NOT NULL, `SelfPnt` int(11) NOT NULL, `SelfEndDt` datetime NOT NULL, `LsnID` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`LsnCntID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хичээлийн агуулга' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `lessoncontenttopic` -- CREATE TABLE IF NOT EXISTS `lessoncontenttopic` ( `LsnCntID` int(11) NOT NULL AUTO_INCREMENT, `TpcID` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`LsnCntID`,`TpcID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хичээлийн агуулгын сэдэв' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `lessondefinition` -- CREATE TABLE IF NOT EXISTS `lessondefinition` ( `LsnID` int(11) NOT NULL, `FldID` int(11) NOT NULL, `FldVal` varchar(200) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`LsnID`,`FldID`,`FldVal`), KEY `FldID` (`FldID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хичээлийн тодрхойлолт'; -- -------------------------------------------------------- -- -- Table structure for table `lessondefinitionform` -- CREATE TABLE IF NOT EXISTS `lessondefinitionform` ( `FldID` int(11) NOT NULL AUTO_INCREMENT, `FldNm` varchar(25) NOT NULL, `IsMulti` tinyint(1) NOT NULL, `Sort` int(11) NOT NULL, `Prmtr` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`FldID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хичээлийн тодорхойлолтын маягт' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `lessontype` -- CREATE TABLE IF NOT EXISTS `lessontype` ( `LsnID` int(11) NOT NULL AUTO_INCREMENT, `LsnNm` varchar(200) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`LsnID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хичээлийн хэлбэр' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `profile` -- CREATE TABLE IF NOT EXISTS `profile` ( `UsrID` int(11) NOT NULL, `FldID` int(11) NOT NULL, `FldVal` varchar(200) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`UsrID`,`FldID`,`FldVal`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хувийн хэрэг'; -- -------------------------------------------------------- -- -- Table structure for table `question` -- CREATE TABLE IF NOT EXISTS `question` ( `QstID` int(11) NOT NULL AUTO_INCREMENT, `Question` varchar(200) NOT NULL, `Answer` varchar(200) NOT NULL, `Type` int(11) NOT NULL, `Lvl` int(11) NOT NULL, `TpcID` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`QstID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Асуулт' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `registrationform` -- CREATE TABLE IF NOT EXISTS `registrationform` ( `FldID` int(11) NOT NULL AUTO_INCREMENT, `UsrTpID` int(11) NOT NULL, `FldNm` varchar(25) NOT NULL, `IsMulti` tinyint(1) NOT NULL, `Srt` int(11) NOT NULL, `Prmtr` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`FldID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Бүртгэлийн маягт' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `relationtype` -- CREATE TABLE IF NOT EXISTS `relationtype` ( `RltnID` int(11) NOT NULL AUTO_INCREMENT, `RltnNm` varchar(25) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`RltnID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хамаарлын төрөл' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `stdtest` -- CREATE TABLE IF NOT EXISTS `stdtest` ( `UsrID` int(11) NOT NULL, `TstPrtID` int(11) NOT NULL, `StrDt` datetime NOT NULL, `EndDt` datetime NOT NULL, `Pnt` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`UsrID`,`TstPrtID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Оюутны шалгалт'; -- -------------------------------------------------------- -- -- Table structure for table `studenttestquestion` -- CREATE TABLE IF NOT EXISTS `studenttestquestion` ( `UsrID` int(11) NOT NULL, `TstID` int(11) NOT NULL, `QueID` int(11) NOT NULL, `Ans` text NOT NULL, `Pnt` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`UsrID`,`TstID`,`QueID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Оюутны шалгалтын асуулт'; -- -------------------------------------------------------- -- -- Table structure for table `studenttimetable` -- CREATE TABLE IF NOT EXISTS `studenttimetable` ( `StdID` int(11) NOT NULL, `LsnID` int(11) NOT NULL, `TchID` int(11) NOT NULL, `LsnTpID` int(11) NOT NULL, `LsnTm` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`StdID`,`LsnID`,`TchID`,`LsnTpID`,`LsnTm`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Оюутны хичээлийн хуваарь'; -- -------------------------------------------------------- -- -- Table structure for table `taskplanner` -- CREATE TABLE IF NOT EXISTS `taskplanner` ( `TskID` int(11) NOT NULL AUTO_INCREMENT, `Title` varchar(50) NOT NULL, `Content` text NOT NULL, `StrtDt` datetime NOT NULL, `EndDt` datetime NOT NULL, `TpUsrID` int(11) NOT NULL, `Status` int(11) NOT NULL, `PntID` int(11) NOT NULL, `WorkPer` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`TskID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Ажлын төлөвлөгөө' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `teachertimetable` -- CREATE TABLE IF NOT EXISTS `teachertimetable` ( `LsnID` int(11) NOT NULL, `TchID` int(11) NOT NULL, `LsnTpID` int(11) NOT NULL, `LsnTm` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`LsnID`,`TchID`,`LsnTpID`,`LsnTm`), KEY `LsnTpID` (`LsnTpID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Багшийн хичээлийн хуваарь'; -- -------------------------------------------------------- -- -- Table structure for table `test` -- CREATE TABLE IF NOT EXISTS `test` ( `TstID` int(11) NOT NULL AUTO_INCREMENT, `TstNm` varchar(25) NOT NULL, `Duration` int(11) NOT NULL, `Pnt` int(11) NOT NULL, `Line` int(11) NOT NULL, `PerPnt` int(11) NOT NULL, `Status` int(11) NOT NULL, `LsnID` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`TstID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Шалгалт' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `testpart` -- CREATE TABLE IF NOT EXISTS `testpart` ( `TstPrtID` int(11) NOT NULL AUTO_INCREMENT, `TstPrtNm` varchar(50) NOT NULL, `TstID` int(11) NOT NULL, `OpenPnt` int(11) NOT NULL, `ClosePnt` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`TstPrtID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Шалгалтын хэсэг' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `testquestion` -- CREATE TABLE IF NOT EXISTS `testquestion` ( `TstID` int(11) NOT NULL, `TpcID` int(11) NOT NULL, `QstLvl` int(11) NOT NULL, `Number` int(11) NOT NULL, `Pnt` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`TstID`,`TpcID`,`QstLvl`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Шалгалтын асуулт'; -- -------------------------------------------------------- -- -- Table structure for table `topic` -- CREATE TABLE IF NOT EXISTS `topic` ( `TpcID` int(11) NOT NULL AUTO_INCREMENT, `TpcNm` varchar(50) NOT NULL, `LsnID` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`TpcID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Сэдэв' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE IF NOT EXISTS `user` ( `UsrID` int(11) NOT NULL AUTO_INCREMENT, `Email` varchar(50) NOT NULL, `UsrCd` varchar(25) NOT NULL, `UsrPw` varchar(25) NOT NULL, `UsrNm` varchar(50) NOT NULL, `UsrLnm` varchar(50) NOT NULL, `UsrPic` varchar(255) NOT NULL, `UsrTpID` int(11) NOT NULL, `RegIP` varchar(25) NOT NULL, `RegDt` datetime NOT NULL, `LstEntIP` varchar(25) NOT NULL, `LstEntDt` datetime NOT NULL, PRIMARY KEY (`UsrID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хэрэглэгч' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `userlesson` -- CREATE TABLE IF NOT EXISTS `userlesson` ( `LsnID` int(11) NOT NULL, `UsrID` int(11) NOT NULL, `RltnID` int(11) NOT NULL, `Grp` int(11) NOT NULL, `Point70` int(11) NOT NULL, `Point30` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`LsnID`,`UsrID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хэрэглэгчийн хичээл'; -- -------------------------------------------------------- -- -- Table structure for table `userrelation` -- CREATE TABLE IF NOT EXISTS `userrelation` ( `UsrID` int(11) NOT NULL, `RltdUsrID` int(11) NOT NULL, `RltnID` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` datetime NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` datetime NOT NULL, PRIMARY KEY (`UsrID`,`RltdUsrID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хэрэглэгчийн хамаарал'; -- -------------------------------------------------------- -- -- Table structure for table `usertype` -- CREATE TABLE IF NOT EXISTS `usertype` ( `UsrTpID` int(11) NOT NULL AUTO_INCREMENT, `UsrTpNm` text NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`UsrTpID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Хэрэглэгчийн төрөл' AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `wall` -- CREATE TABLE IF NOT EXISTS `wall` ( `TpUsrID` int(11) NOT NULL, `InsID` int(11) NOT NULL, `InsDt` int(11) NOT NULL, `UpdID` int(11) NOT NULL, `UpdDt` int(11) NOT NULL, PRIMARY KEY (`TpUsrID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Самбар'; -- -- Constraints for dumped tables -- -- -- Constraints for table `adteacherjournal` -- ALTER TABLE `adteacherjournal` ADD CONSTRAINT `adteacherjournal_ibfk_2` FOREIGN KEY (`ClsID`) REFERENCES `classstudent` (`ClsID`) ON UPDATE CASCADE, ADD CONSTRAINT `adteacherjournal_ibfk_1` FOREIGN KEY (`FldID`) REFERENCES `adteacherjournalfld` (`JFldID`) ON UPDATE CASCADE; -- -- Constraints for table `adteacherjournalfld` -- ALTER TABLE `adteacherjournalfld` ADD CONSTRAINT `adteacherjournalfld_ibfk_1` FOREIGN KEY (`JFldID`) REFERENCES `adteacherjournal` (`FldID`) ON UPDATE CASCADE; -- -- Constraints for table `classstudent` -- ALTER TABLE `classstudent` ADD CONSTRAINT `classstudent_ibfk_2` FOREIGN KEY (`StdID`) REFERENCES `user` (`UsrID`) ON UPDATE CASCADE, ADD CONSTRAINT `classstudent_ibfk_1` FOREIGN KEY (`ClsID`) REFERENCES `class` (`ClsID`) ON UPDATE CASCADE; -- -- Constraints for table `lessondefinition` -- ALTER TABLE `lessondefinition` ADD CONSTRAINT `lessondefinition_ibfk_2` FOREIGN KEY (`LsnID`) REFERENCES `lesson` (`LsnID`) ON UPDATE CASCADE, ADD CONSTRAINT `lessondefinition_ibfk_1` FOREIGN KEY (`FldID`) REFERENCES `lessondefinitionform` (`FldID`) ON UPDATE CASCADE; -- -- Constraints for table `teachertimetable` -- ALTER TABLE `teachertimetable` ADD CONSTRAINT `teachertimetable_ibfk_1` FOREIGN KEY (`LsnTpID`) REFERENCES `lessontype` (`LsnID`) ON UPDATE CASCADE; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
9be9fab2c201be3874e90b0a33bd6cf9f40bc6e1
SQL
tutorials24x7/notification-management-database-mysql
/notification.sql
UTF-8
4,802
3.28125
3
[ "MIT" ]
permissive
-- MySQL dump 10.13 Distrib 8.0.14, for Win64 (x86_64) -- -- Host: 127.0.0.1 Database: notification -- ------------------------------------------------------ -- Server version 8.0.14 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; SET NAMES utf8 ; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `notification` -- DROP TABLE IF EXISTS `notification`; /*!40101 SET @saved_cs_client = @@character_set_client */; SET character_set_client = utf8mb4 ; CREATE TABLE `notification` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `userId` bigint(20) NOT NULL, `sourceId` bigint(20) NOT NULL, `sourceType` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `type` smallint(6) NOT NULL DEFAULT '0', `read` tinyint(1) NOT NULL DEFAULT '1', `trash` tinyint(1) NOT NULL DEFAULT '1', `createdAt` datetime NOT NULL, `updatedAt` datetime DEFAULT NULL, `content` text COLLATE utf8mb4_unicode_ci, PRIMARY KEY (`id`), KEY `idx_notification_user` (`userId`), CONSTRAINT `fk_notification_user` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `notification` -- LOCK TABLES `notification` WRITE; /*!40000 ALTER TABLE `notification` DISABLE KEYS */; /*!40000 ALTER TABLE `notification` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `notification_template` -- DROP TABLE IF EXISTS `notification_template`; /*!40101 SET @saved_cs_client = @@character_set_client */; SET character_set_client = utf8mb4 ; CREATE TABLE `notification_template` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `title` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, `description` varchar(2048) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `type` smallint(6) NOT NULL DEFAULT '0', `sourceType` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `createdAt` datetime NOT NULL, `updatedAt` datetime DEFAULT NULL, `content` text COLLATE utf8mb4_unicode_ci, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `notification_template` -- LOCK TABLES `notification_template` WRITE; /*!40000 ALTER TABLE `notification_template` DISABLE KEYS */; /*!40000 ALTER TABLE `notification_template` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `user` -- DROP TABLE IF EXISTS `user`; /*!40101 SET @saved_cs_client = @@character_set_client */; SET character_set_client = utf8mb4 ; CREATE TABLE `user` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `firstName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `middleName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `lastName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `username` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `mobile` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `email` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `passwordHash` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL, `registeredAt` datetime NOT NULL, `lastLogin` datetime DEFAULT NULL, `intro` tinytext COLLATE utf8mb4_unicode_ci, `profile` text COLLATE utf8mb4_unicode_ci, PRIMARY KEY (`id`), UNIQUE KEY `uq_username` (`username`), UNIQUE KEY `uq_mobile` (`mobile`), UNIQUE KEY `uq_email` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `user` -- LOCK TABLES `user` WRITE; /*!40000 ALTER TABLE `user` DISABLE KEYS */; /*!40000 ALTER TABLE `user` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2020-10-25 17:24:59
true
bf9c7c3f10198ef04a8073dbf10cc6289559be1e
SQL
ajrussellaudio/sinatra-blog
/db/blog_example.sql
UTF-8
260
2.96875
3
[]
no_license
DROP TABLE comments; DROP TABLE posts; CREATE TABLE posts ( id SERIAL PRIMARY KEY, title VARCHAR(255), body TEXT, posted_on DATE ); CREATE TABLE comments ( id SERIAL PRIMARY KEY, body TEXT, posted_on DATE, post_id INT REFERENCES posts(id) );
true
4aaeb0e0db3dd193ccd40698a670e814dfe7ff93
SQL
jean-dedieu/CabinetMedicalSGBD
/database_medimiashs.sql
UTF-8
3,855
3.59375
4
[]
no_license
CREATE TABLE IF NOT EXISTS `Patient` ( `Nss_P` INT NOT NULL, `Nom_Patient` VARCHAR(45) NOT NULL, `Sexe` VARCHAR(45) NOT NULL, `Age` INT NOT NULL, `Profession` VARCHAR(45) NOT NULL, `Date_Deces` DATE NULL, PRIMARY KEY (`Nss_P`)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `Medecin` ( `Nss_M` INT NOT NULL, `Nom_Medecin` VARCHAR(45) NOT NULL, `Sexe` VARCHAR(45) NOT NULL, `Age` INT NOT NULL, `Adresse` VARCHAR(100) NOT NULL, PRIMARY KEY (`Nss_M`)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `Consultation` ( `Num_Consultation` INT NOT NULL, `Statut` VARCHAR(45) NOT NULL, `Date_Consultation` DATE NULL, `Patient_Nss_P` INT NOT NULL, `Medecin_Nss_M` INT NOT NULL, PRIMARY KEY (`Num_Consultation`, `Patient_Nss_P`, `Medecin_Nss_M`), CONSTRAINT `fk_Consultation_Patient` FOREIGN KEY (`Patient_Nss_P`) REFERENCES `Patient` (`Nss_P`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_Consultation_Medecin1` FOREIGN KEY (`Medecin_Nss_M`) REFERENCES `Medecin` (`Nss_M`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `Classe` ( `Num_Classe` INT NOT NULL, `Categorie` VARCHAR(45) NOT NULL, `Taux_Remboursement` DOUBLE NOT NULL, PRIMARY KEY (`Num_Classe`)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `Affection` ( `Num_Affection` INT NOT NULL, `Nom_Affection` VARCHAR(45) NOT NULL, `Classe_Num_Classe` INT NOT NULL, PRIMARY KEY (`Num_Affection`, `Classe_Num_Classe`), CONSTRAINT `fk_Affection_Classe` FOREIGN KEY (`Classe_Num_Classe`) REFERENCES `Classe` (`Num_Classe`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `Liste_Tarif` ( `Num_Tarif` INT NOT NULL, `Nom_Tarif` VARCHAR(45) NOT NULL, `Montant_Tarif` VARCHAR(45) NOT NULL, PRIMARY KEY (`Num_Tarif`)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `Prescription` ( `Num_Prescription` INT NOT NULL, `Nom_Medicament` VARCHAR(45) NOT NULL, `Quantite` INT NOT NULL, PRIMARY KEY (`Num_Prescription`)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `Acte_Medicale` ( `Num_Acte` INT NOT NULL, `Date_Creation` DATE NOT NULL, `Montant` DOUBLE NOT NULL, `Consultation_Num_Consultation` INT NOT NULL, `Consultation_Patient_Nss_P` INT NOT NULL, `Consultation_Medecin_Nss_M` INT NOT NULL, `Liste_Tarif_Num_Tarif` INT NOT NULL, `Prescription_Num_Prescription` INT NOT NULL, PRIMARY KEY (`Num_Acte`, `Consultation_Num_Consultation`, `Consultation_Patient_Nss_P`, `Consultation_Medecin_Nss_M`, `Liste_Tarif_Num_Tarif`, `Prescription_Num_Prescription`), CONSTRAINT `fk_Acte_Medicale_Consultation1` FOREIGN KEY (`Consultation_Num_Consultation` , `Consultation_Patient_Nss_P` , `Consultation_Medecin_Nss_M`) REFERENCES `Consultation` (`Num_Consultation` , `Patient_Nss_P` , `Medecin_Nss_M`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_Acte_Medicale_Liste_Tarif1` FOREIGN KEY (`Liste_Tarif_Num_Tarif`) REFERENCES `Liste_Tarif` (`Num_Tarif`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_Acte_Medicale_Prescription1` FOREIGN KEY (`Prescription_Num_Prescription`) REFERENCES `Prescription` (`Num_Prescription`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `Patient_has_Affection` ( `Patient_Nss_P` INT NOT NULL, `Affection_Num_Affection` INT NOT NULL, PRIMARY KEY (`Patient_Nss_P`, `Affection_Num_Affection`), CONSTRAINT `fk_Patient_has_Affection_Patient1` FOREIGN KEY (`Patient_Nss_P`) REFERENCES `Patient` (`Nss_P`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_Patient_has_Affection_Affection1` FOREIGN KEY (`Affection_Num_Affection`) REFERENCES `Affection` (`Num_Affection`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB;
true
957ced58a8141a3f060931192ca7b84b9f04a252
SQL
descriptions-of-it-technologies/oracle-sql-plsql
/labs/sql2/demo/demo_06_With.sql
UTF-8
152
3.046875
3
[]
no_license
WITH avgsal_tab AS (SELECT avg(salary) avgsal FROM employees) SELECT last_name, salary, avgsal avsal FROM employees, avgsal_tab WHERE salary > avgsal ;
true
e3fd3d0a0890123561afcb723638836e1246737e
SQL
ToborTheGreat/Repository01
/dw.parameter_catalog_groups.sql
UTF-8
1,980
3.21875
3
[]
no_license
-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; SET search_path = dw, pg_catalog; ALTER TABLE ONLY dw.parameter_catalog_groups DROP CONSTRAINT parameter_catalog_groups_vnd; DROP INDEX dw.parameter_catalog_groups_ux; ALTER TABLE ONLY dw.parameter_catalog_groups DROP CONSTRAINT parameter_catalog_groups_pk; DROP TABLE dw.parameter_catalog_groups; SET search_path = dw, pg_catalog; SET default_tablespace = p2_dwdata; SET default_with_oids = false; -- -- Name: parameter_catalog_groups; Type: TABLE; Schema: dw; Owner: -; Tablespace: p2_dwdata -- CREATE TABLE parameter_catalog_groups ( parameter_catalog_group_id integer DEFAULT nextval('parameter_catalog_group_seq'::regclass) NOT NULL, technology character varying(50) NOT NULL, description character varying(100) NOT NULL, created timestamp without time zone NOT NULL, modified timestamp without time zone NOT NULL, infrastructure_vendor_id integer NOT NULL ); SET default_tablespace = p2_dwindex; -- -- Name: parameter_catalog_groups_pk; Type: CONSTRAINT; Schema: dw; Owner: -; Tablespace: p2_dwindex -- ALTER TABLE ONLY parameter_catalog_groups ADD CONSTRAINT parameter_catalog_groups_pk PRIMARY KEY (parameter_catalog_group_id); -- -- Name: parameter_catalog_groups_ux; Type: INDEX; Schema: dw; Owner: -; Tablespace: p2_dwindex -- CREATE UNIQUE INDEX parameter_catalog_groups_ux ON parameter_catalog_groups USING btree (technology, description, infrastructure_vendor_id); -- -- Name: parameter_catalog_groups_vnd; Type: FK CONSTRAINT; Schema: dw; Owner: - -- ALTER TABLE ONLY parameter_catalog_groups ADD CONSTRAINT parameter_catalog_groups_vnd FOREIGN KEY (infrastructure_vendor_id) REFERENCES infrastructure_vendors(infrastructure_vendor_id); -- -- PostgreSQL database dump complete --
true
50dbe633495f257103f703012ddaafb6414b5240
SQL
PgYw/dJi-Android-
/server/Dji.sql
UTF-8
5,034
2.796875
3
[]
no_license
--注意,如果想手机访问数据库需要ctrl+f把127.0.0.1本地域名换成本地电脑ip SET NAMES UTF8; DROP DATABASE IF EXISTS dji; CREATE DATABASE djiApp CHARSET=UTF8; USE djiApp; CREATE TABLE dji_user( user_id INT PRIMARY KEY AUTO_INCREMENT comment '用户的id', reg_way VARCHAR(16) comment '用户注册方式', user_phone CHAR(11) comment '用户手机号', user_email VARCHAR(64) comment '用户邮箱', user_pwd VARCHAR(128) comment '用户密码' ); INSERT INTO dji_user VALUES (NULL,"phone",15555555555,"2585351891@qq.com","123456.."); CREATE TABLE dji_cart( cart_id INT PRIMARY KEY AUTO_INCREMENT comment '购物车的id', user_id INT comment '用户的id', product_id INT comment '商品的id', product_count INT comment '商品的数量', product_isSelect CHAR(1) comment '商品的选中状态' ); CREATE TABLE dji_product( product_id INT PRIMARY KEY AUTO_INCREMENT comment '商品的id', product_img VARCHAR(128) comment '商品的图片', product_ify VARCHAR(28) comment '商品的分类', product_title VARCHAR(128) comment '商品的介绍', product_Oprice DECIMAL(8,2) comment '商品的本来的价格', product_Nprice DECIMAL(8,2) comment '商品的打折后的价格', product_select VARCHAR(1) comment '商品是否为推荐商品', relevancy_id INT comment '关联的子产品id' ); INSERT INTO dji_product VALUES (NULL,'http://127.0.0.1:3000/images/Osmo1_one.jpg','灵眸 Osmo','口袋云台相机',2499,0,0,7), (NULL,'http://127.0.0.1:3000/images/Osmo2_one.jpg','灵眸 Osmo','手机云台2',899,0,1,7), (NULL,'http://127.0.0.1:3000/images/Mavic1_one.jpg','"御" Mavic','2',9888,0,1,NULL), (NULL,'http://127.0.0.1:3000/images/Mavic2_one.jpg','"御" Mavic','Air',4999,0,0,NULL), (NULL,'http://127.0.0.1:3000/images/Mavic3_one.jpg','"御" Mavic','Pro 铂金版',6499,0,0,NULL), (NULL,'http://127.0.0.1:3000/images/spark1_one.jpg','"晓" Spark','操控套装',3199,0,1,NULL), (NULL,'http://127.0.0.1:3000/images/mobile1_relevancy.jpg',"闪迪 microSD卡","64GB",119,0,1,NULL); CREATE TABLE dji_img( img_id INT PRIMARY KEY AUTO_INCREMENT comment '图片的id', relevancy_id INT comment '图片关联的商品id', img_url VARCHAR(128) comment '图片的地址' ); INSERT INTO dji_img VALUES (NULL,'1','http://127.0.0.1:3000/images/Osmo1_one.jpg'), (NULL,'1','http://127.0.0.1:3000/images/Osmo1_two.jpg'), (NULL,'1','http://127.0.0.1:3000/images/Osmo1_three.jpg'), (NULL,'2','http://127.0.0.1:3000/images/Osmo2_one.jpg'), (NULL,'2','http://127.0.0.1:3000/images/Osmo2_two.jpg'), (NULL,'2','http://127.0.0.1:3000/images/Osmo2_three.jpg'), (NULL,'3','http://127.0.0.1:3000/images/Mavic1_one.jpg'), (NULL,'3','http://127.0.0.1:3000/images/Mavic1_two.jpg'), (NULL,'3','http://127.0.0.1:3000/images/Mavic1_three.jpg'), (NULL,'4','http://127.0.0.1:3000/images/Mavic2_one.jpg'), (NULL,'4','http://127.0.0.1:3000/images/Mavic2_two.jpg'), (NULL,'4','http://127.0.0.1:3000/images/Mavic2_three.jpg'), (NULL,'5','http://127.0.0.1:3000/images/Mavic3_one.jpg'), (NULL,'5','http://127.0.0.1:3000/images/Mavic3_two.jpg'), (NULL,'5','http://127.0.0.1:3000/images/Mavic3_three.jpg'), (NULL,'6','http://127.0.0.1:3000/images/spark1_one.jpg'), (NULL,'6','http://127.0.0.1:3000/images/spark1_two.jpg'), (NULL,'6','http://127.0.0.1:3000/images/spark1_three.jpg'), (NULL,'7','http://127.0.0.1:3000/images/mobile1_relevancy.jpg'), (NULL,'7','http://127.0.0.1:3000/images/mobile2_relevancy.jpg'), (NULL,'7','http://127.0.0.1:3000/images/mobile3_relevancy.jpg'); CREATE TABLE dji_banner( banner_id INT PRIMARY KEY AUTO_INCREMENT comment '轮播图的id', banner_href VARCHAR(128) comment '轮播图的超链接', banner_img VARCHAR(128) comment '轮播图的地址', banner_productLnTop VARCHAR(128) comment '轮播图的简介(上)', banner_productLnBottom VARCHAR(128) comment '轮播图的简介(下)' ); INSERT INTO dji_banner VALUES (NULL,null,'http://127.0.0.1:3000/images/swipe1.png',"御 MAVIC 2","画质旗舰,变焦先锋"), (NULL,null,'http://127.0.0.1:3000/images/swipe2.png',"灵眸 OSMO 口袋云台相机","转动随心,灵感不停"); CREATE TABLE dji_shaky( shaky_id INT PRIMARY KEY AUTO_INCREMENT comment '活动的id', shaky_title VARCHAR(128) comment '活动的介绍', shaky_a VARCHAR(128) comment '活动的链接', shaky_imgUrl VARCHAR(128) comment '活动的图片地址' ); INSERT INTO dji_shaky VALUES (NULL,"DJI Select 会员计划 7项会员权益|最高5折优惠",NULL,'http://127.0.0.1:3000/images/select.png'); CREATE TABLE dji_favourable( favourable_id INT PRIMARY KEY AUTO_INCREMENT comment '优惠的id', favourable_title VARCHAR(128) comment '优惠的介绍', favourable_a VARCHAR(128) comment '优惠的链接', favourable_imgUrl VARCHAR(128) comment '优惠的图片地址' ); INSERT INTO dji_favourable VALUES (NULL,"翻新机 实惠价格 | 质量保证 | 同等保修",NULL,'http://127.0.0.1:3000/images/refurbished.png'), (NULL,"教育折扣 最高九折",NULL,'http://127.0.0.1:3000/images/edu_discount.png');
true
d06e302315546b452a67f27180575e9bef6e4bb8
SQL
RookieRoll/kobold-blog
/kobold-blog-provider/src/main/resources/source/blog.sql
UTF-8
3,164
3.46875
3
[]
no_license
/* Navicat Premium Data Transfer Source Server : LocalHost Source Server Type : MySQL Source Server Version : 80015 Source Host : localhost:3306 Source Schema : blog Target Server Type : MySQL Target Server Version : 80015 File Encoding : 65001 Date: 01/07/2019 09:52:45 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for blogs -- ---------------------------- DROP TABLE IF EXISTS `blogs`; CREATE TABLE `blogs` ( `id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL, `sub_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL, `create_time` timestamp(0) NULL DEFAULT NULL, `blog_status` tinyint(255) NULL DEFAULT NULL, `modify_time` timestamp(0) NULL DEFAULT NULL, `is_deleted` tinyint(255) NULL DEFAULT NULL, `user_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for classify -- ---------------------------- DROP TABLE IF EXISTS `classify`; CREATE TABLE `classify` ( `id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, `classify_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `sort` int(255) NULL DEFAULT NULL, `create_time` timestamp(0) NULL DEFAULT NULL, `is_deleted` tinyint(1) NULL DEFAULT NULL, `is_stopped` tinyint(1) NULL DEFAULT NULL, `user_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for classifyblogs -- ---------------------------- DROP TABLE IF EXISTS `classifyblogs`; CREATE TABLE `classifyblogs` ( `id` int(11) NOT NULL, `classify_id` int(11) NULL DEFAULT NULL, `blog_id` int(11) NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for user -- ---------------------------- DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, `username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `birthday` timestamp(0) NULL DEFAULT NULL, `sex` tinyint(255) NULL DEFAULT NULL, `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `creation_time` timestamp(0) NULL DEFAULT NULL, `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; SET FOREIGN_KEY_CHECKS = 1;
true
1a85ed36c94b533747456b674ca1ceecd47b2aa8
SQL
dloose/abacus
/database/stock_schema.sql
UTF-8
547
3.3125
3
[]
no_license
CREATE TABLE symbols ( symbol TEXT PRIMARY KEY, added_date TIMESTAMP NOT NULL DEFAULT NOW(), initial_import_date TIMESTAMP, last_update_date TIMESTAMP ); CREATE TABLE symbol_data ( symbol TEXT NOT NULL REFERENCES symbols(symbol) ON DELETE CASCADE, date DATE NOT NULL, open NUMERIC NOT NULL, close NUMERIC NOT NULL, high NUMERIC NOT NULL, low NUMERIC NOT NULL, sma100d NUMERIC, rsi100d NUMERIC ); CREATE UNIQUE INDEX ON symbol_data(symbol, date DESC);
true
497749d8fb620de5f9121629192f993566755977
SQL
RavinduHasanka/GadgetBadgetSystem
/Group_Seliya/gadget_badget_delivery.sql
UTF-8
2,178
2.875
3
[]
no_license
-- MariaDB dump 10.17 Distrib 10.4.11-MariaDB, for Win64 (AMD64) -- -- Host: localhost Database: gadget_badget -- ------------------------------------------------------ -- Server version 10.1.36-MariaDB /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `delivery` -- DROP TABLE IF EXISTS `delivery`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `delivery` ( `DeliveryID` int(11) NOT NULL AUTO_INCREMENT, `ItemID` int(11) DEFAULT NULL, `ReceiverName` varchar(45) DEFAULT NULL, `ReceiverPhoneNo` varchar(10) DEFAULT NULL, `ReceiverMail` varchar(45) DEFAULT NULL, PRIMARY KEY (`DeliveryID`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `delivery` -- LOCK TABLES `delivery` WRITE; /*!40000 ALTER TABLE `delivery` DISABLE KEYS */; INSERT INTO `delivery` VALUES (1,12,'sandun','0789652416','sandun@yahoo.com'),(2,45,'janith','0713562849','janith@gmail.com'),(3,18,'kasun','0776259865','kasun@gmail.com'); /*!40000 ALTER TABLE `delivery` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2021-04-23 23:47:58
true
51f1e902fd7d74cf224cdced32959ed16b2478e6
SQL
jgarzonext/plsql-testing
/script_plsql/bd_iaxis/script/tables/DIR_CALLESCPOSTALES.sql
ISO-8859-1
1,449
2.859375
3
[]
no_license
-------------------------------------------------------- -- DDL for Table DIR_CALLESCPOSTALES -------------------------------------------------------- CREATE TABLE "AXIS"."DIR_CALLESCPOSTALES" ( "IDCALLE" NUMBER(10,0), "CPOSTAL" VARCHAR2(10 BYTE), "NUMPINF" NUMBER(5,0), "NPARINF" NUMBER(5,0), "NIMPSUP" NUMBER(5,0), "NPASSUP" NUMBER(5,0), "CVALCCP" NUMBER(1,0) ) SEGMENT CREATION DEFERRED PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING TABLESPACE "AXIS" ; COMMENT ON COLUMN "AXIS"."DIR_CALLESCPOSTALES"."IDCALLE" IS 'Id Calle'; COMMENT ON COLUMN "AXIS"."DIR_CALLESCPOSTALES"."CPOSTAL" IS 'Codigo Postal Calle'; COMMENT ON COLUMN "AXIS"."DIR_CALLESCPOSTALES"."NPARINF" IS 'Nmero Par Inferior'; COMMENT ON COLUMN "AXIS"."DIR_CALLESCPOSTALES"."NIMPSUP" IS 'Nmero Impar Superior'; COMMENT ON COLUMN "AXIS"."DIR_CALLESCPOSTALES"."NPASSUP" IS 'Nmero Par Superior'; COMMENT ON COLUMN "AXIS"."DIR_CALLESCPOSTALES"."CVALCCP" IS 'Calle-CP Validado'; COMMENT ON TABLE "AXIS"."DIR_CALLESCPOSTALES" IS 'Calles'; GRANT UPDATE ON "AXIS"."DIR_CALLESCPOSTALES" TO "R_AXIS"; GRANT SELECT ON "AXIS"."DIR_CALLESCPOSTALES" TO "R_AXIS"; GRANT INSERT ON "AXIS"."DIR_CALLESCPOSTALES" TO "R_AXIS"; GRANT DELETE ON "AXIS"."DIR_CALLESCPOSTALES" TO "R_AXIS"; GRANT SELECT ON "AXIS"."DIR_CALLESCPOSTALES" TO "CONF_DWH"; GRANT SELECT ON "AXIS"."DIR_CALLESCPOSTALES" TO "PROGRAMADORESCSI";
true
fe4666f8f25596d82544643bd8741438be4f2214
SQL
Henrique-Moura/sd-09-mysql-vocabulary-booster
/desafio16.sql
UTF-8
411
3.703125
4
[]
no_license
USE hr; DELIMITER $$ CREATE FUNCTION buscar_quantidade_de_empregos_por_funcionario(EMAIL_EMPLOYEES VARCHAR(25)) RETURNS INT READS SQL DATA BEGIN DECLARE amount_of_jobs INT; SELECT COUNT(*) FROM hr.employees AS E INNER JOIN hr.job_history AS JH ON JH.EMPLOYEE_ID = E.EMPLOYEE_ID WHERE EMAIL = EMAIL_EMPLOYEES INTO amount_of_jobs; RETURN amount_of_jobs; END $$ DELIMITER ;
true
83b271950bd61230c81afdeb939abc8b119bd35b
SQL
jjthom87/class_curriculum
/express_handlebars/params_and_partials/lesson/backup.sql
UTF-8
3,751
3.34375
3
[]
no_license
-- -- PostgreSQL database dump -- -- Dumped from database version 9.6.1 -- Dumped by pg_dump version 9.6.1 SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: Animals; Type: TABLE; Schema: public; Owner: jaredthomas -- CREATE TABLE "Animals" ( id integer NOT NULL, name character varying(255) NOT NULL, class character varying(255) NOT NULL, "createdAt" timestamp with time zone, "updatedAt" timestamp with time zone, description text ); ALTER TABLE "Animals" OWNER TO jaredthomas; -- -- Name: Animals_id_seq; Type: SEQUENCE; Schema: public; Owner: jaredthomas -- CREATE SEQUENCE "Animals_id_seq" START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE "Animals_id_seq" OWNER TO jaredthomas; -- -- Name: Animals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: jaredthomas -- ALTER SEQUENCE "Animals_id_seq" OWNED BY "Animals".id; -- -- Name: SequelizeMeta; Type: TABLE; Schema: public; Owner: jaredthomas -- CREATE TABLE "SequelizeMeta" ( name character varying(255) NOT NULL ); ALTER TABLE "SequelizeMeta" OWNER TO jaredthomas; -- -- Name: Animals id; Type: DEFAULT; Schema: public; Owner: jaredthomas -- ALTER TABLE ONLY "Animals" ALTER COLUMN id SET DEFAULT nextval('"Animals_id_seq"'::regclass); -- -- Data for Name: Animals; Type: TABLE DATA; Schema: public; Owner: jaredthomas -- COPY "Animals" (id, name, class, "createdAt", "updatedAt", description) FROM stdin; 1 Komodo Dragon Reptilia \N \N Komodo Dragons are super big lizards, and they can eat humans. Do your best not to mess with one. 2 Chameleon Reptilia \N \N I know these guys disguise themselves, and have a super cool way of catching their prey. 3 Gecko Reptilia \N \N Geico, and a playstation one game i used to play. 4 Poison Dart Frog Amphibia \N \N I heard their poison is lethal. Do your best not to mess with one 5 Salamander Amphibia \N \N I think they can swim. Can do they do things on land? Whatever, they're pretty ugly but pretty cool too. 6 Common Reed Frog Amphibia \N \N No idea what these are. Probably a boring ribbiting frog 7 Black Widow Arachnida \N \N I heard they're poisonous. Steve-O once put one in his mouth, and he didn't know that. Yea! 8 Goliath Birdeater Arachnida \N \N You can guess what this spider does. 9 Tarantula Arachnida \N \N Remember Daniel Stern's scream in Home Alone. That was because of a tarantula. Kevin Durant's nickname is Durantula. \. -- -- Name: Animals_id_seq; Type: SEQUENCE SET; Schema: public; Owner: jaredthomas -- SELECT pg_catalog.setval('"Animals_id_seq"', 1, false); -- -- Data for Name: SequelizeMeta; Type: TABLE DATA; Schema: public; Owner: jaredthomas -- COPY "SequelizeMeta" (name) FROM stdin; 20171224042410-unnamed-migration.js \. -- -- Name: Animals Animals_pkey; Type: CONSTRAINT; Schema: public; Owner: jaredthomas -- ALTER TABLE ONLY "Animals" ADD CONSTRAINT "Animals_pkey" PRIMARY KEY (id); -- -- Name: SequelizeMeta SequelizeMeta_pkey; Type: CONSTRAINT; Schema: public; Owner: jaredthomas -- ALTER TABLE ONLY "SequelizeMeta" ADD CONSTRAINT "SequelizeMeta_pkey" PRIMARY KEY (name); -- -- PostgreSQL database dump complete --
true
afc48e9ed88b8fe5190527ab365c5d5067bfca8d
SQL
theonesp/Obesity-project
/Primary ICD9 diagnosis.sql
UTF-8
320
3.328125
3
[ "MIT" ]
permissive
-- Code for the primary ICD-9 diagnosis select final_2.hadm_id, primary_dx.icd9_code, primary_dx.short_title, primary_dx.long_title from public.final_2 -- replace by the table name created by you in the cohort selection left join public.primary_dx on public.final_2.hadm_id = public.primary_dx.hadm_id order by hadm_id
true
92ef73395422aa4cc063f3710266ab40bd06f09d
SQL
ytw9699/Square
/SQUARE3/WebContent/스퀘어테이블모음.sql
UTF-8
3,915
3.296875
3
[]
no_license
1.회원가입 테이블 create table modMember( id varchar2(20), ex varchar2(100) ); create table MEMBER( id varchar2(20) primary key not null, password varchar2(20) not null, name varchar2(10) not null, email varchar2(50) not null, address varchar2(100) default '0',--상세주소 zipcode varchar2(10) default '0',--우편번호 account varchar2(20) not null,--계좌번호 profile_img varchar2(30) default '0', jumin varchar2(10) not null, phone_num varchar2(20) not null, status number default '0',--계정상태//0:정상//1:게시글막기// 2:게시글막기+로그인차단 reg_date date not null, dot_sum number default '0',--계정이 소지한 DOT 총량 authority number default '0'--0 : 회원 1 : 관리자 ); 2.LINE 테이블 create table LINE( LINE_NUM number primary key not null, LINE_SUBJECT varchar2(20) not null, LINE_REGDATE date not null, LINE_IMG varchar2(30) not null ); 3.LINE_NUM 시퀀스 create sequence LINE_NUM_no_seq; 4. 게시글 테이블 create table board( LINE_NUM NUMBER not null, BOARD_NUM NUMBER primary key not null, BOARD_SUBJECT VARCHAR2(200) not null, BOARD_AUTHOR VARCHAR2(20) not null,--작성자의 아이디 BOARD_CONTENT VARCHAR2(4000) not null, BOARD_REGDATE DATE not null, BOARD_UPLOAD VARCHAR2(100) default '0', BOARD_UP NUMBER default '0',--추천수 DEFAULT = 0 BOARD_DOWN NUMBER default '0',--비추천수 DEFAULT = 0 BOARD_DOT NUMBER default '0', --받은 Dot 총량 DEFAULT = 0 BOARD_SINGO NUMBER default '0',--신고횟수 DEFAULT = 0 BOARD_READCOUNT NUMBER default '0', BOARD_STATUS NUMBER default '0'--0 : 정상 / 1 : 블라인드상태 ); 5. BOARD_NUM 시퀀스 create sequence BOARD_NUM_no_seq; 6. 댓글 테이블 create table comments( LINE_NUM NUMBER not null,--라인번호 BOARD_NUM NUMBER not null,--게시글번호 COMMENT_NUM NUMBER primary key not null,--댓글번호 COMMENT_AUTHOR NUMBER not null, COMMENT_REGDATE DATE not null, COMMENT_CONTENT VARCHAR2(2000) not null, COMMENT_REF NUMBER not null, COMMENT_RE_LEVEL NUMBER not null, COMMENT_UP NUMBER default '0', COMMENT_DOWN NUMBER default '0', COMMENT_STATUS NUMBER default '0'--0 : 정상(기본값) 1 : 삭제된 상태 ); 7. COMMENT_NUM 시퀀스 create sequence COMMENT_NUM_no_seq; 8.신고 테이블 create table singo( SINGO_NUM NUMBER primary key not null, BOARD_NUM NUMBER not null, SINGO_REPORTER VARCHAR2(20) not null,--신고자아이디 SINGO_BADMAN VARCHAR2(20) not null,--피신고자 아이디 SINGO_REASON VARCHAR2(1000) not null,--신고사유 SINGO_REGDATE DATE not null ); 9. SINGO_NUM 시퀀스 create sequence SINGO_NUM_no_seq; 10.닷충전 테이블 create table DOT_CHARGE( DC_NUM NUMBER primary key not null, DC_ID VARCHAR2(20) not null, DC_VALUE NUMBER not null, DC_STATUS NUMBER default '0',--0 : 대기중(무통장일경우) 1 : 충전완료 DC_DATE DATE not null, DC_DATED DATE--충전 승인 날짜 ); 11. DC_NUM 시퀀스 create sequence DC_NUM_no_seq; 12.닷환전 테이블 create table DOT_EXCHANGE( DE_NUM NUMBER primary key not null, DE_ID VARCHAR2(20) not null, DE_VALUE NUMBER not null, DE_STATUS NUMBER default '0',--0 : 대기중 1 : 환전완료 DE_DATE DATE not null, DE_DATED DATE -- 승인 날짜 ); 13. DE_NUM 시퀀스 create sequence DE_NUM_no_seq; 14. 닷 사용내역 테이블 create table DOT_HISTORY( DH_NUM NUMBER primary key not null, DH_DONATION NUMBER not null,--기부 DH_FROM VARCHAR2(20) not null,--준사람 DH_TO VARCHAR2(20) not null,--받은사람 DH_DATE DATE not null, BOARD_NUM NUMBER not null ); 15. DH_NUM 시퀀스 create sequence DH_NUM_no_seq; 16. 좋아요 글 담기 테이블 create table LIKE_BOARD( LIKE_NUM NUMBER primary key not null,--좋아요 글 담기 게시판의 글번호 LIKE_ID VARCHAR2(20) not null,--즐겨찾기를 한 사람의 아이디 ORG_BOARD_NUM NUMBER not null--즐겨찾기를 한 게시물의 NUMBER ); 17. LIKE_NUM 시퀀스 create sequence LIKE_NUM_no_seq;
true
4ff0148236854427251519416868cb5009e8b8b2
SQL
zuhara/Lycaeum-Mentoring
/database/postgres.sql
UTF-8
1,164
3.5625
4
[]
no_license
CREATE TABLE customer ( id INTEGER, name VARCHAR(500), jdate DATE, address TEXT, email VARCHAR(500)); CREATE TABLE invoice ( cid INTEGER REFERENCES customer(id), id INTEGER PRIMARY KEY, date DATE, particulars text, amount NUMERIC); INSERT INTO invoice VALUES (3, 1, '2020-Feb-01', 'Machine learning', 450); INSERT INTO customer(id, name, jdate, address, email) VALUES (1, 'John and sons', '2020-Feb-01', '5th Street', 'john@johnandsons.com'); INSERT INTO customer(id, name, jdate, address, email) VALUES (3, 'Batman', '2020-Jan-01', '5th Street, Gotham', 'bruce@wayne.net'); INSERT INTO customer(id, name, jdate, address, email) VALUES (2, 'Superman', '2015-July-04', '5th Street, Metropolis', 'clark@dailyplanet.com'); ALTER TABLE customer ADD PRIMARY KEY (id); ALTER TABLE customer ADD NOT NULL (id); SELECT * FROM customer where id=2; DROP DATABASE invoice; SELECT * FROM customer; SELECT * FROM invoice_customer; SELECT * FROM invoice_invoice ; SELECT * FROM invoice_invoice WHERE id = '6';
true
91812452546073c7393c47aab7a96157918ec89c
SQL
alex-carvalho/kanban-board-dev3
/src/main/resources/db/migration/V1.3__Change_contraint.sql
UTF-8
157
2.9375
3
[ "MIT" ]
permissive
ALTER TABLE cards DROP CONSTRAINT IF EXISTS cards_users_fk; ALTER TABLE cards ADD CONSTRAINT cards_users_fk FOREIGN KEY (user_id) REFERENCES users (id);
true
cd01fd44d4be7545c3afab49294a8cfc647b214f
SQL
ManuelRodriguezRUM/exam1-spring-17-big-data-dannyvillanueva
/hive/hive.sql
UTF-8
532
3.609375
4
[ "Apache-2.0" ]
permissive
# You sql follows # Pregunta 1: SELECT e.region, e.ciudad, count(*) FROM escuelas e GROUP BY e.region, e.ciudad;; # Pregunta 2: SELECT e.nombre, count(*) FROM escuelas e , students s WHERE e.escuelaID=s.escuelaID GROUP BY e.nombre; # Pregunta 3: SELECT s.studentID, e.nombre FROM escuelas e, students s WHERE e.escuelaID=s.escuelaID AND (e.ciudad="Ponce" OR e.ciudad="Cabo Rojo"); # Pregunta 4: SELECT e.region, e.ciudad, count(*) FROM escuelas e, students s WHERE e.escuelaID=s.escuelaID GROUP BY e.region, e.ciudad;
true
ccb45b6cc974d6ef25922b8d7549c9c242b2f9a1
SQL
shunchaowang/smartpay
/code/smartpay/core/src/test/resources/data.sql
UTF-8
11,556
3.296875
3
[]
no_license
-- ----------------------------------------------------- -- Data for table MERCHANT_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO MERCHANT_STATUSES (MCST_ID, MCST_NAME, MCST_DESCRIPTION, MCST_ACTIVE, MCST_CODE) VALUES (NULL, 'Normal', 'Normal', 1, '200'); INSERT INTO MERCHANT_STATUSES (MCST_ID, MCST_NAME, MCST_DESCRIPTION, MCST_ACTIVE, MCST_CODE) VALUES (NULL, 'Frozen', 'Frozen', 1, '500'); COMMIT; -- ----------------------------------------------------- -- Data for table CREDENTIAL_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO CREDENTIAL_STATUSES (CRST_ID, CRST_NAME, CRST_DESCRIPTION, CRST_ACTIVE, CRST_CODE) VALUES (NULL, 'Submitted', 'The credential is submitted for approval.', 1, '400'); INSERT INTO CREDENTIAL_STATUSES (CRST_ID, CRST_NAME, CRST_DESCRIPTION, CRST_ACTIVE, CRST_CODE) VALUES (NULL, 'Approved', 'The credential is approved.', 1, '500'); INSERT INTO CREDENTIAL_STATUSES (CRST_ID, CRST_NAME, CRST_DESCRIPTION, CRST_ACTIVE, CRST_CODE) VALUES (NULL, 'Denied', 'The credential is denied.', 1, '502'); INSERT INTO CREDENTIAL_STATUSES (CRST_ID, CRST_NAME, CRST_DESCRIPTION, CRST_ACTIVE, CRST_CODE) VALUES (NULL, 'Expired', 'The credential has expired.', 1, '404'); COMMIT; -- ----------------------------------------------------- -- Data for table CREDENTIAL_TYPES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO CREDENTIAL_TYPES (CRTP_ID, CRTP_NAME, CRTP_DESCRIPTION, CRTP_ACTIVE, CRTP_CODE) VALUES (NULL, 'Certificate', 'Certificate', 1, '100'); COMMIT; -- ----------------------------------------------------- -- Data for table FEE_TYPES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO FEE_TYPES (FETP_ID, FETP_NAME, FETP_DESCRIPTION, FETP_ACTIVE, FETP_CODE) VALUES (NULL, 'Static', 'Static amount for every transaction', 1, '100'); INSERT INTO FEE_TYPES (FETP_ID, FETP_NAME, FETP_DESCRIPTION, FETP_ACTIVE, FETP_CODE) VALUES (NULL, 'Percentage', 'Percentage based on the transaction amount', 1, '101'); COMMIT; -- ----------------------------------------------------- -- Data for table ENCRYPTION_TYPES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO ENCRYPTION_TYPES (ENTP_ID, ENTP_NAME, ENTP_DESCRIPTION, ENTP_ACTIVE, ENTP_CODE) VALUES (NULL, 'MD5', 'MD5 Algorithm', 1, '100'); INSERT INTO ENCRYPTION_TYPES (ENTP_ID, ENTP_NAME, ENTP_DESCRIPTION, ENTP_ACTIVE, ENTP_CODE) VALUES (NULL, 'SHA', 'SHA Algorithm', 1, '101'); COMMIT; -- ----------------------------------------------------- -- Data for table ACCOUNT_TYPES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO ACCOUNT_TYPES (ACTP_ID, ACTP_NAME, ACTP_DESCRIPTION, ACTP_ACTIVE, ACTP_CODE) VALUES (NULL, 'Bank', 'The account is the bank account number.', 1, '100'); INSERT INTO ACCOUNT_TYPES (ACTP_ID, ACTP_NAME, ACTP_DESCRIPTION, ACTP_ACTIVE, ACTP_CODE) VALUES (NULL, 'Card', 'The account is a bank card.', 1, '200'); COMMIT; -- ----------------------------------------------------- -- Data for table ACCOUNT_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO ACCOUNT_STATUSES (ACST_ID, ACST_NAME, ACST_DESCRIPTION, ACST_ACTIVE, ACST_CODE) VALUES (NULL, 'Normal', 'The merchant account is normal.', 1, '200'); INSERT INTO ACCOUNT_STATUSES (ACST_ID, ACST_NAME, ACST_DESCRIPTION, ACST_ACTIVE, ACST_CODE) VALUES (NULL, 'Frozen', 'The merchant account is frozen.', 1, '400'); COMMIT; -- ----------------------------------------------------- -- Data for table SITE_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO SITE_STATUSES (SIST_ID, SIST_NAME, SIST_DESCRIPTION, SIST_ACTIVE, SIST_CODE) VALUES (NULL, 'Created', 'Created and wait for approval', 1, '400'); INSERT INTO SITE_STATUSES (SIST_ID, SIST_NAME, SIST_DESCRIPTION, SIST_ACTIVE, SIST_CODE) VALUES (NULL, 'Approved', 'Approved to operation', 1, '500'); INSERT INTO SITE_STATUSES (SIST_ID, SIST_NAME, SIST_DESCRIPTION, SIST_ACTIVE, SIST_CODE) VALUES (NULL, 'Frozen', 'Frozen', 1, '401'); INSERT INTO SITE_STATUSES (SIST_ID, SIST_NAME, SIST_DESCRIPTION, SIST_ACTIVE, SIST_CODE) VALUES (NULL, 'Declined', 'Declined', 1, '501'); COMMIT; -- ----------------------------------------------------- -- Data for table USER_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO USER_STATUSES (USST_ID, USST_NAME, USST_DESCRIPTION, USST_ACTIVE, USST_CODE) VALUES (NULL, 'Normal', 'Normal', 1, '100'); INSERT INTO USER_STATUSES (USST_ID, USST_NAME, USST_DESCRIPTION, USST_ACTIVE, USST_CODE) VALUES (NULL, 'Deactived', 'Deactived', 1, '400'); INSERT INTO USER_STATUSES (USST_ID, USST_NAME, USST_DESCRIPTION, USST_ACTIVE, USST_CODE) VALUES (NULL, 'Frozen', 'Frozen', 1, '501'); COMMIT; -- ----------------------------------------------------- -- Data for table ROLES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO ROLES (ROLE_ID, ROLE_NAME, ROLE_DESCRIPTION, ROLE_ACTIVE, ROLE_CODE) VALUES (NULL, 'ROLE_ADMIN', 'System Admin', 1, '100'); INSERT INTO ROLES (ROLE_ID, ROLE_NAME, ROLE_DESCRIPTION, ROLE_ACTIVE, ROLE_CODE) VALUES (NULL, 'ROLE_MERCHANT_ADMIN', 'Merchant Admin', 1, '200'); INSERT INTO ROLES (ROLE_ID, ROLE_NAME, ROLE_DESCRIPTION, ROLE_ACTIVE, ROLE_CODE) VALUES (NULL, 'ROLE_MERCHANT_OPERATOR', 'Merchant Operator', 1, '201'); COMMIT; -- ----------------------------------------------------- -- Data for table ORDER_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO ORDER_STATUSES (ORST_ID, ORST_NAME, ORST_DESCRIPTION, ORST_ACTIVE, ORST_CODE) VALUES (NULL, 'Initiated', 'The order is initiated.', 1, '400'); INSERT INTO ORDER_STATUSES (ORST_ID, ORST_NAME, ORST_DESCRIPTION, ORST_ACTIVE, ORST_CODE) VALUES (NULL, 'Confirmed', 'The order is confirmed.', 1, '500'); INSERT INTO ORDER_STATUSES (ORST_ID, ORST_NAME, ORST_DESCRIPTION, ORST_ACTIVE, ORST_CODE) VALUES (NULL, 'Paid', 'The order is paid.', 1, '401'); INSERT INTO ORDER_STATUSES (ORST_ID, ORST_NAME, ORST_DESCRIPTION, ORST_ACTIVE, ORST_CODE) VALUES (NULL, 'Preparing for Shipment', 'The order is parpared for shipment, cannot be cancel at this stage.', 1, '501'); INSERT INTO ORDER_STATUSES (ORST_ID, ORST_NAME, ORST_DESCRIPTION, ORST_ACTIVE, ORST_CODE) VALUES (NULL, 'Cancelled', 'The order is cancelled.', 1, '402'); INSERT INTO ORDER_STATUSES (ORST_ID, ORST_NAME, ORST_DESCRIPTION, ORST_ACTIVE, ORST_CODE) VALUES (NULL, 'Shipped', 'The order is shipped.', 1, '502'); INSERT INTO ORDER_STATUSES (ORST_ID, ORST_NAME, ORST_DESCRIPTION, ORST_ACTIVE, ORST_CODE) VALUES (NULL, 'Delivered', 'The order is delivered.', 1, '503'); INSERT INTO ORDER_STATUSES (ORST_ID, ORST_NAME, ORST_DESCRIPTION, ORST_ACTIVE, ORST_CODE) VALUES (NULL, 'Returned', 'The order is returned.', 1, '403'); INSERT INTO ORDER_STATUSES (ORST_ID, ORST_NAME, ORST_DESCRIPTION, ORST_ACTIVE, ORST_CODE) VALUES (NULL, 'Refunded', 'The order is refunded.', 1, '504'); COMMIT; -- ----------------------------------------------------- -- Data for table CURRENCIES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO CURRENCIES (CRCY_ID, CRCY_NAME, CRCY_DESCRIPTION, CRCY_ACTIVE, CRCY_CODE) VALUES (NULL, 'USD', 'US Dollar', 1, '100'); INSERT INTO CURRENCIES (CRCY_ID, CRCY_NAME, CRCY_DESCRIPTION, CRCY_ACTIVE, CRCY_CODE) VALUES (NULL, 'RMB', 'Chinese Yuan', 1, '101'); COMMIT; -- ----------------------------------------------------- -- Data for table CUSTOMER_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO CUSTOMER_STATUSES (CSST_ID, CSST_NAME, CSST_DESCRIPTION, CSST_ACTIVE, CSST_CODE) VALUES (NULL, 'Normal', 'Normal', 1, '200'); INSERT INTO CUSTOMER_STATUSES (CSST_ID, CSST_NAME, CSST_DESCRIPTION, CSST_ACTIVE, CSST_CODE) VALUES (NULL, 'Frozen', 'Frozen', 1, '500'); COMMIT; -- ----------------------------------------------------- -- Data for table CUSTOMER_LOGIN_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO CUSTOMER_LOGIN_STATUSES (CSLS_ID, CSLS_NAME, CSLS_DESCRIPTION, CSLS_ACTIVE, CSLS_CODE) VALUES (NULL, 'Frozen', 'Frozen', 1, '500'); INSERT INTO CUSTOMER_LOGIN_STATUSES (CSLS_ID, CSLS_NAME, CSLS_DESCRIPTION, CSLS_ACTIVE, CSLS_CODE) VALUES (NULL, 'Normal', 'Normal', 1, '200'); COMMIT; -- ----------------------------------------------------- -- Data for table PAYMENT_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO PAYMENT_STATUSES (PYST_ID, PYST_NAME, PYST_DESCRIPTION, PYST_ACTIVE, PYST_CODE) VALUES (NULL, 'Approved', 'Approved', 1, '500'); INSERT INTO PAYMENT_STATUSES (PYST_ID, PYST_NAME, PYST_DESCRIPTION, PYST_ACTIVE, PYST_CODE) VALUES (NULL, 'Declined', 'Declined', 1, '501'); COMMIT; -- ----------------------------------------------------- -- Data for table PAYMENT_TYPES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO PAYMENT_TYPES (PYTP_ID, PYTP_NAME, PYTP_DESCRIPTION, PYTP_ACTIVE, PYTP_CODE) VALUES (NULL, 'Credit Card', 'Credit Card', 1, '100'); INSERT INTO PAYMENT_TYPES (PYTP_ID, PYTP_NAME, PYTP_DESCRIPTION, PYTP_ACTIVE, PYTP_CODE) VALUES (NULL, 'Debit Card', 'Debit Card', 1, '101'); COMMIT; -- ----------------------------------------------------- -- Data for table SHIPMENT_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO SHIPMENT_STATUSES (SHST_ID, SHST_NAME, SHST_DESCRIPTION, SHST_ACTIVE, SHST_CODE) VALUES (NULL, 'Shipped', 'Shipped', 1, '500'); INSERT INTO SHIPMENT_STATUSES (SHST_ID, SHST_NAME, SHST_DESCRIPTION, SHST_ACTIVE, SHST_CODE) VALUES (NULL, 'Delivered', 'Delivered', 1, '501'); INSERT INTO SHIPMENT_STATUSES (SHST_ID, SHST_NAME, SHST_DESCRIPTION, SHST_ACTIVE, SHST_CODE) VALUES (NULL, 'Lost', 'Lost', 1, '400'); INSERT INTO SHIPMENT_STATUSES (SHST_ID, SHST_NAME, SHST_DESCRIPTION, SHST_ACTIVE, SHST_CODE) VALUES (NULL, 'Damaged', 'Damaged', 1, '401'); COMMIT; -- ----------------------------------------------------- -- Data for table ADMINISTRATORS -- ----------------------------------------------------- START TRANSACTION; INSERT INTO ADMINISTRATORS (ADMN_ID, ADMN_USERNAME, ADMN_PASSWORD, ADMN_FIRST_NAME, ADMN_LAST_NAME, ADMN_EMAIL, ADMN_PROFILE_IMAGE, ADMN_REMARK, ADMN_CREATED_TIME, ADMN_UPDATED_TIME, ADMN_ACTIVE, ADMN_ROLE_ID) VALUES (NULL, 'admin', 'admin', 'Admin', 'Admin', 'ironaire@gmail.com', NULL, NULL, NOW(), NULL, 1, 1); COMMIT; -- ----------------------------------------------------- -- Data for table RETURN_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO RETURN_STATUSES (RTST_ID, RTST_NAME, RTST_DESCRIPTION, RTST_ACTIVE, RTST_CODE) VALUES (NULL, 'Shipped', 'Shipped', 1, '400'); INSERT INTO RETURN_STATUSES (RTST_ID, RTST_NAME, RTST_DESCRIPTION, RTST_ACTIVE, RTST_CODE) VALUES (NULL, 'Delivered', 'Delivered', 1, '401'); COMMIT; -- ----------------------------------------------------- -- Data for table REFUND_STATUSES -- ----------------------------------------------------- START TRANSACTION; INSERT INTO REFUND_STATUSES (RFST_ID, RFST_NAME, RFST_DESCRIPTION, RFST_ACTIVE, RFST_CODE) VALUES (NULL, 'Issued', 'Issued', 1, '500'); INSERT INTO REFUND_STATUSES (RFST_ID, RFST_NAME, RFST_DESCRIPTION, RFST_ACTIVE, RFST_CODE) VALUES (NULL, 'Funded', 'Funded', 1, '501'); COMMIT;
true
77de93344c666b6f414d0f99d0d1aaf23f20f3e9
SQL
adminZDY/NewWeb1.0
/web/sql/newsDB(MySql).sql
UTF-8
4,421
3.765625
4
[]
no_license
use sys; #创建数据库,如果存在则删除 # drop database if exists newdb; #如果不存在数据库,则创建 create database if not exists newsDB; use newsDB; #表存在则删除 drop table if exists userInfo; # 用户信息表 create table if not exists userInfo ( #用户编号 userId int not null primary key, #用户名(唯一) userName varchar(20) not null unique, #密码(登录密码) password varchar(20) not null ); #表存在则删除 drop table if exists newsTypeInfo; #新闻类型表 create table if not exists newsTypeInfo ( #类型编号 typeId int not null auto_increment primary key, #类型名称(唯一) typeName varchar(20) not null unique, #类型备注(可为空) remark varchar(50) null ); drop table if exists newsInfo; #新闻信息表 create table if not exists newsInfo ( #新闻编号 newsId int not null auto_increment primary key, #新闻类型(外键) typeId int not null, #新闻发表者(外键) userId int not null, #新闻标题 title varchar(40) not null, #新闻内容 content text not null, #是否推荐新闻(0不推荐,1推荐),默认为0 recommended int not null default(0), #新闻点击次数,默认为0 click int not null default(0), #新闻发布时间,默认为当前时间 releaseTime Date not null default(curdate()), #新闻关键字 keywords varchar(20) not null, FOREIGN KEY(typeId) REFERENCES newsTypeInfo(typeId), FOREIGN KEY(userId) REFERENCES userInfo(userId) ); #添加用户 insert into userInfo values('test','123456'); insert into userInfo values('admin','123456'); #添加类型 insert into newsTypeInfo values('学院新闻','关于学院内部的新闻'); insert into newsTypeInfo values('行业新闻','关于IT行业的新闻'); insert into newsTypeInfo values('就业新闻','关于学院学员的新闻'); insert into newsTypeInfo values('其他新闻','与学员有关的其他新闻'); insert into newsTypeInfo values('学员生活','发布学员在学习生活的相关新闻'); insert into newsTypeInfo values('学院','关于学院内部的新闻'); insert into newsTypeInfo values('行业','关于IT行业的新闻'); insert into newsTypeInfo values('就业','关于学院学员的新闻'); insert into newsTypeInfo values('其他','与学员有关的其他新闻'); insert into newsTypeInfo values('生活','发布学员在学习生活的相关新闻'); insert into newsTypeInfo values('新闻','关于学院内部的新闻'); insert into newsTypeInfo values('行','关于IT行业的新闻'); insert into newsTypeInfo values('就','关于学院学员的新闻'); insert into newsTypeInfo values('其','与学员有关的其他新闻'); insert into newsTypeInfo values('学','发布学员在学习生活的相关新闻'); #添加新闻 insert into newsInfo (typeId,userId,title,content,keywords) values(2,2,'我们准备进入"物联网时代吗?','不要以为物','物联网,互联网'); insert into newsInfo (typeId,userId,title,content,recommended,keywords) values(1,2,'传媒对大学校园报道议题研究','近年来,传媒',1,'学员,传媒'); insert into newsInfo (typeId,userId,title,content,keywords) values(1,2,'我校召开第二次领导干部培训学习会','4月12日晚,...','培训,管理'); insert into newsInfo (typeId,userId,title,content,keywords) values(1,2,'党报护花花锦绣-东宅中学校园新闻','校园文化建设','治理,改革'); insert into newsInfo (typeId,userId,title,content,keywords) values(1,2,'我院针对外包而持续开办日语课程','今年我院课程','外包,日语'); insert into newsInfo (typeId,userId,title,content,keywords) values(1,2,'获市企业维权会副理事长单位','重庆市各界企业','维权,协会'); insert into newsInfo (typeId,userId,title,content,keywords) values(1,2,'李老师接受重庆日报专访','李老师正式','董事长,专访,媒体'); insert into newsInfo (typeId,userId,title,content,keywords) values(5,2,'惠普篮球赛总决赛季军争多战报道','今天的篮球总决赛','惠普,篮球,决赛'); #新闻类型 select * from userInfo; select * from newsTypeInfo where typeId = 1; update newsTypeInfo set typeName ='',remark = '' where typeId = 1; #新闻 #insert into newsInfo(typeId,userId,title,content,keywords) values(,,'','','') select * from newsInfo; select * from newsInfo where newsId = 1;
true
f22414e9a129c4f9cccae7e37c6294f674d513e9
SQL
nhan2804/supconnect
/test.session.sql
UTF-8
1,686
4.46875
4
[ "MIT" ]
permissive
-- @block CREATE TABLE Users( id INT PRIMARY KEY AUTO_INCREMENT, email VARCHAR(255) NOT NULL UNIQUE, bio TEXT, country VARCHAR(2) ); --@block CREATE TABLE Rooms( id INT AUTO_INCREMENT, street VARCHAR(255), owner_id INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (owner_id) REFERENCES Users(id) ) --@block CREATE TABLE Bookings( id INT AUTO_INCREMENT, guest_id INT NOT NULL, room_id INT NOT NULL, check_in DATETIME, PRIMARY KEY (id), FOREIGN KEY (guest_id) REFERENCES Users(id), FOREIGN KEY (room_id) REFERENCES Rooms(id) ) --@block INSERT INTO Users (email, bio, country) VALUES ('chung2@email.com', 'chung dep trai', 'VN'), ('hello@world.com', 'i like strangers', 'US'), ('bonjour@monde.com', 'baz', 'FR'), ('hola@munda.com', 'foo', 'MX') --@block INSERT INTO Rooms (owner_id, street) VALUES (1, 'san diego sailboat'), (1, 'nantucket cottage'), (1, 'vail cabin'), (1, 'sf cardboard box'); --@block INSERT INTO Bookings (guest_id, room_id, check_in) VALUES (1, 2, NOW()), (1, 3, NOW()), (6, 3, NOW()), (6, 1, NOW()) --@block CREATE INDEX email_index ON Users(email); --@block SELECT id, email FROM Users WHERE country = 'VN' -- AND id > 1 AND email like 'chung%' ORDER BY id ASC LIMIT 2; --@BLOCK select * from Rooms; --@block SELECT Users.id as user_id, Rooms.id as room_id, email, street FROM Users LEFT JOIN Rooms ON Rooms.owner_id = Users.id; --@block Rooms as a user has booked SELECT guest_id, room_id, street, check_in FROM Bookings INNER JOIN Rooms ON Rooms.id = room_id; --@block drop TABLES -- DROP TABLE Users; -- DROP TABLE Rooms; DROP TABLE Bookings;
true
43b9d53fea8ba9f470163a86b6754b83618fb02a
SQL
pryor-pan/mysql-
/hotelmanagement.sql
UTF-8
2,222
3.0625
3
[]
no_license
/* Navicat MySQL Data Transfer Source Server : mySQL Source Server Version : 50520 Source Host : localhost:3306 Source Database : hotelmanagement Target Server Type : MYSQL Target Server Version : 50520 File Encoding : 65001 Date: 2021-05-19 20:37:58 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for roomtable -- ---------------------------- DROP TABLE IF EXISTS `roomtable`; CREATE TABLE `roomtable` ( `Rid` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT, `Rtype` varchar(100) NOT NULL, `Rprice` decimal(60,0) NOT NULL, `State` int(10) NOT NULL, `Cname` varchar(100) DEFAULT NULL, `Cnumber` varchar(100) DEFAULT NULL, `Date` varchar(100) DEFAULT NULL, `Days` int(10) DEFAULT NULL, PRIMARY KEY (`Rid`) ) ENGINE=InnoDB AUTO_INCREMENT=108 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of roomtable -- ---------------------------- INSERT INTO `roomtable` VALUES ('0000000101', '标准间', '199', '0', '', '', '', '0'); INSERT INTO `roomtable` VALUES ('0000000102', '标准间', '199', '1', '张三', '18366585415', '2020-4-12', '3'); INSERT INTO `roomtable` VALUES ('0000000103', '大床房', '299', '0', null, null, null, null); INSERT INTO `roomtable` VALUES ('0000000104', '大床房', '299', '1', '李四', '13544562229', '2020-4-18', '1'); INSERT INTO `roomtable` VALUES ('0000000105', '大床房', '299', '0', null, null, null, null); INSERT INTO `roomtable` VALUES ('0000000106', '豪华套间', '599', '1', '李刚', '18543662231', '2020-6-28', '7'); INSERT INTO `roomtable` VALUES ('0000000107', '豪华套间', '599', '0', null, null, null, null); -- ---------------------------- -- Table structure for users -- ---------------------------- DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `uname` varchar(100) NOT NULL, `password` varchar(100) NOT NULL, `role` int(10) NOT NULL, PRIMARY KEY (`uname`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of users -- ---------------------------- INSERT INTO `users` VALUES ('1111', '1111', '1'); INSERT INTO `users` VALUES ('2222', '2222', '0');
true
d8c7bd4f7302e92683526850c01a5a1aaa71297d
SQL
silence-do-good/stress-test-Postgres-and-MySQL
/dump/high/day09/select0356.sql
UTF-8
412
3.546875
4
[]
no_license
SELECT obs.sensor_id, avg(counts) FROM (SELECT sensor_id, date_trunc('day', timestamp), count(*) as counts FROM WiFiAPObservation WHERE timestamp>'2017-11-08T03:56:00Z' AND timestamp<'2017-11-09T03:56:00Z' AND SENSOR_ID = ANY(array['3141_clwa_1420','3146_clwa_6217','3141_clwa_1600','3143_clwa_3099','3143_clwa_3209']) GROUP BY sensor_id, date_trunc('day', timestamp)) AS obs GROUP BY sensor_id
true
39fa71a26e021e9488a9e2e0dd7bea6e6c27a0e3
SQL
PriyankaM06091994/Designing-Advanced-Data-Architectures-for-Business-Intelligence
/Sakila Database/4_RentalsbyCustomer.sql
UTF-8
3,753
4.375
4
[]
no_license
#1.List Customers (Last name, First Name) with rental amount, rental quantity, active status, country and city – #tabular & sql query SELECT c.last_name,c.first_name, sum(p.amount) as RentalAmount, count(r.rental_id) as Rental_Quantity, country.country, city.city,c.active FROM customer AS c JOIN rental AS r ON c.customer_id = r.customer_id JOIN payment as p ON p.rental_id=r.rental_id JOIN address as a ON a.address_id=c.address_id JOIN city as city ON a.city_id=city.city_id JOIN country as country ON country.country_id=city.country_id WHERE c.active = 1 GROUP BY c.last_name,c.first_name ORDER BY c.last_name,c.first_name desc; #2-List top 10 Customers (Last name, First Name) by rental amount (ranked) for PG & PG-13 rated films – bar chart #& sql query SELECT RANK() OVER (ORDER BY sum(p.amount) DESC) AS 'Rank', c.last_name,c.first_name, sum(p.amount) as RentalAmount FROM customer AS c JOIN rental AS r ON c.customer_id = r.customer_id JOIN inventory as i ON r.inventory_id=i.inventory_id JOIN film_category as f ON f.film_id=i.film_id JOIN film as fil ON fil.film_id = f.film_id JOIN category as ct ON ct.category_id=f.category_id JOIN payment as p ON p.rental_id=r.rental_id WHERE fil.rating ='PG' or fil.rating = 'PG-13' GROUP BY c.last_name,c.first_name ORDER BY RentalAmount desc limit 10; #3-Contribution by rental amount for customers from France, Italy or Germany - Treemap (or Heatmap) & sql #query SELECT c.last_name,c.first_name, sum(p.amount) as RentalAmount FROM customer AS c JOIN rental AS r ON c.customer_id = r.customer_id JOIN payment as p ON p.rental_id=r.rental_id JOIN address as a ON a.address_id=c.address_id JOIN city as city ON a.city_id=city.city_id JOIN country as country ON country.country_id=city.country_id WHERE country.country ='France' or country.country ='Italy' or country.country ='Germany' GROUP BY c.customer_id ORDER BY RentalAmount desc; #4- List top 20 Customers (Last name, First Name) by rental amount (ranked) for comedy films – bar chart & sql #query SELECT row_number() OVER (ORDER BY sum(p.amount) DESC) AS 'Rank', c.last_name,c.first_name, sum(p.amount) as RentalAmount FROM customer AS c JOIN rental AS r ON c.customer_id = r.customer_id JOIN inventory as i ON r.inventory_id=i.inventory_id JOIN film_category as f ON f.film_id=i.film_id JOIN category as ct ON ct.category_id=f.category_id JOIN payment as p ON p.rental_id=r.rental_id WHERE ct.name = 'Comedy' GROUP BY c.customer_id limit 20; #5-List top 10 Customers (Last name, First Name) from China by rental amount (ranked) for films that have #replacement costs greater than $24 – bar chart & sql query SELECT row_number() OVER (ORDER BY sum(p.amount) DESC) AS 'Rank',c.last_name,c.first_name, sum(p.amount) as RentalAmount FROM customer AS c JOIN rental AS r ON c.customer_id = r.customer_id JOIN inventory as i ON r.inventory_id=i.inventory_id JOIN film_category as f ON f.film_id=i.film_id JOIN film as fi ON fi.film_id=f.film_id JOIN category as ct ON ct.category_id=f.category_id JOIN payment as p ON p.rental_id=r.rental_id JOIN address as a ON a.address_id=c.address_id JOIN city as city ON a.city_id=city.city_id JOIN country as country ON country.country_id=city.country_id WHERE country.country ='China' AND fi.replacement_cost>24 GROUP BY c.customer_id limit 10;
true
d0a7ac6dcf6260e2612373a461861308a2d98467
SQL
ackentdev/my-shared-library
/db/get_concerts.sql
UTF-8
159
3.25
3
[]
no_license
select c.concert_id, c.concert_name, c.date, sl.song_name, sl.catalog_id from concerts c join song_library sl on (sl.song_id = c.song_id) where c.user_id = $1;
true
3c246692317c29cb058013ef5c5fb4edba52adb7
SQL
marlonmoreira1/sql_projects
/INTRODUÇÃO AO SQL (SQLITE).sql
UTF-8
475
3.4375
3
[]
no_license
select c.name,p.price,p.description,o.order_date,o.order_qty from customer_order o join customer c on c.CUSTOMER_ID = o.customer_id join product p on o.product_id = p.product_id; select name, city ||' , '|| state ||' , '|| zip as location from customer; select name,street_address ||' '|| city ||' , '|| state ||' '|| zip as location from customer; ] select name,street_address || ' ' || city || ' ' || state || ' ' || zip as location from customer;
true
37ab03bcb19ece720b367c4b8757cdf84e616c8a
SQL
cfpb/HMDA_Data_Science_Kit
/load_scripts/SQL/create_and_load_ts_2020.sql
UTF-8
455
2.765625
3
[ "CC0-1.0" ]
permissive
DROP TABLE IF EXISTS hmda_public.ts_2020; CREATE TABLE hmda_public.ts_2020 ( activity_year VARCHAR(4), calendar_quarter VARCHAR(1), lei VARCHAR(20), tax_id VARCHAR(10), agency_code VARCHAR(1), respondent_name VARCHAR, respondent_state VARCHAR(2), respondent_city VARCHAR, respondent_zip_code VARCHAR, lar_count VARCHAR ); COPY hmda_public.ts_2020 FROM '{data_path}/data/ts/ts_2020.txt' DELIMITER '|' ENCODING 'latin1' CSV HEADER; COMMIT;
true
b46a79f6702945ce812a37ef8066acabdf76a9e4
SQL
lucasDSBR/Sistema_Simples
/db/users.sql
UTF-8
1,860
2.921875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.0.4 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Tempo de geração: 14-Fev-2021 às 03:10 -- Versão do servidor: 10.4.14-MariaDB -- versão do PHP: 7.3.26 -- Desenvolvido por Lucas Silva -- E-mail: lucasmaciel6690@gmail.com -- linkedin(Lucas Silva): https://www.linkedin.com/in/lucas-silva-a9582b188/ -- Lattes: http://lattes.cnpq.br/6136104141544990 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Banco de dados: `usuarios` -- -- -------------------------------------------------------- -- -- Estrutura da tabela `users` -- CREATE TABLE `users` ( `id_user` int(10) NOT NULL, `nome_user` varchar(50) NOT NULL, `email_user` varchar(50) NOT NULL, `cidade_user` varchar(40) NOT NULL, `telefone_user` varchar(10) NOT NULL, `funcao_user` varchar(40) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Extraindo dados da tabela `users` -- INSERT INTO `users` (`id_user`, `nome_user`, `email_user`, `cidade_user`, `telefone_user`, `funcao_user`) VALUES (1, 'testando', 'testando@gmail.com', 'Testando-Testando', '000000000', 'Teste'); -- -- Índices para tabelas despejadas -- -- -- Índices para tabela `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id_user`); -- -- AUTO_INCREMENT de tabelas despejadas -- -- -- AUTO_INCREMENT de tabela `users` -- ALTER TABLE `users` MODIFY `id_user` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
c25d52c73d8080af72de5caf931842ae4698751b
SQL
willogrady/Skill-map
/AzureResourceGroup5/createroletable.sql
UTF-8
4,824
3.28125
3
[]
no_license
USE svccompanyrolesdb DROP TABLE IF EXISTS [role_competency_skill_map]; DROP TABLE IF EXISTS [role_company_skill_map]; DROP TABLE IF EXISTS [role_skill_map]; DROP TABLE IF EXISTS [role]; DROP TABLE IF EXISTS [role_group]; CREATE TABLE role_skill_map ( [role_skill_map_id] INT NOT NULL IDENTITY, [role_id] INT NOT NULL, [skillcode] VARCHAR(45) NOT NULL, [level] INT NOT NULL, [required] SMALLINT NOT NULL DEFAULT 1, [version_id] INT NOT NULL DEFAULT 1, PRIMARY KEY ([role_skill_map_id])); CREATE TABLE role ( [role_id] INT NOT NULL IDENTITY, [role_title] VARCHAR(45) NOT NULL, [role_grade] VARCHAR(45) NULL, [version_id] INT NOT NULL DEFAULT 1, [role_summary] VARCHAR(45) NULL, [role_group_id] INT NOT NULL, PRIMARY KEY ([role_id])); CREATE TABLE role_group ( [role_group_id] INT NOT NULL IDENTITY, [role_group] VARCHAR(45) NOT NULL, [version_id] VARCHAR(45) NOT NULL DEFAULT 1, PRIMARY KEY ([role_group_id])); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Technical Architect',1); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Solution Architect',1); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Data Architect',1); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Cheif Architect',1); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Chief Architect',1); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Senior Technical Architect',1); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Senior Solution Architect',1); INSERT INTO role ([role_title],[role_group_id],[role_grade]) VALUES ('Senior Business Analyst',2,'G6'); INSERT INTO role ([role_title],[role_group_id],[role_grade]) VALUES ('Junior Business Analyst',2,'G4'); INSERT INTO role ([role_title],[role_group_id],[role_grade]) VALUES ('Principal Business Analyst',2,'G5'); INSERT INTO role ([role_title],[role_group_id],[role_grade]) VALUES ('Business Analyst',2,'G5'); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Project Manager',4); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Software Engineer',5); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Human Resources Business Partner',7); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Test Architect - Non-Functional',9); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Associate Test Architect- Non-Functional',9); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Senior Test Architect - Functional',9); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Associate Test Architect - Functional',9); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Senior Test Engineer',9); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Test Engineer',9); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Senior Test Architect - Non-functional',9); INSERT INTO role ([role_title],[role_group_id],[role_grade]) VALUES ('Senior Test Manager',9,'G12'); INSERT INTO role ([role_title],[role_group_id],[role_grade]) VALUES ('Test Lead',9,'G8'); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Test Architect - Functional',9); INSERT INTO role ([role_title],[role_group_id],[role_grade]) VALUES ('Test Analyst',9,'G5'); INSERT INTO role ([role_title],[role_group_id],[role_grade]) VALUES ('Graduate/Trainee Test Engineer',9,'T2'); INSERT INTO role ([role_title],[role_group_id]) VALUES ('Test Manager',9); INSERT INTO role ([role_title],[role_group_id],[role_grade]) VALUES ('Group Manager/Geographical Head of Testing',9,'G14'); INSERT INTO role_group ([role_group]) VALUES ('Architecture'); INSERT INTO role_group ([role_group]) VALUES ('Business Analysis'); INSERT INTO role_group ([role_group]) VALUES ('Consulting'); INSERT INTO role_group ([role_group]) VALUES ('Delivery Management'); INSERT INTO role_group ([role_group]) VALUES ('Engineering'); INSERT INTO role_group ([role_group]) VALUES ('Finance'); INSERT INTO role_group ([role_group]) VALUES ('Human Resources'); INSERT INTO role_group ([role_group]) VALUES ('Support & Operations'); INSERT INTO role_group ([role_group]) VALUES ('Testing'); CREATE TABLE role_company_skill_map ( [role_skill_map_id_company] INT NOT NULL IDENTITY, [role_id] INT NOT NULL, [company_skill_id] INT NOT NULL, [level] INT NOT NULL, [required] SMALLINT NOT NULL DEFAULT 1, [version_id] INT NOT NULL DEFAULT 1, PRIMARY KEY ([role_skill_map_id_company])); CREATE TABLE role_competency_skill_map ( [role_skill_map_id_competency] INT NOT NULL IDENTITY, [role_id] INT NOT NULL, [competency_id] INT NOT NULL, [level] INT NOT NULL, [required] SMALLINT NOT NULL DEFAULT 1, [version_id] INT NOT NULL DEFAULT 1, PRIMARY KEY ([role_skill_map_id_competency]));
true
f50abc1d576452849b7008d77de1eb78e336f8a1
SQL
zweihan/didactic-waddle
/ddl.cql
UTF-8
2,035
3.53125
4
[]
no_license
CREATE TYPE IF NOT EXISTS cs4224.address ( street_1 text, street_2 text, city text, state text, zipcode text ); CREATE TYPE IF NOT EXISTS cs4224.order_line ( ol_i_id int, ol_delivery_d timestamp, ol_amount decimal, ol_supply_w_id int, ol_quantity decimal, ol_dist_info varchar ); CREATE TABLE IF NOT EXISTS cs4224.warehouse ( w_id int PRIMARY KEY, w_name text, w_address frozen<address>, w_tax decimal, w_ytd decimal ); CREATE TABLE IF NOT EXISTS cs4224.district ( d_w_id int, d_id int, d_name text, d_address frozen<address>, d_tax decimal, d_w_tax decimal, d_ytd decimal, d_next_o_id int, primary key ((d_w_id, d_id)) ); CREATE TABLE IF NOT EXISTS cs4224.customer ( c_w_id int, c_d_id int, c_id int, c_first text, c_middle text, c_last text, c_address frozen<address>, c_phone text, c_balance decimal, c_since timestamp, c_credit text, c_credit_lim decimal, c_discount decimal, c_ytd_payment decimal, c_payment_cnt int, c_delivery_cnt int, c_data text, primary key ((c_w_id, c_d_id), c_id) ); CREATE TABLE IF NOT EXISTS cs4224.customer_balance ( c_w_id int, c_d_id int, c_id int, c_balance decimal, primary key((c_d_id), c_balance, c_w_id, c_id) )with clustering order by (c_balance desc); CREATE TABLE IF NOT EXISTS cs4224.item ( i_id int primary key, i_name text, i_price decimal, i_im_id int, i_data text ); CREATE TABLE IF NOT EXISTS cs4224."order" ( o_w_id int, o_d_id int, o_id int, o_c_id int, o_carrier_id int, o_ol_cnt int, o_all_local boolean, o_entry_d timestamp, o_o_lines list<frozen<order_line>>, primary key ((o_w_id, o_d_id), o_id)); CREATE INDEX order_o_id on cs4224."order" (o_id); CREATE INDEX order_o_c_id on cs4224."order" (o_c_id); CREATE TABLE IF NOT EXISTS cs4224.stock ( s_w_id int, s_i_id int, s_price decimal, s_name text, s_quantity int, s_ytd decimal, s_order_cnt int, s_remote_cnt int, s_dist_01 text, s_dist_02 text, s_dist_03 text, s_dist_04 text, s_dist_05 text, s_dist_06 text, s_dist_07 text, s_dist_08 text, s_dist_09 text, s_dist_10 text, s_data text, primary key (s_w_id, s_i_id) );
true
89302edaf9a109fe11ab3380e2a9b1b4a7050b58
SQL
Kickrop/sql_statreg
/statreg_7.sql
WINDOWS-1251
6,398
3.578125
4
[]
no_license
select count(distinct x.okpo) --, gr3, pole_67 from ( select a.okpo, gr3, pole_67, pole_8, pole_7, pole_6, pole_27 from statregistr.razdel_1_2_1 a join statregistr.razdel_1_1 b on a.okpo=b.okpo join statregistr.statregistr7 c on a.okpo=c.pole_1 or (c.pole_3=a.okpo) where a.gr3='1' and c.pole_67 like '%005%' ) x join statregistr.licenses_edited d on (x.pole_8=d.inn) or (x.pole_27=d.ogrn) or (x.pole_7=d.fullname) or (x.pole_6=d.shortname) -- select distinct x.okpo, gr3, pole_67 from ( select a.okpo, gr3, pole_67, pole_8, pole_7, pole_6, pole_27 from statregistr.razdel_1_2_1 a join statregistr.razdel_1_1 b on a.okpo=b.okpo join statregistr.statregistr7 c on a.okpo=c.pole_1 or (c.pole_3=a.okpo) join statregistr.licenses_edited d on (c.pole_8=d.inn) or (c.pole_27=d.ogrn) or (c.pole_7=d.fullname) or (c.pole_6=d.shortname) where a.gr3='1' and c.pole_67 not like '%005%' ) x -- select distinct x.okpo, gr3, count(edu_level) --, pole_67 SIMILAR TO '005'--REGEXP_MATCHES(pole_67,'005') pole_67_005 --count(distinct a.okpo) --distinct a.okpo--count(distinct a.okpo) --REGEXP_MATCHES(pole_67,'005') from ( select a.okpo, gr3, pole_8, pole_67, pole_7, pole_6, pole_27, edu_level from statregistr.razdel_1_2_2 a join statregistr.razdel_1_1 b on a.okpo=b.okpo join statregistr.statregistr7 c on a.okpo=c.pole_1 or (c.pole_3=a.okpo) --join statregistr.licenses_edited d on (c.pole_8=d.inn) or (c.pole_27=d.ogrn) or (c.pole_7=d.fullname) or (c.pole_6=d.shortname) --or (b.kpp=d.kpp) --or c.pole_7=d.fullname join statregistr.licenses_edited d on (c.pole_8=d.inn) --or (x.pole_27=d.ogrn) or (x.pole_7=d.fullname) or (x.pole_6=d.shortname) where a.gr3='1' and a.str_n = 1 and pole_67 not like '%054%' and edu_level not in (' ', ' ') --and branch = '1'--and d.inn is null --group by x.okpo ) x group by x.okpo, gr3 -- select distinct x.okpo, gr3, edu_level --, pole_67 SIMILAR TO '005'--REGEXP_MATCHES(pole_67,'005') pole_67_005 --count(distinct a.okpo) --distinct a.okpo--count(distinct a.okpo) --REGEXP_MATCHES(pole_67,'005') from ( select a.okpo, gr3, pole_8, pole_67, pole_7, pole_6, pole_27 from statregistr.razdel_1_2_2 a join statregistr.razdel_1_1 b on a.okpo=b.okpo join statregistr.statregistr7 c on a.okpo=c.pole_1 or (c.pole_3=a.okpo) --join statregistr.licenses_edited d on (c.pole_8=d.inn) or (c.pole_27=d.ogrn) or (c.pole_7=d.fullname) or (c.pole_6=d.shortname) --or (b.kpp=d.kpp) --or c.pole_7=d.fullname where a.gr3='2' and a.str_n = 1 and pole_67 like '%054%' ) x join statregistr.licenses_edited d on (x.pole_8=d.inn) --or (x.pole_27=d.ogrn) or (x.pole_7=d.fullname) or (x.pole_6=d.shortname) where edu_level not in (' ', ' ') -- select x.okpo , case when add_okved_85_41 = 1 then ' 85.41' end , case when pole_22_85_41 is null then ' 85.41' end from (select okpo, avg(case when left(gr4_okved_add,5) = '85.41' then 1 end) add_okved_85_41 from statregistr.additional_okved where str_n = 2 group by okpo ) x join (select okpo , avg(case when left(pole_22_trimed,5) = '85.41' then 1 end) pole_22_85_41 , avg(case when left(pole_22_trimed,5) <> '85.41' then 2 end) pole_22_not from statregistr._1_dop_reg_okved_statregistr7 group by okpo ) y on (x.okpo = y.okpo) where pole_22_85_41 is null and add_okved_85_41 is not null --- CREATE MATERIALIZED VIEW statregistr._1_dop_fact_okved_statregistr7 AS select okpo, trim(from pole_79_unnested) pole_79_trimed from ( select okpo,pole_79_ed, unnest(pole_79_ed) pole_79_unnested --select okpo,pole_22_ed--, trim(from pole_22_ed) --pole_22_trimed from (SELECT * from statregistr.okpo_statreg_by_gleb) a join (SELECT pole_1, string_to_array(pole_79,';') pole_79_ed FROM statregistr._0_statregistr7 ) b on (a.okpo = b.pole_1) --limit 100 ) c WITH DATA; --- select max(length(shortname)) from licenses_edited ALTER TABLE statregistr7 ALTER COLUMN pole_6 TYPE varchar(500) USING pr_code_upd::integer ALTER TABLE licenses_edited ALTER COLUMN shortname TYPE varchar(500) USING pr_code_upd::integer --DROP index statregistr_statregistr7_fullname create index statregistr_statregistr7_fullname_ on _0_statregistr7 ("pole_7"); create index "_statregistr_statregistr7_id_" on statregistr._0_statregistr7 ("pole_3"); create index "_statregistr_statregistr7_inn_" on statregistr._0_statregistr7 ("pole_8"); create index "_statregistr_statregistr7_ogrn_" on statregistr._0_statregistr7 ("pole_27"); create index "_statregistr_statregistr7_okpo_" on statregistr._0_statregistr7 ("pole_1"); create index "_statregistr_statregistr7_shortname_" on statregistr._0_statregistr7 ("pole_6"); create index "_statregistr_statregistr7_9_" on statregistr._0_statregistr7 ("pole_9"); create index "_statregistr_statregistr7_2" on statregistr._0_statregistr7 ("pole_2"); SELECT * FROM ( select okpo_statreg_by_gleb.okpo from ( statregistr.okpo_statreg_by_gleb LEFT JOIN statregistr.razdel_1_1 ON statregistr.okpo_statreg_by_gleb.okpo = statregistr.razdel_1_1.okpo --WHERE statregistr.razdel_1_1.okpo is null and len(okpo)=14 And Right(RTrim(okpo),3)>1 ) as a ) as b INNER JOIN statregistr.statregistr7 on statregistr7.pole_3 = b.okpo ; select count(*) from statregistr.razdel_2 delete from statregistr.razdel_2 --drop table public.additional_okved --select * --x.okpo, statregistr.statregistr7.pole_3 --from ( select max(length(pole_3)) from statregistr.statregistr7 --3b select okpo_statreg_by_gleb.okpo, pole_3 from statregistr.okpo_statreg_by_gleb LEFT JOIN statregistr.razdel_1_1 ON okpo_statreg_by_gleb.okpo = razdel_1_1.okpo join statregistr.statregistr7 on okpo_statreg_by_gleb.okpo = statregistr.statregistr7.pole_1 WHERE statregistr.razdel_1_1.okpo is null and length(okpo_statreg_by_gleb.okpo) = 14 and right(TRIM(okpo_statreg_by_gleb.okpo),3) > '001' --len(okpo)=14 And Right(RTrim(okpo),3)>1 and okpo_statreg_by_gleb.okpo <> pole_3 --) x --- ) a join statregistr.statregistr7 on a.okpo = statregistr.statregistr7.pole_3 limit 100 ) as a ) as b INNER JOIN statregistr.statregistr7 on statregistr7.pole_3 = b.okpo
true
f68ff56543cc5fdd6b1d370e1b4af8287d0c85f4
SQL
asurkis/databases-coursework-pt3
/indices.sql
UTF-8
2,455
4
4
[]
no_license
-- QUERY PLAN -- -------------------------------------------------------------------------------- -- ------------------ -- Seq Scan on human (cost=0.00..49.56 rows=1 width=110) (actual time=0.013..0.13 -- 4 rows=4 loops=1) -- Filter: (name = 'Human n+1'::text) -- Rows Removed by Filter: 1001 -- Planning Time: 0.096 ms -- Execution Time: 0.147 ms -- (5 строк) -- db_coursework=# create index on human (name); -- CREATE INDEX -- db_coursework=# explain analyze select * from human where name = 'Human n+1'; -- QUERY PLAN -- -------------------------------------------------------------------------------- -- ---------------------------------------- -- Index Scan using human_name_idx on human (cost=0.28..8.29 rows=1 width=110) (a -- ctual time=0.014..0.015 rows=4 loops=1) -- Index Cond: (name = 'Human n+1'::text) -- Planning Time: 0.115 ms -- Execution Time: 0.024 ms -- (4 строки) CREATE INDEX ON human (name); -- QUERY PLAN -- -------------------------------------------------------------------------------- -- ----------------------- -- Seq Scan on tournament (cost=0.00..1.31 rows=25 width=85) (actual time=0.011.. -- 0.013 rows=14 loops=1) -- Filter: (place = 'Улица Пушкина, дом Колотушкина'::text) -- Rows Removed by Filter: 11 -- Planning Time: 0.055 ms -- Execution Time: 0.023 ms -- (5 строк) -- db_coursework=# create index on tournament (place); -- CREATE INDEX -- db_coursework=# explain analyze select * from tournament where place = 'Улица Пушкина, дом Колотушкина'; -- QUERY PLAN -- -------------------------------------------------------------------------------- -- ----------------------- -- Seq Scan on tournament (cost=0.00..1.31 rows=14 width=68) (actual time=0.009.. -- 0.011 rows=14 loops=1) -- Filter: (place = 'Улица Пушкина, дом Колотушкина'::text) -- Rows Removed by Filter: 11 -- Planning Time: 0.184 ms -- Execution Time: 0.021 ms -- (5 строк) -- Делать индекс на place -- не лучший выбор, т.к. время планирования увеличивается, -- а производительность -- нет (и сам индекс не используется)
true
b801482fc9cc532276dad56a8fcb905b2e5e8867
SQL
reva0807/course_progress_funnel
/assessment/ddl.sql
UTF-8
2,714
3.578125
4
[]
no_license
create schema course_progress_funnel; set search_path=course_progress_funnel; -- dim_geo_info create table if not exists dim_geo_info ( id BIGINT PRIMARY KEY, city VARCHAR(255) NOT NULL, state VARCHAR(255) NOT NULL, counry VARCHAR(255) NOT NULL ); -- dim_learner create table if not exists dim_learner ( id BIGINT PRIMARY KEY, email VARCHAR(255) NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, birthday DATE, gender VARCHAR(10), geo_id INT REFERENCES dim_geo_info(id), registration_time timestamp with time zone NOT NULL, is_active BOOLEAN DEFAULT TRUE NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -- dim_instructor create table if not exists dim_instructor ( id BIGINT PRIMARY KEY, email VARCHAR(255), first_name VARCHAR(255), last_name VARCHAR(255), institution VARCHAR(255), created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -- dim_course create table if not exists dim_course ( id VARCHAR(255) primary key, title VARCHAR(255) NOT NULL, instructor_id BIGINT NOT NULL REFERENCES dim_instructor(id), category VARCHAR(255), created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -- dim_module create table if not exists dim_module( id VARCHAR(50) PRIMARY KEY, title VARCHAR(255) NOT NULL, ordinal_position INT NOT NULL, course_id VARCHAR(255) NOT NULL REFERENCES dim_course(id), publish_timestampt timestamp with time zone NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -- dim_item create table if not exists dim_item ( id VARCHAR(50) PRIMARY KEY, title VARCHAR(255) NOT NULL, ordinal_position INT NOT NULL, module_id VARCHAR(50) NOT NULL REFERENCES dim_module(id), item_type VARCHAR(50) NOT NULL, estimated_finish_time INT DEFAULT 10 NOT NULL, publish_timestamp timestamp with time zone NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -- fct_item_activity create table if not exists fct_item_activity ( ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, learner_id BIGINT NOT NULL REFERENCES dim_learner(id), item_id VARCHAR(50) NOT NULL REFERENCES dim_item(id), action VARCHAR(255), result VARCHAR(255), start_timestamp timestamp with time zone NOT NULL, end_timestamp timestamp with time zone ); -- fct_enrollment create table if not exists fct_enrollment ( id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, learner_id BIGINT NOT NULL REFERENCES dim_learner(id), course_id VARCHAR(255) NOT NULL REFERENCES dim_course(id), enrollment_timestamp timestamp with time zone NOT NULL );
true
76f49877135d9efb169dc84a749d79dd49a6e5bc
SQL
zhengbigbig/first-spring-web
/src/main/resources/db/migration/V1__Create_tables.sql
UTF-8
429
2.90625
3
[]
no_license
create table user ( id bigint primary key auto_increment, name varchar(100) ); create table `match` ( id bigint primary key auto_increment, user_id bigint, score int ); insert into user(id,name) values ( 1,'AAA' ); insert into user(id,name) values ( 2,'BBB' ); insert into user(id,name) values ( 3,'CCC' ); insert into `match`(id,user_id,score) values ( 1,1,1000 ); insert into `match`(id,user_id,score) values ( 2,2,2000 );
true
cf3dc13b924a35d9dcafca8243c53ae66e12a78f
SQL
dingjinhui821/julive_database
/schema/julive_ods/yw_owl_project_monitor.sql
UTF-8
1,391
2.90625
3
[]
no_license
drop table if exists ods.yw_owl_project_monitor; create external table ods.yw_owl_project_monitor( id bigint comment '', order_id bigint comment '订单id', see_project_id bigint comment '带看id', see_employee_id bigint comment '带看咨询师id', city_id bigint comment '城市id', city_name string comment '城市名称', project_id bigint comment '带看楼盘id', stime int comment '带看楼盘开始时间', etime int comment '带看楼盘结束时间', create_datetime int comment '创建时间', update_datetime int comment '修改时间', etl_time string comment 'ETL跑数时间' ) row format delimited fields terminated by '\001' lines terminated by '\n' stored as textfile location '/dw/ods/yw_owl_project_monitor' ;
true
058e1ceaf885d3d8f7a74031d92f8ec386112088
SQL
stoianov00/Java
/Java MySQL/03.Built In Functions/15.Show All Games with Duration .sql
UTF-8
437
3.5
4
[]
permissive
SELECT name AS 'game', CASE WHEN HOUR(start) BETWEEN 0 AND 11 THEN 'Morning' WHEN HOUR(start) BETWEEN 12 AND 17 THEN 'Afternoon' ELSE 'Evening' END AS 'Part of the Day', CASE WHEN duration <= 3 THEN 'Extra Short' WHEN duration BETWEEN 4 AND 6 THEN 'Short' WHEN duration BETWEEN 7 AND 10 THEN 'Long' ELSE 'Extra Long' END AS 'Duration' FROM games ORDER BY name ASC;
true
1802dc0434c2d18fb5ecf191448fd1f0e37fd726
SQL
mebelousov/antlr_psql
/src/test/resources/sql/select/f6d194e2.sql
UTF-8
188
2.8125
3
[ "MIT" ]
permissive
-- file:rowtypes.sql ln:104 expect:true select unique1, unique2 from tenk1 where (unique1, unique2) < any (select ten, ten from tenk1 where hundred < 3) and unique1 <= 20 order by 1
true
b3ad7a18c94a9cde3defd1cd5fcb4578be7fb32f
SQL
gpulatov/postgreSQL_DataBase-testing
/Scripts/PostgreSQL_4.sql
UTF-8
3,118
4.28125
4
[]
no_license
/********************************* * PostgreSQL - 4 */ /*********************************** 1- Display country_id, country name, region id , region name from hr database */ select country_id, country_name, c.region_id, region_name from countries AS "c" inner join regions AS "r" on c.region_id = r.region_id; /*********************************** 2- Display All cities , country names from hr database */ select city, country_name from locations AS "l" inner join countries as "c" ON l.country_id = c.country_id order by country_name; /************************************ 3-Display the first and last name, department name, city, and state province for each employee. */ select first_name, last_name, department_name, city, state_province from employees as "e" inner join departments as "d" on e.department_id = d.department_id inner join locations as "l" on d.location_id = l.location_id; /************************************ 4-Display the first name, last name, department id and department name, for all employees for departments 80 or 40. */ select first_name, last_name, d.department_id, department_name from employees as "e" inner join departments as "d" on e.department_id = d.department_id where e.department_id = 80 or e.department_id = 40; /************************************* 5-Display employees first name, last name department id and all departments including those where does not have any employee. */ select first_name, last_name, d.department_id, department_name from employees as "e" right join departments as "d" on e.department_id = d.department_id /**************************************** 6-Display the first name, last name, department number and name, for all employees who have or have not any department. */ select first_name, last_name, d.department_id, department_name from employees as "e" left join departments as "d" on e.department_id = d.department_id /***************************************** 7-Display firstname,lastname,department_name,city,country and region name for all employees. */ select first_name, last_name, d.department_id, department_name, city, country_name, region_name from employees as "e" inner join departments as "d" on e.department_id = d.department_id inner join locations as "l" on d.location_id = l.location_id inner join countries as "c" on c.country_id = c.country_id inner join regions as "r" on r.region_id = c.region_id /****************************************** 8-I want to know how many copies of each movie we have at store 1. */ select f.title, count(title) from film as "f" inner join inventory as "i" on i.film_id = f.film_id where store_id = 1 group by f.title order by count(title) desc; /********************************************** 9-Display all customers first name,last name, phone,postal_code,city,country */ select first_name, last_name, phone, postal_code, city, country from customer as "c" inner join address as "a" on a.address_id = c.address_id inner join city as "cty" on cty.city_id = a.city_id inner join country as "cntry" on cntry.country_id = cty.country_id
true
15d0e0b81d409f676ff64461626e7c70b34625f8
SQL
joaommd/PeqCelulas
/criar_base_dados.sql
UTF-8
3,773
3.671875
4
[]
no_license
USE db_peqcelulas; DROP TABLE IF EXISTS demograficos; CREATE TABLE demograficos( doente_id INT AUTO_INCREMENT PRIMARY KEY, nd INT NOT NULL, data_nascimento DATE, genero VARCHAR (10), CONSTRAINT genero_chk CHECK ( genero IN ('Feminino', 'Masculino', 'Outro') ), PRIMARY KEY (doente_id) ); DROP TABLE IF EXISTS diagnosticos; CREATE TABLE diagnosticos( doente_id INT NOT NULL, data_diagnostico DATE NOT NULL, topografia VARCHAR(10) NOT NULL, histologia VARCHAR(10) NOT NULL, comportamento INT, grau INT, lateralidade VARCHAR(20), CONSTRAINT diagn_prmkey PRIMARY KEY ( doente_id, data_diagnostico, topografia, histologia ), CONSTRAINT lateralidade_chk CHECK ( lateralidade IN ( 'Direito', 'Esquerdo', 'Central', 'Desconhecido' ) ), CONSTRAINT diagn_frkey FOREIGN KEY (doente_id) REFERENCES demograficos(doente_id) ); DROP TABLE IF EXISTS estadios; CREATE TABLE estadios( doente_id INT NOT NULL, tipo VARCHAR(12) NOT NULL, data DATE NOT NULL, T VARCHAR(3) NOT NULL, N VARCHAR(3) NOT NULL, M VARCHAR(3) NOT NULL, agrupado VARCHAR(4), CONSTRAINT tipo_chk CHECK ( tipo IN ('Clínico', 'Patológico') ), PRIMARY KEY (doente_id, data, tipo), FOREIGN KEY (doente_id) REFERENCES demograficos(doente_id) ); DROP TABLE IF EXISTS actos_medicos; CREATE TABLE actos_medicos( doente_id INT NOT NULL, tipo_ato VARCHAR(20) NOT NULL, grupo_ato VARCHAR(20) NOT NULL, servico_executante VARCHAR(10) NOT NULL, data_acto DATE NOT NULL, estado VARCHAR (5), CONSTRAINT estado_chk CHECK ( estado IN ( 'VSEC', 'VCEC', 'VXEC', 'MSEC', 'MCEC', 'MXEC' ) ), FOREIGN KEY (doente_id) REFERENCES demograficos(doente_id) ); DROP TABLE IF EXISTS biometrias; CREATE TABLE biometrias( doente_id INT NOT NULL, data_hora TIMESTAMP NOT NULL, tipo VARCHAR(255) NOT NULL, valor FLOAT NOT NULL, unidades VARCHAR(20) NOT NULL, PRIMARY KEY (doente_id, data_hora, tipo), FOREIGN KEY (doente_id) REFERENCES demograficos(doente_id) ); DROP TABLE IF EXISTS ref_medicamentos; CREATE TABLE ref_medicamentos( codigo_medicamento VARCHAR (10) PRIMARY KEY, nome_medicamento VARCHAR(10) ); DROP TABLE IF EXISTS ref_protocolos; CREATE TABLE ref_protocolos( codigo_protocolo VARCHAR (10), nome_protocolo VARCHAR(10), PRIMARY KEY ( codigo_protocolo, nome_protocolo ) ); DROP TABLE IF EXISTS farmacos; CREATE TABLE farmacos( doente_id INT NOT NULL, data_administracao DATE NOT NULL, grupo_farmacoter VARCHAR(10), codigo_medicamento VARCHAR(10) NOT NULL, local_administracao VARCHAR(10), codigo_protocolo VARCHAR(10), CONSTRAINT localadmn_chk CHECK ( local_administracao IN ( 'Internamento', 'Hospital Dia', 'Ambulatório' ) ), PRIMARY KEY ( doente_id, data_administracao, codigo_medicamento ), FOREIGN KEY (doente_id) REFERENCES demograficos(doente_id), FOREIGN KEY (codigo_medicamento) REFERENCES ref_medicamentos(codigo_medicamento) ); DROP TABLE IF EXISTS adiamentos; CREATE TABLE adiamentos( doente_id INT NOT NULL, data_adiamento DATE NOT NULL, motivo VARCHAR(10), PRIMARY KEY (doente_id, data_adiamento), FOREIGN KEY (doente_id) REFERENCES demograficos(doente_id) ); DROP TABLE IF EXISTS radioterapia; CREATE TABLE radioterapia( doente_id INT NOT NULL, data_procedimento DATE NOT NULL, procedimento VARCHAR(10) NOT NULL, PRIMARY KEY ( doente_id, data_procedimento, procedimento ) ); DROP TABLE IF EXISTS ref_radioterapia; CREATE TABLE ref_radioterapia ( procedimento VARCHAR(10) PRIMARY KEY, tipo VARCHAR(10) NOT NULL, CONSTRAINT tipo_chk CHECK (tipo IN ('convencional' , 'estereotáxica')) );
true