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
d1219019d0fd67b8efc70e6625efcd8e175c2e4a
SQL
webmasteractivogroup/transporteactivo
/backend/transporteactivo/sql/querys.sql
UTF-8
4,929
3.53125
4
[]
no_license
SELECT distinct(ls."STOPID"), s."SHORTNAME", s."LONGNAME" FROM "LINESTOPS" ls JOIN "LINES" l ON ls."LINEID" = l."LINEID" JOIN "STOPS" s ON ls."STOPID" = s."STOPID" WHERE l."SHORTNAME" ~ '^E'; --- Donde solo paran los expresos SELECT distinct(ls."STOPID"), s."LONGNAME", substring(l."SHORTNAME" from 1 for 1) as "STOPTYPE" FROM "LINESTOPS" ls JOIN "LINES" l ON ls."LINEID" = l."LINEID" JOIN "STOPS" s ON ls."STOPID" = s."STOPID" WHERE l."SHORTNAME" LIKE 'E%' ORDER BY ls."STOPID"; ---- otra SELECT distinct(ls."STOPID"), case substring(l."SHORTNAME" from 1 for 1) when 'E' then 1 when 'T' then 1 when 'P' then 2 when 'A' then 3 end as "STOPTYPE", s."LONGNAME" FROM "LINESTOPS" ls JOIN "LINES" l ON ls."LINEID" = l."LINEID" JOIN "STOPS" s ON ls."STOPID" = s."STOPID" WHERE l."SHORTNAME" NOT LIKE 'R%' ORDER BY ls."STOPID"; CREATE VIEW stop_types AS SELECT distinct(ls."STOPID"), min(case substring(l."SHORTNAME" from 1 for 1) when 'E' then 1 when 'T' then 1 when 'P' then 2 when 'A' then 3 end) as "STOPTYPE" FROM "LINESTOPS" ls JOIN "LINES" l ON ls."LINEID" = l."LINEID" JOIN "STOPS" s ON ls."STOPID" = s."STOPID" WHERE l."SHORTNAME" NOT LIKE 'R%' GROUP BY ls."STOPID"; -- Query que crea la vista con los stoptype generados. CREATE OR REPLACE VIEW stop_types AS SELECT distinct(ls."STOPID"), min(case substring(l."SHORTNAME" from 1 for 1) when 'E' then 1 when 'T' then 1 when 'P' then 2 when 'A' then 3 end) as "STOPTYPE" FROM "LINESTOPS" ls JOIN "LINES" l ON ls."LINEID" = l."LINEID" JOIN "STOPS" s ON ls."STOPID" = s."STOPID" WHERE l."SHORTNAME" NOT LIKE 'R%' GROUP BY ls."STOPID"; -- GRANT ALL PRIVILEGES ON stop_types TO transporteactivo; -- Query que crea la vista para el autocompletado -- CREATE OR REPLACE VIEW search AS -- SELECT s."STOPID" AS id, s."LONGNAME" AS nombre, CAST(ms.tipo_parada AS varchar) AS extra, 'p' as tipo -- FROM "STOPS" s -- JOIN mio_miostops ms ON ms.stops_ptr_id = s."STOPID" -- UNION -- SELECT l."LINEID" AS id, l."SHORTNAME" AS nombre, l."DESCRIPTION" AS extra, 'r' as tipo -- FROM "LINES" l -- ORDER BY tipo DESC, nombre; -- -- Modificacion query Busqueda -- CREATE OR REPLACE VIEW search AS -- SELECT s."STOPID" AS id, s."LONGNAME" AS nombre, CAST(ms.tipo_parada AS varchar) AS extra, 'p' as tipo, -- CAST(s."DECIMALLATITUDE" AS varchar) || ';' || CAST(s."DECIMALLONGITUDE" AS varchar) AS extra2 -- FROM "STOPS" s -- JOIN mio_miostops ms ON ms.stops_ptr_id = s."STOPID" -- UNION -- SELECT l."LINEID" AS id, l."SHORTNAME" AS nombre, l."DESCRIPTION" AS extra, 'r' as tipo, CAST(larcs."ORIENTATION" AS varchar) as extra2 -- FROM "LINES" l -- JOIN "LINESARCS" larcs ON larcs."LINEID" = l."LINEID" -- ORDER BY tipo DESC, nombre; -- Modificacion Busqueda usando linevariant CREATE OR REPLACE VIEW search AS SELECT ms."STOPID" AS id, ms."LONGNAME" AS nombre, CAST(ms.tipo_parada AS varchar) AS extra, 'p' as tipo, CAST(ms."DECIMALLATITUDE" AS varchar) || ';' || CAST(ms."DECIMALLONGITUDE" AS varchar) AS extra2, ms."SHORTNAME" as linevariant FROM mio_miostops ms UNION SELECT lstops."LINEID" AS id , l."SHORTNAME" AS nombre, l."DESCRIPTION" AS extra, 'r' as tipo, CAST(lstops."ORIENTATION" as varchar) as extra2, CAST(MIN(lstops."LINEVARIANT") as varchar) AS linevariant FROM "LINESTOPS" lstops INNER JOIN "LINES" l ON (lstops."LINEID" = l."LINEID" AND l."SHORTNAME" NOT LIKE 'R%') GROUP BY l."SHORTNAME", lstops."LINEID", l."DESCRIPTION", lstops."ORIENTATION" ORDER BY tipo DESC, nombre; -- paradas por rutas CREATE OR REPLACE VIEW paradas_por_ruta AS SELECT "LINESARCS"."LINEARCID" as id , "LINESARCS"."LINEID" as lineid, "ARCS"."STOPS_STOPID_START" as stop_start_id, "STOPS"."LONGNAME" as stop_start_name, "STOPS"."DECIMALLATITUDE" as stop_start_lat, "STOPS"."DECIMALLONGITUDE" as stop_start_lng, "ARCS"."STOPS_STOPID_END" as stop_end_id, T5."LONGNAME" as stop_end_name, T5."DECIMALLATITUDE" as stop_end_lat, T5."DECIMALLONGITUDE" as stop_end_lng, "LINESARCS"."ARCSEQUENCE" as arcsequence, "LINESARCS"."ORIENTATION" as orientation, "LINESARCS"."LINEVARIANT" as linevariant FROM "ARCS" LEFT OUTER JOIN "LINESARCS" ON ("ARCS"."ARCID" = "LINESARCS"."ARCID") INNER JOIN "STOPS" ON ("ARCS"."STOPS_STOPID_START" = "STOPS"."STOPID") INNER JOIN "STOPS" T5 ON ("ARCS"."STOPS_STOPID_END" = T5."STOPID") -- GRANT ALL PRIVILEGES ON search TO transporteactivo; -- Query inicial que podría ayudar para crear las paradas compuestas SELECT s."STOPID", s."LONGNAME", substring (s."LONGNAME" from '^(.*) [ABCDabcd][0-9]$') as NAME, substring (s."LONGNAME" from '^.* ([ABCDabcd][0-9])$') as GATE FROM "STOPS" s JOIN mio_miostops ms ON s."STOPID" = ms.stops_ptr_id WHERE s."LONGNAME" ~* '.*[ABCD][0-9]$' AND ms.tipo_parada = 1 ORDER BY s."LONGNAME";
true
12c8e7780c4f005032f3802e1c936fd5202d22a2
SQL
thesyd1982/softcpa
/src/main/resources/scripts/configure-mysql.sql
UTF-8
1,478
3.140625
3
[]
no_license
## Use to run mysql db docker image, optional if you're not using a local mysqldb # docker run --name mysqldb -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql # connect to mysql and run as root user #Create Databases CREATE DATABASE scpa_dev; CREATE DATABASE scpa_prod; #Create database service accounts CREATE USER 'scpa_dev_user'@'localhost' IDENTIFIED BY 'Pq4s67Xa'; CREATE USER 'scpa_prod_user'@'localhost' IDENTIFIED BY 'Pq4s67Xa'; CREATE USER 'scpa_dev_user'@'%' IDENTIFIED BY 'Pq4s67Xa'; CREATE USER 'scpa_prod_user'@'%' IDENTIFIED BY 'Pq4s67Xa'; #Database grants GRANT SELECT ON scpa_dev.* to 'scpa_dev_user'@'localhost'; GRANT INSERT ON scpa_dev.* to 'scpa_dev_user'@'localhost'; GRANT DELETE ON scpa_dev.* to 'scpa_dev_user'@'localhost'; GRANT UPDATE ON scpa_dev.* to 'scpa_dev_user'@'localhost'; GRANT SELECT ON scpa_prod.* to 'scpa_prod_user'@'localhost'; GRANT INSERT ON scpa_prod.* to 'scpa_prod_user'@'localhost'; GRANT DELETE ON scpa_prod.* to 'scpa_prod_user'@'localhost'; GRANT UPDATE ON scpa_prod.* to 'scpa_prod_user'@'localhost'; GRANT SELECT ON scpa_dev.* to 'scpa_dev_user'@'%'; GRANT INSERT ON scpa_dev.* to 'scpa_dev_user'@'%'; GRANT DELETE ON scpa_dev.* to 'scpa_dev_user'@'%'; GRANT UPDATE ON scpa_dev.* to 'scpa_dev_user'@'%'; GRANT SELECT ON scpa_prod.* to 'scpa_prod_user'@'%'; GRANT INSERT ON scpa_prod.* to 'scpa_prod_user'@'%'; GRANT DELETE ON scpa_prod.* to 'scpa_prod_user'@'%'; GRANT UPDATE ON scpa_prod.* to 'scpa_prod_user'@'%';
true
4bdc8cbb1a6205ca4da362b9aa73c3f4ccfda787
SQL
jyuly12/holbertonschool-higher_level_programming
/0x0E-SQL_more_queries/7-cities.sql
UTF-8
325
3.453125
3
[]
no_license
-- Creates the database hbtn_0d_usa and the table cities on your MySQL server. CREATE DATABASE IF NOT EXISTS hbtn_0d_usa; CREATE TABLE IF NOT EXISTS hbtn_0d_usa.cities( PRIMARY KEY(id),id INT NOT NULL AUTO_INCREMENT, state_id INT NOT NULL,name VARCHAR(256) NOT NULL, FOREIGN KEY(state_id) REFERENCES hbtn_0d_usa.states(id));
true
a9b5e029ab1222aafad547832273ce9f63978b04
SQL
yiiapps/galaxy
/console/data/galaxy.sql
UTF-8
11,456
3.421875
3
[ "BSD-3-Clause", "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.0.4 -- http://www.phpmyadmin.net -- -- 主机: localhost -- 生成日期: 2015 年 04 月 14 日 06:37 -- 服务器版本: 5.6.12-log -- PHP 版本: 5.4.12 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 */; -- -- 数据库: `galaxy` -- CREATE DATABASE IF NOT EXISTS `galaxy` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; USE `galaxy`; -- -------------------------------------------------------- -- -- 表的结构 `auth_assignment` -- CREATE TABLE IF NOT EXISTS `auth_assignment` ( `item_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `user_id` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `created_at` int(11) DEFAULT NULL, PRIMARY KEY (`item_name`,`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -------------------------------------------------------- -- -- 表的结构 `auth_item` -- CREATE TABLE IF NOT EXISTS `auth_item` ( `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `type` int(11) NOT NULL, `description` text COLLATE utf8_unicode_ci, `rule_name` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, `data` text COLLATE utf8_unicode_ci, `created_at` int(11) DEFAULT NULL, `updated_at` int(11) DEFAULT NULL, PRIMARY KEY (`name`), KEY `rule_name` (`rule_name`), KEY `idx-auth_item-type` (`type`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -------------------------------------------------------- -- -- 表的结构 `auth_item_child` -- CREATE TABLE IF NOT EXISTS `auth_item_child` ( `parent` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `child` varchar(64) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`parent`,`child`), KEY `child` (`child`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -------------------------------------------------------- -- -- 表的结构 `auth_rule` -- CREATE TABLE IF NOT EXISTS `auth_rule` ( `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `data` text COLLATE utf8_unicode_ci, `created_at` int(11) DEFAULT NULL, `updated_at` int(11) DEFAULT NULL, PRIMARY KEY (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -------------------------------------------------------- -- -- 表的结构 `comment` -- CREATE TABLE IF NOT EXISTS `comment` ( `id` int(12) NOT NULL AUTO_INCREMENT, `parent_id` int(12) DEFAULT NULL, `post_id` int(12) NOT NULL, `user_id` int(12) NOT NULL DEFAULT '0', `text` text, `create_time` int(11) DEFAULT NULL, `update_time` int(11) DEFAULT NULL, `status` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `owner_name` (`post_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ; -- -------------------------------------------------------- -- -- 表的结构 `friend_link` -- CREATE TABLE IF NOT EXISTS `friend_link` ( `id` int(11) NOT NULL AUTO_INCREMENT, `category_id` int(11) DEFAULT NULL, `title` varchar(100) NOT NULL, `pic` varchar(255) NOT NULL, `url` varchar(200) NOT NULL, `memo` text NOT NULL, `sort_order` int(11) NOT NULL DEFAULT '255', `language` varchar(45) NOT NULL, `create_time` int(11) NOT NULL, `update_time` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=66 ; -- -------------------------------------------------------- -- -- 表的结构 `lookup` -- CREATE TABLE IF NOT EXISTS `lookup` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `code` int(11) NOT NULL, `type` varchar(128) NOT NULL, `position` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; -- -------------------------------------------------------- -- -- 表的结构 `menu` -- CREATE TABLE IF NOT EXISTS `menu` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `parent` int(11) DEFAULT NULL, `route` varchar(256) DEFAULT NULL, `order` int(11) DEFAULT NULL, `data` text, PRIMARY KEY (`id`), KEY `parent` (`parent`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- 表的结构 `migration` -- CREATE TABLE IF NOT EXISTS `migration` ( `version` varchar(180) CHARACTER SET utf8 NOT NULL, `apply_time` int(11) DEFAULT NULL, PRIMARY KEY (`version`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -------------------------------------------------------- -- -- 表的结构 `post` -- CREATE TABLE IF NOT EXISTS `post` ( `id` int(11) NOT NULL AUTO_INCREMENT, `category_id` int(11) NOT NULL DEFAULT '0', `user_id` int(11) DEFAULT '0', `language_id` int(11) DEFAULT '0', `star_id` int(11) DEFAULT '0', `cluster_id` int(11) DEFAULT '0', `station_id` int(11) DEFAULT '0', `title` varchar(200) NOT NULL, `url` varchar(100) DEFAULT NULL, `source` varchar(50) DEFAULT NULL, `summary` text, `content` text NOT NULL, `tags` text, `status` int(11) DEFAULT NULL, `views` int(11) NOT NULL DEFAULT '0', `allow_comment` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:allow;1:forbid', `create_time` int(11) NOT NULL, `update_time` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `FK_post_author` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=180 ; -- -------------------------------------------------------- -- -- 表的结构 `profile` -- CREATE TABLE IF NOT EXISTS `profile` ( `user_id` int(11) NOT NULL, `name` varchar(255) DEFAULT NULL, `public_email` varchar(255) DEFAULT NULL, `gravatar_email` varchar(255) DEFAULT NULL, `gravatar_id` varchar(32) DEFAULT NULL, `location` varchar(255) DEFAULT NULL, `website` varchar(255) DEFAULT NULL, `bio` text, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- 表的结构 `social_account` -- CREATE TABLE IF NOT EXISTS `social_account` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) DEFAULT NULL, `provider` varchar(255) NOT NULL, `client_id` varchar(255) NOT NULL, `data` text, PRIMARY KEY (`id`), UNIQUE KEY `account_unique` (`provider`,`client_id`), KEY `fk_user_account` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- 表的结构 `star` -- CREATE TABLE IF NOT EXISTS `star` ( `id` int(11) NOT NULL AUTO_INCREMENT, `skin_id` int(11) DEFAULT NULL, `cluster_id` int(11) DEFAULT NULL, `station_id` int(11) DEFAULT NULL, `name` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, `name_alias` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `domain` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `type` tinyint(1) DEFAULT NULL, `detail` text COLLATE utf8_unicode_ci, `start_date` int(11) DEFAULT NULL, `end_date` int(11) DEFAULT NULL, `create_time` int(11) DEFAULT NULL, `update_time` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- 表的结构 `station` -- CREATE TABLE IF NOT EXISTS `station` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `detail` text COLLATE utf8_unicode_ci, `enabled` tinyint(1) NOT NULL DEFAULT '0', `start_date` int(11) DEFAULT NULL, `end_date` int(11) DEFAULT NULL, `create_time` int(11) NOT NULL, `update_time` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ; -- -------------------------------------------------------- -- -- 表的结构 `tag` -- CREATE TABLE IF NOT EXISTS `tag` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `frequency` int(11) DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=40 ; -- -------------------------------------------------------- -- -- 表的结构 `token` -- CREATE TABLE IF NOT EXISTS `token` ( `user_id` int(11) NOT NULL, `code` varchar(32) NOT NULL, `created_at` int(11) NOT NULL, `type` smallint(6) NOT NULL, UNIQUE KEY `token_unique` (`user_id`,`code`,`type`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- 表的结构 `tree` -- CREATE TABLE IF NOT EXISTS `tree` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `root` int(10) unsigned DEFAULT NULL, `lft` int(10) unsigned NOT NULL, `rgt` int(10) unsigned NOT NULL, `level` smallint(5) unsigned NOT NULL, `type` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(128) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `root` (`root`), KEY `lft` (`lft`), KEY `rgt` (`rgt`), KEY `level` (`level`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=35 ; -- -------------------------------------------------------- -- -- 表的结构 `user` -- CREATE TABLE IF NOT EXISTS `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(25) NOT NULL, `email` varchar(255) NOT NULL, `password_hash` varchar(60) NOT NULL, `auth_key` varchar(32) NOT NULL, `confirmed_at` int(11) DEFAULT NULL, `unconfirmed_email` varchar(255) DEFAULT NULL, `blocked_at` int(11) DEFAULT NULL, `registration_ip` varchar(45) DEFAULT NULL, `created_at` int(11) NOT NULL, `updated_at` int(11) NOT NULL, `flags` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `user_unique_username` (`username`), UNIQUE KEY `user_unique_email` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=149 ; -- -- 限制导出的表 -- -- -- 限制表 `auth_assignment` -- ALTER TABLE `auth_assignment` ADD CONSTRAINT `auth_assignment_ibfk_1` FOREIGN KEY (`item_name`) REFERENCES `auth_item` (`name`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- 限制表 `auth_item` -- ALTER TABLE `auth_item` ADD CONSTRAINT `auth_item_ibfk_1` FOREIGN KEY (`rule_name`) REFERENCES `auth_rule` (`name`) ON DELETE SET NULL ON UPDATE CASCADE; -- -- 限制表 `auth_item_child` -- ALTER TABLE `auth_item_child` ADD CONSTRAINT `auth_item_child_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `auth_item` (`name`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `auth_item_child_ibfk_2` FOREIGN KEY (`child`) REFERENCES `auth_item` (`name`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- 限制表 `menu` -- ALTER TABLE `menu` ADD CONSTRAINT `menu_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `menu` (`id`) ON DELETE SET NULL ON UPDATE CASCADE; -- -- 限制表 `profile` -- ALTER TABLE `profile` ADD CONSTRAINT `fk_user_profile` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE; -- -- 限制表 `social_account` -- ALTER TABLE `social_account` ADD CONSTRAINT `fk_user_account` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE; -- -- 限制表 `token` -- ALTER TABLE `token` ADD CONSTRAINT `fk_user_token` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE 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
78e843985b541d6bdeffb055a02a0eee21cc3e1b
SQL
jmoloko/JdbcCrudConsoleApp
/src/main/resources/sql/create_dev_skill.sql
UTF-8
327
3.578125
4
[]
no_license
CREATE TABLE dev_skill ( dev_id INT NOT NULL, sk_id INT NOT NULL, PRIMARY KEY (dev_id, sk_id), FOREIGN KEY (dev_id) REFERENCES developer (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (sk_id) REFERENCES skill (id) ON DELETE CASCADE ON UPDATE CASCADE );
true
3f21ecd57e9f74162f7467bd8aac8114d6c69835
SQL
jaedeokhan/study-20-1-db-mysql
/labfile/LAB_02.sql
UTF-8
357
3.734375
4
[]
no_license
-- LAB # 02 -- 1. 한국에 있는 도시들 보기 SELECT Name FROM city WHERE CountryCode = 'KOR'; -- 2. 미국에 있는 도시들 보기 SELECT Name FROM city WHERE CountryCOde = 'USA'; -- 3. 한국에 있는 도시들 중에 인구 수가 1,000,000 이상인 도시 보기 SELECT Name FROM city WHERE CountryCode = 'KOR' AND Population >= 1000000;
true
be2c2a208d289eea1183a0a56c7d362d3b1dfad6
SQL
SiddTripathi/Database_sql
/Sql_Pract_5.sql
UTF-8
3,024
3.9375
4
[]
no_license
------Task 1------ drop table grade; drop table course; drop table student; --------1---- create table student (student_no varchar2(6),student_name varchar2(20) not null,student_address varchar2(50),CONSTRAINT student_student_no_pk PRIMARY KEY (student_no)); -------------2-- create table course (course_no varchar2(4),course_name varchar2(20) not null,course_details varchar2(50),CONSTRAINT course_course_no_pk PRIMARY KEY (course_no)); -----------3----- create table grade (student_no varchar2(6),course_no varchar2(4),grade number(3) not null,constraint grade_pk PRIMARY KEY (student_no,course_no), constraint grade_student_no_fk Foreign Key(student_no) References student(student_no),constraint grade_course_no_fk Foreign Key(course_no) References course(course_no)); -----Task2------- ----table category---- create table category ( category_id varchar2(2) not null, category_name varchar2(20), category_details varchar2(100), constraint category_category_id_pk primary key(category_id)); ----table item desc----- create table item_desc( item_id varchar2(6) not null, category_id varchar2(2) not null, primary_desc varchar2(50), secondary_desc varchar2(50), color_desc varchar2(10), size_desc varchar2(10), status_code char(1) not null, production_date date, expiry_date date, brand_name varchar2(20), constraint item_desc_pk primary key(item_id), constraint item_desc_category_fk foreign key(category_id) references category(category_id)); ----table store_information--- create table store_information( store_id varchar2(3) not null, store_name varchar2(20) not null, street_name varchar2(20), city varchar2(20), zip_code varchar2(6), phone_nbr varchar2(20), manager_name varchar2(30), open_sunday_flag char(1) not null, CONSTRAINT store_information_pk primary key(store_id) ); -----table membership_index----- create table members_index( membership_id varchar2(6) not null, customer_name varchar2(20), address varchar2(50), members_type varchar2(10) not null, join_date date not null, member_status char(1), member_points number(3), CONSTRAINT members_index_pk primary key(membership_id) ); --table store_visit---- create table store_visit( visit_id varchar2(6) not null, store_id varchar2(3) not null, membership_id varchar2(6) not null, transaction_date date, tot_unique_itm_cnt number(2), tot_visit_amt number(5,3), CONSTRAINT store_visit_pk primary key(visit_id), CONSTRAINT table9_store_information_fk foreign key(store_id) references store_information(store_id), CONSTRAINT table9_members_index_fk foreign key(membership_id) references members_index(membership_id) ); -----table item_scan----- create table item_scan( visit_id varchar2(6) not null, item_id varchar2(6) not null, quantity number(2), unit_cost number(5,3), unit_total_cost number(5,3), CONSTRAINT item_scan_pk primary key(visit_id,item_id), CONSTRAINT item_scan_item_desc_fk foreign key(item_id) references item_desc(item_id), CONSTRAINT item_scan_store_visit_fk foreign key(visit_id) references store_visit(visit_id) );
true
b57d4c37b533dde3a63484b24cc7a9ab3b76e3de
SQL
chri17g5/PET
/ThePetExamn/EverythingSQL/TableCreation.sql
UTF-8
1,386
3.515625
4
[]
no_license
USE PETexam CREATE TABLE Persons ( ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY, FirstName NVARCHAR(100) NOT NULL, LastName NVARCHAR(100) NOT NULL, Age INT NOT NULL, DateOfBirth DATE NOT NULL, Nationality NVARCHAR(100) NOT NULL, PersonalAddress NVARCHAR(100) NOT NULL, HeadShot NVARCHAR(MAX) NOT NULL, /* THIS IS A NVARCHAR BECAUSE I DON'T HAVE TIME TO LEARN PICTURE SAVINGS SO CALL IN PROGRAM AND DISPLAY FROM FOLDER */ Remarks NVARCHAR(MAX) --GangID INT FOREIGN KEY REFERENCES Gangs(ID), --AgentID INT FOREIGN KEY REFERENCES Agents(ID) ); CREATE TABLE Agents ( ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY, Department NVARCHAR(100) NOT NULL, DateOfEmployment DATE NOT NULL, Salery FLOAT NOT NULL ); CREATE TABLE Informants ( ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY, --GangID INT NOT NULL FOREIGN KEY REFERENCES Gangs(ID), --AgentID INT NOT NULL FOREIGN KEY REFERENCES Agents(ID), Deployment DATETIME NOT NULL, EndOfDeployment DATETIME NOT NULL ); CREATE TABLE Gangs ( ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY, GangName NVARCHAR(MAX) NOT NULL, LogoOrSymbol NVARCHAR(MAX) NOT NULL, /* THIS IS A NVARCHAR BECAUSE I DON'T HAVE TIME TO LEARN PICTURE SAVINGS SO CALL IN PROGRAM AND DISPLAY FROM FOLDER */ ThreatLevel NVARCHAR(100) NOT NULL, KnownLocations NVARCHAR(MAX), /* SHOULD BE ANOTHER TABLE OR A LIST OF LOCATIONS */ HasActiveCases BIT NOT NULL );
true
533e84e8eb4c8fd1dbd0fa5bbd20c05ce9d2549c
SQL
lpredova/ProjectBananko
/stvari/preradjenaERA.sql
UTF-8
8,136
3.28125
3
[]
no_license
-- MySQL Script generated by MySQL Workbench -- 06/11/15 00:32:28 -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; -- ----------------------------------------------------- -- Table `tip_korisnika` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tip_korisnika` ( `id_tip_korisnika` INT NOT NULL AUTO_INCREMENT, `naziv` VARCHAR(30) NOT NULL, `aktivan` TINYINT(1) NOT NULL, PRIMARY KEY (`id_tip_korisnika`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `status_korisnika` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `status_korisnika` ( `id_status_korisnika` INT NOT NULL AUTO_INCREMENT, `naziv` VARCHAR(30) NOT NULL, `opis` VARCHAR(200) NULL, PRIMARY KEY (`id_status_korisnika`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `korisnik` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `korisnik` ( `id_korisnik` INT NOT NULL AUTO_INCREMENT, `ime` VARCHAR(30) NOT NULL, `prezime` VARCHAR(30) NOT NULL, `adresa` VARCHAR(45) NOT NULL, `grad` VARCHAR(20) NOT NULL, `zupanija` VARCHAR(30) NOT NULL, `email` VARCHAR(80) NOT NULL, `datum_rodenja` DATE NOT NULL, `spol` CHAR(1) NOT NULL, `korisnicko_ime` VARCHAR(30) NOT NULL, `lozinka` VARCHAR(20) NOT NULL, `tip_korisnika_id_tip_korisnika` INT NOT NULL, `status_korisnika_id_status_korisnika` INT NOT NULL, PRIMARY KEY (`id_korisnik`), INDEX `fk_korisnik_tip_korisnika1_idx` (`tip_korisnika_id_tip_korisnika` ASC), INDEX `fk_korisnik_status_korisnika1_idx` (`status_korisnika_id_status_korisnika` ASC), CONSTRAINT `fk_korisnik_tip_korisnika1` FOREIGN KEY (`tip_korisnika_id_tip_korisnika`) REFERENCES `tip_korisnika` (`id_tip_korisnika`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_korisnik_status_korisnika1` FOREIGN KEY (`status_korisnika_id_status_korisnika`) REFERENCES `status_korisnika` (`id_status_korisnika`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `dnevnik_rada` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `dnevnik_rada` ( `id_dnevnik_rada` INT NOT NULL AUTO_INCREMENT, `radnja` VARCHAR(80) NOT NULL, `vrijeme` DATETIME NOT NULL, `korisnik_id_korisnik` INT NOT NULL, `aktivan` TINYINT(1) NULL, PRIMARY KEY (`id_dnevnik_rada`), INDEX `fk_dnevnik_rada_korisnik_idx` (`korisnik_id_korisnik` ASC), CONSTRAINT `fk_dnevnik_rada_korisnik` FOREIGN KEY (`korisnik_id_korisnik`) REFERENCES `korisnik` (`id_korisnik`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `prodavac` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `prodavac` ( `id_prodavac` INT NOT NULL AUTO_INCREMENT, `korisnik_id_korisnik` INT NOT NULL, `automobil_id_automobil` INT NOT NULL, `aktivan` TINYINT(1) NULL, PRIMARY KEY (`id_prodavac`, `automobil_id_automobil`), INDEX `fk_prodavac_korisnik1_idx` (`korisnik_id_korisnik` ASC), CONSTRAINT `fk_prodavac_korisnik1` FOREIGN KEY (`korisnik_id_korisnik`) REFERENCES `korisnik` (`id_korisnik`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sajam` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sajam` ( `id_sajam` INT NOT NULL AUTO_INCREMENT, `lokacija` VARCHAR(50) NOT NULL, `pocetak` DATETIME NOT NULL, `kraj` DATETIME NOT NULL, `aktivan` TINYINT(1) NULL, `korisnik_id_korisnik` INT NOT NULL, PRIMARY KEY (`id_sajam`), INDEX `fk_sajam_korisnik1_idx` (`korisnik_id_korisnik` ASC), CONSTRAINT `fk_sajam_korisnik1` FOREIGN KEY (`korisnik_id_korisnik`) REFERENCES `korisnik` (`id_korisnik`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sajam_has_prodavac` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sajam_has_prodavac` ( `sajam_id_sajam` INT NOT NULL, `prodavac_id_prodavac` INT NOT NULL, PRIMARY KEY (`sajam_id_sajam`, `prodavac_id_prodavac`), INDEX `fk_sajam_has_prodavac_prodavac1_idx` (`prodavac_id_prodavac` ASC), INDEX `fk_sajam_has_prodavac_sajam1_idx` (`sajam_id_sajam` ASC), CONSTRAINT `fk_sajam_has_prodavac_sajam1` FOREIGN KEY (`sajam_id_sajam`) REFERENCES `mydb`.`sajam` (`id_sajam`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_sajam_has_prodavac_prodavac1` FOREIGN KEY (`prodavac_id_prodavac`) REFERENCES `prodavac` (`id_prodavac`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`automobil` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `automobil` ( `id_automobil` INT NOT NULL AUTO_INCREMENT, `marka` VARCHAR(30) NOT NULL, `godiste` INT NOT NULL, `kilometraza` FLOAT NOT NULL, `snaga` FLOAT NOT NULL, `potrosnja` FLOAT NOT NULL, `tip_goriva` VARCHAR(30) NOT NULL, `dodatna_oprema` VARCHAR(200) NOT NULL, `pocetna_cijena` FLOAT NOT NULL, `zeljena_cijena` FLOAT NOT NULL, `ocjena` FLOAT NOT NULL, `kategorija_id_kategorija` INT ZEROFILL NOT NULL, `aktivan` TINYINT(1) NULL, PRIMARY KEY (`id_automobil`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `tip_dokumenta` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tip_dokumenta` ( `id_tip_dokumenta` INT ZEROFILL NOT NULL AUTO_INCREMENT, `naziv` VARCHAR(45) NOT NULL, `aktivan` VARCHAR(45) NULL, PRIMARY KEY (`id_tip_dokumenta`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `galerija` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `galerija` ( `id_galerija` INT NOT NULL AUTO_INCREMENT, `naziv_dokumenta` VARCHAR(80) NOT NULL, `tip_dokumenta_id_tip_dokumenta` INT ZEROFILL NOT NULL, `aktivan` TINYINT(1) NULL, `automobil_id_automobil` INT NOT NULL, PRIMARY KEY (`id_galerija`), INDEX `fk_galerija_tip_dokumenta1_idx` (`tip_dokumenta_id_tip_dokumenta` ASC), INDEX `fk_galerija_automobil1_idx` (`automobil_id_automobil` ASC), CONSTRAINT `fk_galerija_tip_dokumenta1` FOREIGN KEY (`tip_dokumenta_id_tip_dokumenta`) REFERENCES `tip_dokumenta` (`id_tip_dokumenta`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_galerija_automobil1` FOREIGN KEY (`automobil_id_automobil`) REFERENCES `automobil` (`id_automobil`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `korisnik_has_automobil` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `korisnik_has_automobil` ( `korisnik_id_korisnik` INT NOT NULL, `automobil_id_automobil` INT NOT NULL, PRIMARY KEY (`korisnik_id_korisnik`, `automobil_id_automobil`), INDEX `fk_korisnik_has_automobil_automobil1_idx` (`automobil_id_automobil` ASC), INDEX `fk_korisnik_has_automobil_korisnik1_idx` (`korisnik_id_korisnik` ASC), CONSTRAINT `fk_korisnik_has_automobil_korisnik1` FOREIGN KEY (`korisnik_id_korisnik`) REFERENCES `korisnik` (`id_korisnik`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_korisnik_has_automobil_automobil1` FOREIGN KEY (`automobil_id_automobil`) REFERENCES `automobil` (`id_automobil`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
true
2eee83239da233ae3a1ad97487a9fe5271b483b8
SQL
PavelK6896/9682Shop3JavaSpring
/src/main/resources/db/migration/V2__user.sql
UTF-8
1,727
3.796875
4
[]
no_license
create table users ( id bigserial, phone VARCHAR(30) not null UNIQUE, password VARCHAR(80) not null, email VARCHAR(50) UNIQUE, first_name VARCHAR(50), last_name VARCHAR(50), address_city VARCHAR(50), address_street VARCHAR(50), PRIMARY KEY (id) ); create table roles ( id serial, name VARCHAR(50) not null, primary key (id) ); create table privileges1 ( id serial, name VARCHAR(50) not null, primary key (id) ); 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 users (id), FOREIGN KEY (role_id) REFERENCES roles (id) ); create table roles_privileges1 ( role_id INT NOT NULL, privilege_id INT NOT NULL, primary key (role_id, privilege_id), FOREIGN KEY (role_id) REFERENCES roles (id), FOREIGN KEY (privilege_id) REFERENCES privileges1 (id) ); insert into roles (name) values ('USER'), ('ADMIN'); insert into privileges1 (name) values ('ROLE_USER'), ('ROLE_ADMIN'); insert into users (phone, password, first_name, last_name, email, address_city, address_street) values ('1','$2y$12$2LVAI8g8ci9Iq/Zod6Zb4uQYw1cLxTIG669BlOJP7W8Xo6dgeHVXa','admin','admin','admin@gmail.com', 'g', 'n'), ('2','$2y$12$2LVAI8g8ci9Iq/Zod6Zb4uQYw1cLxTIG669BlOJP7W8Xo6dgeHVXa','user','user','user@gmail.com', 'v', 'b'); insert into users_roles (user_id, role_id) values (1, 1), (2, 2); insert into roles_privileges1 (role_id, privilege_id) values (1, 1), (2, 1), (2, 2);
true
c88958cdda6bfde7197e1dac114703319ca8ff0b
SQL
waycambas8/Algoritma-genetika
/database/ag_tsp.sql
UTF-8
3,938
2.90625
3
[]
no_license
/* SQLyog Ultimate v9.50 MySQL - 5.5.5-10.1.29-MariaDB : Database - ag_tsp ********************************************************************* */ /*!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*/`app_genetika` /*!40100 DEFAULT CHARACTER SET latin1 */; USE `app_genetika`; /*Table structure for table `tb_admin` */ DROP TABLE IF EXISTS `tb_admin`; CREATE TABLE `tb_admin` ( `user` varchar(16) NOT NULL, `pass` varchar(16) DEFAULT NULL, PRIMARY KEY (`user`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*Data for the table `tb_admin` */ insert into `tb_admin`(`user`,`pass`) values ('admin','admin'); /*Table structure for table `tb_bobot` */ DROP TABLE IF EXISTS `tb_bobot`; CREATE TABLE `tb_bobot` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `ID1` varchar(16) DEFAULT NULL, `ID2` varchar(16) DEFAULT NULL, `bobot` double DEFAULT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM AUTO_INCREMENT=31 DEFAULT CHARSET=latin1; /*Data for the table `tb_bobot` */ insert into `tb_bobot`(`ID`,`ID1`,`ID2`,`bobot`) values (1,'T001','T001',0),(2,'T001','T002',9.983),(3,'T002','T002',0),(4,'T002','T001',10.056),(14,'T003','T002',13.416),(13,'T003','T001',18.962),(12,'T003','T003',0),(11,'T002','T003',9.144),(10,'T001','T003',14.233),(15,'T001','T004',11.106),(16,'T002','T004',11.3),(17,'T003','T004',23.133),(18,'T004','T004',0),(19,'T004','T001',11.239),(20,'T004','T002',11.323),(21,'T004','T003',21.266),(22,'T001','T005',22.033),(23,'T002','T005',20.058),(24,'T003','T005',17.709),(25,'T004','T005',29.066),(26,'T005','T005',0),(27,'T005','T001',22.153),(28,'T005','T002',20.157),(29,'T005','T003',18.734),(30,'T005','T004',29.086); /*Table structure for table `tb_kelompok` */ DROP TABLE IF EXISTS `tb_kelompok`; CREATE TABLE `tb_kelompok` ( `kode_kelompok` varchar(16) NOT NULL, `nama_kelompok` varchar(255) DEFAULT NULL, PRIMARY KEY (`kode_kelompok`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*Data for the table `tb_kelompok` */ insert into `tb_kelompok`(`kode_kelompok`,`nama_kelompok`) values ('K01','Pantai di Bali'); /*Table structure for table `tb_options` */ DROP TABLE IF EXISTS `tb_options`; CREATE TABLE `tb_options` ( `option_name` varchar(16) NOT NULL, `option_value` text, PRIMARY KEY (`option_name`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*Data for the table `tb_options` */ insert into `tb_options`(`option_name`,`option_value`) values ('cost_per_kilo','1500'),('default_lat','-0.789275'),('default_lng','113.92132700000002'),('default_zoom','5'); /*Table structure for table `tb_titik` */ DROP TABLE IF EXISTS `tb_titik`; CREATE TABLE `tb_titik` ( `kode_titik` varchar(16) NOT NULL, `nama_titik` varchar(255) DEFAULT NULL, `kode_kelompok` varchar(16) DEFAULT NULL, `lat` double DEFAULT NULL, `lng` double DEFAULT NULL, PRIMARY KEY (`kode_titik`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; /*Data for the table `tb_titik` */ insert into `tb_titik`(`kode_titik`,`nama_titik`,`kode_kelompok`,`lat`,`lng`) values ('T001','Pantai Nusa Dua','K01',-8.795761599999999,115.23282130000007),('T002','Pantai Jimbaran','K01',-8.7765946,115.1663701),('T003','Pantai Kuta','K01',-8.7202498,115.16917620000004),('T004','Pantai Pandawa','K01',-8.845280200000001,115.18706789999999),('T005','Pantai Sanur','K01',-8.674670299999999,115.26403290000007); /*!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
49a0b37dbc3dc2caca4042f1e20dac4813fb4779
SQL
arisolucion/civ6_mod_argentina
/civ6modargentinafixed/sql/SanMartin/MountainMovement.sql
UTF-8
8,470
2.734375
3
[]
no_license
--======================================================================================================================================== --======================================================================================================================================== -- IF YOU WANT TO USE THIS -- ======================= -- Simply include this file and add it to the database. -- Then if you want to make a unit walk on mountains, give them ABILITY_MOUNTAIN_MOVE_ALLOWED -- And... that's it :D --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== --======================================================================================================================================== INSERT OR REPLACE INTO Types (Type, Kind) VALUES ('MODIFIER_ALL_UNITS_NO_MOVE_TERRAIN', 'KIND_MODIFIER'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'KIND_ABILITY'); UPDATE Terrains SET Impassable = 0 WHERE TerrainType = 'TERRAIN_GRASS_MOUNTAIN'; UPDATE Terrains SET Impassable = 0 WHERE TerrainType = 'TERRAIN_PLAINS_MOUNTAIN'; UPDATE Terrains SET Impassable = 0 WHERE TerrainType = 'TERRAIN_DESERT_MOUNTAIN'; UPDATE Terrains SET Impassable = 0 WHERE TerrainType = 'TERRAIN_TUNDRA_MOUNTAIN'; UPDATE Terrains SET Impassable = 0 WHERE TerrainType = 'TERRAIN_SNOW_MOUNTAIN'; INSERT OR REPLACE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('LEU_NO_MOUNTAIN_MOVE_REQUIREMENT', 'REQUIREMENTSET_TEST_ALL'); INSERT OR REPLACE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('LEU_NO_MOUNTAIN_MOVE_REQUIREMENT', 'LEU_REQUIRES_NO_MOUNTAIN_ABILITY'); INSERT OR REPLACE INTO Requirements (RequirementId, RequirementType, Inverse) VALUES ('LEU_REQUIRES_NO_MOUNTAIN_ABILITY', 'REQUIREMENT_UNIT_HAS_ABILITY', 1); INSERT OR REPLACE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('LEU_REQUIRES_NO_MOUNTAIN_ABILITY', 'UnitAbilityType', 'ABILITY_MOUNTAIN_MOVE_ALLOWED'); INSERT OR REPLACE INTO UnitAbilities (UnitAbilityType, Name, Description, Inactive) VALUES ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'LOC_ABILITY_MOVE_MOUNTAINS_NAME', 'LOC_ABILITY_MOVE_MOUNTAINS_DESCRIPTION', 1); INSERT OR REPLACE INTO TypeTags (Type, Tag) VALUES ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_LANDCIVILIAN'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_LIGHT_CAVALRY'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_RANGED_CAVALRY'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_HEAVY_CAVALRY'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_RANGED'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_RECON'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_MELEE'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_ANTI_CAVALRY'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_SIEGE'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_TRADER'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_MEDIC'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_BATTERING_RAM'), ('ABILITY_MOUNTAIN_MOVE_ALLOWED', 'CLASS_SIEGE_TOWER'); INSERT OR REPLACE INTO GameModifiers (ModifierId) VALUES ('NO_GRASS_MOUNTAIN_MOVE'), ('NO_PLAINS_MOUNTAIN_MOVE'), ('NO_DESERT_MOUNTAIN_MOVE'), ('NO_TUNDRA_MOUNTAIN_MOVE'), ('NO_SNOW_MOUNTAIN_MOVE'); INSERT OR REPLACE INTO DynamicModifiers (ModifierType, CollectionType, EffectType) VALUES ('MODIFIER_ALL_UNITS_NO_MOVE_TERRAIN', 'COLLECTION_ALL_UNITS', 'EFFECT_ADJUST_UNIT_VALID_TERRAIN'); INSERT OR REPLACE INTO Modifiers (ModifierId, ModifierType, SubjectRequirementSetId) VALUES ('NO_GRASS_MOUNTAIN_MOVE', 'MODIFIER_ALL_UNITS_NO_MOVE_TERRAIN', 'LEU_NO_MOUNTAIN_MOVE_REQUIREMENT'), ('NO_PLAINS_MOUNTAIN_MOVE', 'MODIFIER_ALL_UNITS_NO_MOVE_TERRAIN', 'LEU_NO_MOUNTAIN_MOVE_REQUIREMENT'), ('NO_DESERT_MOUNTAIN_MOVE', 'MODIFIER_ALL_UNITS_NO_MOVE_TERRAIN', 'LEU_NO_MOUNTAIN_MOVE_REQUIREMENT'), ('NO_TUNDRA_MOUNTAIN_MOVE', 'MODIFIER_ALL_UNITS_NO_MOVE_TERRAIN', 'LEU_NO_MOUNTAIN_MOVE_REQUIREMENT'), ('NO_SNOW_MOUNTAIN_MOVE', 'MODIFIER_ALL_UNITS_NO_MOVE_TERRAIN', 'LEU_NO_MOUNTAIN_MOVE_REQUIREMENT'); INSERT OR REPLACE INTO ModifierArguments (ModifierId, Name, Value) VALUES ('NO_GRASS_MOUNTAIN_MOVE', 'TerrainType', 'TERRAIN_GRASS_MOUNTAIN'), ('NO_PLAINS_MOUNTAIN_MOVE', 'TerrainType', 'TERRAIN_PLAINS_MOUNTAIN'), ('NO_DESERT_MOUNTAIN_MOVE', 'TerrainType', 'TERRAIN_DESERT_MOUNTAIN'), ('NO_TUNDRA_MOUNTAIN_MOVE', 'TerrainType', 'TERRAIN_TUNDRA_MOUNTAIN'), ('NO_SNOW_MOUNTAIN_MOVE', 'TerrainType', 'TERRAIN_SNOW_MOUNTAIN'); --========================================================================================================================== --==========================================================================================================================
true
15eb8fbf20c53ab309e9399299d5c9e77075caae
SQL
DcodeDesign/learn-MySQL
/EXERCICES/EX_SELECT_INSERT_UPDATE_DELETE_UNDER-QUERY/EX1_SELECT_INSERT_UPDATE_DELETE_UNDER-QUERY.sql
UTF-8
42,781
4.375
4
[]
no_license
-- ****************************************************** -- ****************************************************** -- DOG_RACING -- ****************************************************** -- ****************************************************** -- 1. -- Pays avec ‘U’ USE Dog_Racing; SELECT * FROM pays WHERE pays.nomP LIKE '%U%'; -- 2. -- Pays sans ‘U’ USE Dog_Racing; SELECT * FROM Dog_Racing.pays where nomP NOT LIKE '%U%'; -- 3. -- Combien de pays sans ‘U’ USE Dog_Racing; SELECT count(nomP) FROM Dog_Racing.pays WHERE nomP NOT LIKE '%U%'; -- 4. -- Nom des chiens sans description USE Dog_Racing; SELECT * FROM Dog_Racing.chien WHERE descCh IS NULL; -- 5. -- ID, Nom et description des chiens ‘BE’ USE Dog_Racing; SELECT idCh, nomCh, descCh FROM chien WHERE nationCh = 'BE' ORDER BY nomCh ASC; -- 6. -- Combien de pays en tout USE Dog_Racing; SELECT count(nomP) FROM Dog_Racing.pays ORDER BY nomP ASC; -- 7. -- Course en 2014 USE Dog_Racing; SELECT nomC, YEAR(dateC) AS ANNEE FROM Dog_Racing.course HAVING ANNEE = '2014' ORDER BY nomC ASC; -- 8. -- Combien de pays DIFFÉRENTs accueillent des courses USE Dog_Racing; SELECT DISTINCT nomP FROM Dog_Racing.course INNER JOIN Dog_Racing.pays ON Dog_Racing.course.lieuC = Dog_Racing.pays.codeP ORDER BY nomP ASC; -- ****************************************************** -- ****************************************************** -- TINTIN -- ****************************************************** -- ****************************************************** -- 9. -- Pers (Nom, Prénom) ASC USE tintin; SELECT nomPers, prenomPers FROM personnage ORDER BY nomPers ASC; -- 10. -- Pers F sans prénom DESC USE tintin; SELECT nomPers, prenomPers, sexePers FROM personnage WHERE sexePers = 'F' AND prenomPers IS NULL ORDER BY nomPers DESC; -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1. -- Affichez la liste (par ordre alphabétique sur le nom) -- des personnages féminins ne possédant pas de prénom. USE tintin; SELECT nomPers FROM personnage WHERE sexePers = 'F' and prenomPers IS NULL ORDER BY nomPers ASC; -- 2. -- Affichez la liste des personnages (Nom et Prénom) présents -- dans l'album "L'ILE NOIRE" classés par idPers. USE tintin; SELECT nomPers, prenomPers FROM personnage INNER JOIN pers_album on personnage.idPers = pers_album.idPers INNER JOIN album on pers_album.idAlb = album.idAlb WHERE titreAlb = 'L''ILE NOIRE' ORDER BY personnage.idPers; -- 3. -- Quelles sont les dates de début et de fin des aventures de Tintin ? SELECT (SELECT dateAlb FROM album ORDER BY dateAlb ASC LIMIT 1) AS dateMin, (SELECT dateAlb FROM album ORDER BY dateAlb DESC LIMIT 1) AS dateMax; -- other solution SELECT MIN(dateAlb) AS dateMin, MAX(dateAlb) AS dateMax FROM album; -- 4. -- Quelle est l'année durant laquelle les personnages ont été les plus "grossiers" ? -- Indiquez le nombre de jurons prononcés durant cette année-là. SELECT count(juron_album.idJur) AS nbrJuron, dateAlb FROM album inner JOIN juron_album ON album.idAlb = juron_album.idAlb GROUP BY dateAlb ORDER BY nbrJuron DESC LIMIT 1; -- 5. -- Quel(s) est(sont) le(s) juron(s) qui est(sont) prononcés exactement 15 fois -- durant les aventures de Tintin ? SELECT count(juron_album.idJur) AS NbrJur, nomJur FROM juron_album inner JOIN juron ON juron_album.idJur = juron.idJur GROUP BY juron_album.idJur HAVING NbrJur = 15 ORDER BY NbrJur DESC; -- 6. -- Affichez le nom et la fonction des personnages féminins gentils classés par nom SELECT nomPers, fonctPers FROM personnage WHERE sexePers = 'F' AND gentilPers = 1 ORDER BY nomPers ASC; -- 7. -- Combien de personnage ont visité la Belgique, le Congo, le Népal ou l'Islande ? -- Affichez la réponse en détaillant le nombre pour chaque pays SELECT count(DISTINCT nomPers) AS nbrPers, GROUP_CONCAT(DISTINCT nomPays) FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays WHERE nomPays in ('BELGIQUE', 'CONGO', 'NEPAL', 'ISLANDE') GROUP BY pays.idPays ORDER BY nbrPers DESC; -- 8. -- Liste des albums classés par idAlb -- + pays associés à chaque album classés par ordre alphabétique -- (titreAlb, dateAlb, nomPays) SELECT titreAlb, dateAlb, nomPays FROM album INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays ORDER BY titreAlb ASC; -- 9. -- Quelles sont les dates des 2ème et avant-dernier albums -- des aventures de Tintin en considérant un ordre chronologique ? SELECT 2EME.titreAlb, 2EME.dateAlb, AVTDERN.titreAlb, AVTDERN.dateAlb FROM (SELECT * FROM album ORDER BY dateAlb ASC LIMIT 1,1) AS 2EME, (SELECT * FROM album ORDER BY dateAlb DESC LIMIT 1,1) AS AVTDERN; -- 10. -- Plusieurs albums de Tintin se déroulent dans plusieurs pays. -- Si le nombre de pays fréquentés est au nombre de 3, -- affichez ces pays ainsi que le titre de l'album. USE tintin; SELECT GROUP_CONCAT(DISTINCT nomPays), titreAlb FROM album INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays GROUP BY pays_album.idAlb HAVING COUNT(DISTINCT nomPays) = 3; -- other solution USE tintin; SELECT nomPays, titreAlb FROM album INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays HAVING titreAlb in (SELECT titreAlb FROM album INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays GROUP BY pays_album.idAlb HAVING COUNT(DISTINCT nomPays) = 3); -- 11. -- Liste des jurons (nom,id) commençant par "Espece de" classés par nom SELECT nomJur, idJur FROM juron WHERE nomJur LIKE 'Espece de%' ORDER BY nomJur ASC; -- 12. Liste des 5 plus grands jurons (nom, id, longueur) -- classés par longueur ( length() = longueur d’une chaîne de caractères) SELECT nomJur, idJur, LENGTH(nomJur) as TAILLE FROM juron ORDER BY TAILLE DESC LIMIT 5; -- 13. Pour chaque album (id, titre), -- le nom, le prénom et la fonction des personnages féminins SELECT album.idAlb, album.titreAlb, group_concat('nom : ',personnage.nomPers, ' prénom : ',personnage.nomPers, ' function : ', personnage.fonctPers, '\n' ) FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE personnage.sexePers = 'F' GROUP BY album.idAlb; -- other solution SELECT album.idAlb, album.titreAlb, personnage.nomPers, personnage.nomPers, personnage.fonctPers FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE personnage.sexePers = 'F' ORDER BY titreAlb; -- 14. -- Liste des gentils personnages féminins classé nom SELECT nomPers FROM personnage WHERE gentilPers = 1 and sexePers = 'F' ORDER BY nomPers; -- 15. -- liste des albums classé par id + Nombre de pays associé à chaque album -- (idalb, titre, année, Nb pays visités) SELECT album.idAlb, album.titreAlb, album.dateAlb, COUNT(DISTINCT nomPays) AS CPT FROM album INNER JOIN pays_album on album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays GROUP BY album.idAlb ORDER BY CPT, dateAlb, titreAlb ASC; -- 16. -- Année de réalisation de "Tintin au Congo" SELECT dateAlb FROM album WHERE titreAlb = 'Tintin au Congo'; -- 17. -- Prénom du Capitaine Haddock SELECT prenomPers FROM personnage WHERE nomPers = 'Haddock'; -- 18. -- Dans quel(s) pays se déroule(nt) "On a marche sur la lune" SELECT nomPays FROM pays INNER JOIN pays_album ON pays.idPays = pays_album .idPays INNER JOIN album ON pays_album.idAlb = album.idAlb WHERE titreAlb = 'On a marche sur la lune'; -- 19. -- La "Castafiore" pronnonce-t-elle des jurons ? SELECT CONCAT('La Castafiore a prononcé : ', COUNT(idJur), ' juron(s)') FROM personnage INNER JOIN juron_album on personnage.idPers = juron_album.idPers WHERE nomPers = 'Castafiore'; -- others solutions USE tintin; SELECT IF((SELECT COUNT(idJur) AS CPT FROM personnage INNER JOIN juron_album on personnage.idPers = juron_album.idPers WHERE nomPers = 'Castafiore') > 0, 'Oui', 'non'); -- 20. -- Nom des albums dans lesquels Tintin voyage en Chine SELECT DISTINCT titreAlb FROM personnage INNER JOIN pers_album ON pers_album.idPers = personnage.idPers INNER JOIN album ON album.idAlb = pers_album.idAlb INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays WHERE nomPays = 'CHINE'; -- 21. -- Quels sont les personnages non anonyme ayant prononcé plus de 100 jurons -- durant les aventures de Tintin SELECT nomPers, count(DISTINCT juron_album.idJur) AS CPT FROM personnage INNER JOIN juron_album on personnage.idPers = juron_album.idPers WHERE nomPers != 'anonyme' OR prenomPers != 'anonyme' GROUP BY personnage.idPers HAVING CPT > 100 ORDER BY CPT DESC; -- other solution SELECT nomPers FROM personnage INNER JOIN juron_album on personnage.idPers = juron_album.idPers WHERE nomPers != 'anonyme' OR prenomPers != 'anonyme' GROUP BY personnage.idPers HAVING count(DISTINCT juron_album.idJur) > 100; -- 22. -- Quel est le nombre de jurons prononcé par les personnages figurant -- dans "Le Lotus Bleu" SELECT nomPers, prenomPers, count(juron_album.idJur) FROM personnage INNER JOIN juron_album ON personnage.idPers = juron_album.idPers INNER JOIN album ON juron_album.idAlb = album.idAlb WHERE titreAlb = 'Le Lotus Bleu' GROUP BY personnage.idPers; -- 23. -- Quel est l'album ou haddock a prononce le plus de juron SELECT titreAlb, count(DISTINCT idJur) AS CPT FROM album INNER JOIN juron_album on album.idAlb = juron_album.idAlb INNER JOIN personnage on juron_album.idPers = personnage.idPers WHERE nomPers = 'haddock' GROUP BY album.idAlb ORDER BY CPT DESC LIMIT 1; -- 24. -- Album et N° Page où on peut lire : -- "REVOLUTIONNAIRE EN PEAU DE LAPIN" SELECT album.titreAlb, juron_album.numPage FROM album INNER JOIN juron_album ON album.idAlb = juron_album.idAlb INNER JOIN juron ON juron_album.idJur = juron.idJur WHERE nomJur = 'REVOLUTIONNAIRE EN PEAU DE LAPIN'; -- 25. -- Liste des pays visités par le Prof TOURNESOL SELECT DISTINCT nomPays FROM pays INNER JOIN pays_album ON pays.idPays = pays_album.idPays INNER JOIN album ON pays_album.idAlb = album.idAlb INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE nomPers = 'TOURNESOL' ORDER BY nomPays ASC; -- -- -- -- -- -- -- -- -- -- OTHERS -- 1. -- Affichez les albums de Tintin classés par ordre chronologique décroissant. SELECT titreAlb FROM album ORDER BY titreAlb DESC; -- 2. -- Affichez les personnages féminins dont la fonction dans les aventures de TINTIN est connue. SELECT nomPers, prenomPers, fonctPers FROM personnage WHERE sexePers= 'F' AND fonctPers IS NOT NULL ORDER BY nomPers ASC; -- 3. -- Affichez la liste des jurons prononcés dans l'album "OBJECTIF LUNE" à la dixième page. SELECT nomJur FROM juron INNER JOIN juron_album ON juron.idJur = juron_album.idJur INNER JOIN album ON juron_album.idAlb = album.idAlb WHERE titreAlb = 'OBJECTIF LUNE' AND numPage = 10 ORDER BY nomJur ASC; -- 4. -- Affichez la liste des jurons (sans doublons) prononcés par les bandits et les perroquets -- dans les albums "TINTIN EN AMERIQUE" et "L'OREILLE CASSEE". Seul le nom des jurons sera affiché -- et ils seront classés alphabétiquement. SELECT DISTINCT nomJur FROM juron INNER JOIN juron_album ON juron.idJur = juron_album.idJur INNER JOIN album ON juron_album.idAlb = album.idAlb INNER JOIN pers_album pa ON album.idAlb = pa.idAlb INNER JOIN personnage ON juron_album.idPers = personnage.idPers WHERE fonctPers in('bandit', 'perroquet') AND titreAlb IN('TINTIN EN AMERIQUE', 'L''OREILLE CASSEE') ORDER BY nomJur ASC; -- 5. -- Affichez le nom des personnages différents ayant prononcé un ou plusieurs jurons dans les 2 premières pages des albums. SELECT DISTINCT nomPers FROM juron INNER JOIN juron_album ON juron.idJur = juron_album.idJur INNER JOIN album ON juron_album.idAlb = album.idAlb INNER JOIN pers_album pa ON album.idAlb = pa.idAlb INNER JOIN personnage ON juron_album.idPers = personnage.idPers WHERE numPage = 2 GROUP BY personnage.idPers HAVING count(DISTINCT juron.idJur) > 0; -- 6. -- Combien de juron ont été prononcé par les 2 héros (Tintin et le capitaine Haddock) dans les albums "LE SECRET DE LA LICORNE" et -- "ON A MARCHE SUR LA LUNE". Présentez le rapport en indiquant le nombre par album et par personne. SELECT album.titreAlb, personnage.nomPers, count(juron_album.idJur) AS nb FROM personnage INNER JOIN juron_album ON personnage.idPers = juron_album.idPers INNER JOIN album ON juron_album.idAlb = album.idAlb WHERE (personnage.nomPers = 'tintin' OR personnage.nomPers = 'Haddock') and (album.titreAlb = 'LE SECRET DE LA LICORNE' or album.titreAlb = 'ON A MARCHE SUR LA LUNE') GROUP BY personnage.idPers, album.idAlb; -- 7. -- Affichez le nombre de personnages différents renseignés dans la DB pour tous les albums de Tintin encodés. -- Classez le rapport de manière décroissante sur le nombre. SELECT titreAlb, count(DISTINCT pers_album.idPers) AS nbPers FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers GROUP BY album.idAlb ORDER BY nbPers DESC; -- 8. -- Quelle est l'année et le titre de l'album dans lequel la "CASTAFIORE" est apparue pour la 1ere fois SELECT titreAlb FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE nomPers = 'CASTAFIORE' ORDER BY dateAlb LIMIT 1; -- 9. Quel(s) est(sont) le(s) personnage(s) qui participe(nt) à 5 aventures de Tintin uniquement SELECT nomPers, count(DISTINCT titreAlb) as NbrAlb FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb GROUP BY personnage.idPers HAVING NbrAlb = 5 ORDER BY NbrAlb DESC; -- 10. -- La DB renseigne que le juron "SCOLOPENDRE" a été prononcé par le capitaine Archibald Haddock dans "LE SECRET DE LA LICORNE" -- à la page 20. Vérifiez cette info à l'aide d'une requête SELECT count(nomJur) FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb INNER JOIN juron_album ON album.idAlb = juron_album.idAlb INNER JOIN juron ON juron_album.idJur = juron.idJur WHERE nomPers = 'Haddock' AND titreAlb = 'LE SECRET DE LA LICORNE' AND numPage = 20 AND nomJur = 'SCOLOPENDRE'; -- other solution SELECT IF((SELECT count(nomJur) FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb INNER JOIN juron_album ON album.idAlb = juron_album.idAlb INNER JOIN juron ON juron_album.idJur = juron.idJur WHERE nomPers = 'Haddock' AND titreAlb = 'LE SECRET DE LA LICORNE' AND numPage = 20 AND nomJur = 'SCOLOPENDRE') > 0, 'Oui', 'non'); -- 11. -- Quel(s) est(sont) le(s) titre(s) de(s) albums de Tintin dont l'aventure réunit plus de 15 personnages "gentils" ? -- Indiquez également le nombre de personnage dans la réponse. SELECT titreAlb, count(pers_album.idPers) nbrPers FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE gentilPers = '1' GROUP BY album.idAlb HAVING nbrPers > 15 ORDER BY nbrPers DESC; -- 12. -- Quel(s) est(sont) le(s) titre(s) des albums de Tintin dont l'aventure se déroule dans UN SEUL pays ? SELECT titreAlb FROM album INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays GROUP BY album.titreAlb HAVING count(nomPays) = 1 ORDER BY titreAlb ASC; -- 13. Combien d'années séparent le premier album de Tintin du dernier ? Faites-en sorte que l'affichage soit complet (Ex : 52 ans) SELECT concat(max(dateAlb) - min(dateAlb), ' ans') FROM album; -- other solution SELECT concat( ( (SELECT dateAlb FROM album order by dateAlb desc LIMIT 1) - (SELECT dateAlb FROM album order by dateAlb asc LIMIT 1) ), ' ans'); -- 14. -- Regroupez et affichez par pays, le(les) ID du(des) pays fréquenté(s) dans chaque album de Tintin. SELECT titreAlb, GROUP_CONCAT(DISTINCT pays_album.idPays) FROM pays INNER JOIN pays_album ON pays.idPays = pays_album.idPays INNER JOIN album ON pays_album.idAlb = album.idAlb GROUP BY album.titreAlb; -- 15. -- Combien de jurons sont prononcés au total dans les albums écrits avant 1945 ? Affichez la réponse en détaillant pour -- chaque album. Soignez la lecture du rapport. SELECT coalesce(titreAlb, 'Nombre Total de jurons') AS 'Titre des Albums', count(juron_album.idJur) AS 'Nombre de jurons par album' FROM juron INNER JOIN juron_album ON juron.idJur = juron_album.idJur INNER JOIN album ON juron_album.idAlb = album.idAlb WHERE dateAlb < 1945 GROUP BY album.titreAlb WITH ROLLUP; -- 16. -- Affichez la liste (clé, nom et prénom) sans doublons des personnages méchants présents dans les albums "TINTIN AU CONGO" -- et "TINTIN ET LES PICAROS" classés par clé. SELECT DISTINCT personnage.idPers, personnage.nomPers, personnage.prenomPers FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb WHERE album.titreAlb in('TINTIN AU CONGO','TINTIN ET LES PICAROS') AND personnage.gentilPers = 0 ORDER BY personnage.idPers; -- 17. -- Dans la requête 16, quels sont les doublons qui ont été masqué ainsi que le nombre de fois qu’ils auraient dû apparaitre ? SELECT concat(personnage.nomPers, ' apparaît ', coalesce(personnage.prenomPers, '')) AS personnage, count(personnage.idPers) AS DOUBLON FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb WHERE album.titreAlb in ('TINTIN AU CONGO', 'TINTIN ET LES PICAROS') AND personnage.gentilPers = 0 GROUP BY personnage.idPers HAVING DOUBLON > 1 ORDER BY personnage.idPers; -- other solution SELECT idPers, nomPers, count(nomPers) nb FROM personnage INNER JOIN pers_album USING (idPers) INNER JOIN album USING (idAlb) WHERE gentilPers = 0 AND titreAlb in ('tintin au congo', 'tintin et les picaros') GROUP BY idPers HAVING nb > 1 ORDER BY idPers; -- 18. -- Affichez les pays visités lors des aventures de Tintin entre 1955 et 1962 (années incluses) SELECT titreAlb FROM album WHERE dateAlb BETWEEN 1955 AND 1962 ORDER BY titreAlb ASC; -- other solution SELECT titreAlb FROM album WHERE dateAlb >= 1955 AND dateAlb <= 1962 ORDER BY titreAlb ASC; -- 19. -- Affichez les personnages "non anonyme" ayant participés aux albums dont le titre comporte le mot "Tintin" SELECT nomPers, titreAlb FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE titreAlb like '%Tintin%' AND nomPers != 'ANONYME'; -- 20. -- Un impoli se voit infliger une amende de 0,10 € par juron s'il en a prononcé plus de 20. -- D'après les jurons répertoriés, quelle sera l'amende à payer par les inconvenants ? -- Etant donné qu'on ne sait poursuivre un "Anonyme", ils seront retirés de la liste SELECT nomPers, 0.10 * count(juron_album.idJur) AS Amande FROM personnage INNER JOIN juron_album ON personnage.idPers = juron_album.idPers WHERE nomPers != 'ANONYME' GROUP BY personnage.idPers HAVING count(juron_album.idJur) > 20 ORDER BY Amande DESC; -- 21. -- Affichez le podium (3 premiers) des jurons les plus prononcés. SELECT nomJur, count(juron_album.idJur) AS nbrJur FROM juron INNER JOIN juron_album ON juron.idJur = juron_album.idJur GROUP BY juron.idJur ORDER BY nbrJur DESC LIMIT 3; -- 22. -- Affichez le nombre de personnage n'ayant pas de prénom connu en détaillant le nombre pour chaque album -- ****************************************************** -- ****************************************************** -- LOCAVOIT -- ****************************************************** -- ****************************************************** -- 23. -- Affichez la liste des clients (id, nom, prenom) classée par ordre alphabétique USE locavoit; SELECT idCli, nomCli, prenomCli FROM clients ORDER BY nomCli ASC; -- 24. -- Affichez les voitures toujours en service de catégorie A ou B SELECT * from voitures WHERE catvoit IN ('A','B') AND dfinvoit IS NULL; -- 25. -- Affichez la liste des voitures en location (id, modele, categ, carbu, km, dDebLoc) SELECT idVoit, modVoit, catVoit, carbvoit, kmVoit, dDebloc from voitures INNER JOIN locations ON voitures.idvoit = locations.voitureLoc WHERE ddebloc IS NOT NULL AND dfinloc IS NULL; -- 26. NOT END -- Affichez la liste des voitures disponibles à la location (en service et pas de location en cours) - (id, modele, categ, carbu, km, nbPortes, nbPlaces, nbBaggages) SELECT idVoit, modVoit, catVoit, carbVoit, kmVoit, nbportescat, nbplacescat, nbbagcat FROM voitures LEFT JOIN locations ON voitureLoc=idvoit --ATTENTION OBLIGATOIRE LEFT(pour avoir meme les-- LEFT JOIN categories ON idcat=catvoit --FK null-- WHERE dfinvoit IS NULL GROUP BY idvoit HAVING (COUNT(ddebloc)-COUNT(dfinloc))= 0 --pas de locations en cours--; -- 27. -- Pour chaque catégorie : id, desc, nb voitures en service, nb voitures pas en service SELECT idvoit, desccat, COUNT(idvoit)-COUNT(dfinvoit) as NbvoitOK, COUNT(dfinvoit) as nbvoitOUT from categories INNER JOIN voitures ON voitures.catvoit = categories.idcat GROUP BY idcat; -- 28. -- Affichez la liste des voitures (id, modele, categ, carbu, km) qui n'ont jamais été louées SELECT idvoit, modvoit, catvoit, carbvoit, kmvoit from Voitures LEFT JOIN locations ON voitures.idvoit = locations.voitureloc WHERE idloc IS NULL; -- 29. -- Affichez la liste des locations en cours: idLoc, dDebLoc, voiture, nomCli, prenomCli, nb de jours de location SELECT idloc, ddebloc, voitureLoc, nomcli, prenomcli, DATEDIFF(CURDATE(), ddebloc)+1 as nbjourloc from locations INNER JOIN clients ON locations.clientloc = clients.idcli WHERE dfinloc IS NULL; -- 30. -- Quel est le meilleur client (plus grand nombre de locations) ? (id, nom, prénom, nbre de locations, prix total des locations) SELECT idcli, Nomcli, prenomcli, COUNT(clientloc) as nombreloc, SUM(prixloc) as TOTLOC from locations INNER JOIN clients ON locations.clientloc = clients.idcli GROUP BY idcli ORDER BY nombreloc desc LIMIT 1; -- 31. -- Affichez la liste des clients ayant loué pour plus de 1000 € (id, nom, prénom) SELECT idcli, Nomcli, prenomcli, SUM(prixloc) as TOTLOC from locations INNER JOIN clients ON locations.clientloc = clients.idcli GROUP BY idcli HAVING TOTLOC>1000; -- 32. -- Affichez toutes les locations du client 1, la durée de location et les km parcourus SELECT idloc, voitureloc as voiture, (dfinloc-ddebloc +1) as durée, (kmfinloc-kmdebloc) as km, prixloc,remloc FROM locations INNER JOIN voitures ON idvoit= voitureloc WHERE clientloc=1; -- 33. -- Affichez le nombre de locations pour tous les clients SELECT idcli, nomcli, prenomcli, COUNT(idloc) as nbloc from clients INNER JOIN locations ON idcli = clientloc GROUP BY idcli; -- 34. -- Affichez la liste des clients ayant plus d’une location en cours SELECT idcli, nomcli, prenomcli, COUNT(idloc) from clients INNER JOIN locations ON idcli = clientloc WHERE dfinloc is NULL GROUP BY idcli HAVING COUNT(idloc)>1; -- 35. -- Affichez le nombre de locations pour tous les clients, le km total parcouru, la durée totale SELECT idcli, nomcli, prenomcli, COUNT(clientloc) as nbloc, SUM(kmfinloc-kmdebloc) as kmparcouru, SUM(DATEDIFF(dfinloc,dDebloc)) as dureetot from locations INNER JOIN clients ON clientloc=idcli GROUP BY idcli ORDER BY nomcli; -- -- -- -- -- -- -- EVALUATION PERSONNEL -- 1. -- Donnez les noms et prénoms des personnages méchants présent dans l'album "Le Lotus Bleu". select nomPers, prenomPers, gentilPers from personnage inner join pers_album on personnage.idPers = pers_album.idPers inner join album on pers_album.idAlb = album.idAlb WHERE titreAlb = 'le Lotus Bleu' and gentilPers = 0 ORDER BY nomPers; -- 2. -- Etablissez la liste des différents jurons prononcés par Milou. select nomPers, nomJur from personnage inner join juron_album on personnage.idPers = juron_album.idPers inner join juron on juron_album.idJur = juron.idJur WHERE nomPers = 'Milou' GROUP BY juron.idJur; -- 3. -- Donnez le nombre de jurons prononcés par chaque personnage non anonyme. -- Le rapport sera classé de manière décroissante en fonction du nombre. select nomPers, count(juron_album.idJur) AS nbrJur from personnage inner join juron_album on personnage.idPers = juron_album.idPers inner join juron on juron_album.idJur = juron.idJur WHERE nomPers != 'ANONYME' GROUP BY juron_album.idPers ORDER BY nbrJur DESC; -- 4. WRONG ! -- Quels sont les personnages (id, Nom et prénom) n'ayant pas prononcé de juron dans les album de tintin. select personnage.idPers, nomPers, prenomPers from personnage INNER JOIN juron_album on personnage.idPers = juron_album.idPers INNER JOIN juron on juron_album.idJur = juron.idJur WHERE juron_album.idJur IS NULL GROUP BY juron_album.idPers; -- 5. -- Etablissez la liste des 10 personnages non anonyme prononçant le plus de jurons différents et -- classez la par le nombre de jurons décroissant. select nomPers, group_concat(nomJur), count(DISTINCT juron_album.idJur) nbrJur from personnage inner join juron_album on personnage.idPers = juron_album.idPers inner join juron on juron_album.idJur = juron.idJur WHERE nomPers != 'ANONYME' GROUP BY juron_album.idPers ORDER BY nbrJur DESC limit 10; -- 6. -- Lequel des 2 Dupont (T ou D) a prononcé le plus souvant des jurons ? Combien ? select nomPers, count(juron_album.idJur) AS nbrJur from personnage inner join juron_album on personnage.idPers = juron_album.idPers inner join juron on juron_album.idJur = juron.idJur WHERE nomPers = 'DUPONT' OR nomPers = 'DUPOND' GROUP BY juron_album.idPers ORDER BY nbrJur DESC; -- 7. -- En quelle année et dans quel album le capitaine HADDOCK apparaît il pour la premère fois ? select nomPers, titreAlb, dateAlb from personnage inner join pers_album on personnage.idPers = pers_album.idPers inner join album on pers_album.idAlb = album.idAlb WHERE nomPers = 'HADDOCK' ORDER BY dateAlb LIMIT 1; -- 8. WRONG ! -- Pour les jurons "FORBAN" et "GREDIN", donnez le nom du juron, l'année durant laquelle il a été -- écrit pour la première fois ainsi que le nombre de personnage différent les ayant prononcés. SELECT DISTINCT nomJur, MIN(dateAlb), count(juron_album.idPers) from juron INNER JOIN juron_album USING (idJur) INNER JOIN personnage USING (idPers) INNER JOIN pers_album USING (idPers) INNER JOIN album on pers_album.idAlb = album.idAlb WHERE nomJur = 'FORBAN' OR nomJur = 'GREDIN' GROUP BY juron_album.idJur; -- 9. -- Quels sont les personnages différents non anonyme autre que milou, HADDOCK, Tintin, Dupont et Dupond, -- présent dans les aventures de Tintin entre 1937 et 1940. On retrouve la date, ID et le nom du personnage dans le rapport. select personnage.idPers, nomPers, prenomPers, dateAlb, titreAlb from personnage inner join pers_album on personnage.idPers = pers_album.idPers inner join album on pers_album.idAlb = album.idAlb WHERE nomPers != 'Milou' and nomPers != 'HADDOCK' and nomPers != 'TINTIN' and nomPers != 'Dupont' and nomPers != 'Dupond' and nomPers != 'ANONYME' and dateAlb BETWEEN '1937' AND '1940' ORDER BY dateAlb; -- ****************************************************** -- ****************************************************** -- ECOLE / DOG_RACING -- ****************************************************** -- ****************************************************** -- 1. -- a. -- Dans la table "pays", ajouter un enregistrement dont le "codeP" sera 'XX' et le "nomP" sera 'Indéterminé' DELETE FROM Dog_Racing.pays WHERE codeP = 'XX'; USE Dog_Racing; INSERT INTO Dog_Racing.pays (codeP, nomP) VALUES ('XX', 'Indéterminé'); UPDATE Dog_Racing.pays SET codeP= 'XX' WHERE codeP = 'XY'; -- b. -- Dans la table "chien", mettre à jour la valeur du champ "nationCh". -- Si "nationCh" est NULL, il prendra la valeur 'XX'. UPDATE Dog_Racing.chien SET descCh = 'Indéterminé' WHERE descCh IS NULL; -- c. -- Créer une requête préparée qui permettra d'afficher le nom des chiens et leur pays -- d'origine en toutes lettres ainsi que le temps qu'ils ont mis lors d'une course rentrée en -- paramètre. La requête présentera les données en classant les enregistrements par ordre -- croissant de leurs résultats. PREPARE P_details_Courses FROM 'SELECT nomCh, nomP, temps FROM chien INNER JOIN resultat ON resultat.idCh = chien.idCh INNER JOIN course ON course.idC = resultat.idC INNER JOIN pays ON pays.codeP = chien.nationCh WHERE nomC = ? ORDER BY temps ASC'; SET @course = "IEPSCF, du C308 au C313"; EXECUTE P_details_Courses USING @course -- 2. -- Créer une vue qui affichera la course la plus rapide en fonction du temps mis par le 1er. drop view v_courserapide; CREATE VIEW V_courseRapide AS SELECT nomC FROM course WHERE idC = ( SELECT idC FROM resultat ORDER BY temps ASC LIMIT 1 ) ; SELECT * FROM V_courseRapide; -- 3. -- Créez une vue qui permettra d'afficher le nom et le pays d'origine en toutes lettres des chiens -- n'ayant participés à aucune course. CREATE VIEW V_chien_noCourse AS SELECT nomCh, nomP FROM chien LEFT JOIN resultat ON chien.idCh = resultat.idCh LEFT JOIN course ON resultat.idC = course.idC LEFT JOIN pays ON chien.nationCh = pays.codeP WHERE temps IS NULL ORDER BY nomCh ASC; SELECT * FROM V_chien_noCourse; -- 4. -- Créer une requête préparée qui prendra en paramètre le nom d'une course ainsi que le nom -- d'un chien (les 2 en toutes lettres). -- La vue renverra le temps mis par ce chien lors de cette course s' il y a participé. SELECT * FROM course LEFT JOIN resultat ON course.idC = resultat.idC LEFT JOIN chien ON resultat.idC = chien.idCh WHERE nomCh = "Bill" AND nomC = "ami de Boule"; SELECT nomCh, nomC, temps FROM chien LEFT JOIN resultat ON chien.idCh = resultat.idCh LEFT JOIN course ON resultat.idC = course.idC WHERE nomCh = "Bill" AND nomC = "Paris en motocrotte"; PREPARE V_dog_course FROM 'SELECT temps FROM chien LEFT JOIN resultat ON chien.idCh = resultat.idCh LEFT JOIN course ON resultat.idC = course.idC WHERE nomCh = ? AND nomC = ?' ; SET @nomChien = 'Bill', SET SET @nomCourse = 'Paris en motocrotte'; SELECT @nomChien, @nomCourse; EXECUTE V_dog_course USING @nomChien, @nomCourse; -- 5. -- Affichez la clé primaire, le nom et le prénom des étudiants et des professeurs de la formation «Fleuriste » (FLEU). USE ecole; SELECT PK_Pers, Nom, Prenom FROM t_pers INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_pers INNER JOIN t_branche ON t_inscription.FK_Cours = t_branche.PK_Branche WHERE PK_Branche = 'FLEU' UNION ALL SELECT PK_Pers, Nom, Prenom FROM t_pers INNER JOIN t_Prof ON t_pers.PK_Pers = t_Prof.FK_pers INNER JOIN t_branche ON t_Prof.FK_Branche = t_branche.PK_Branche WHERE PK_Branche = 'FLEU' -- 6. -- Combien y a-t-il d'étudiants masculins par niveau d’étude inscrits dans l’établissement ? -- L’affichage nous donnera également le nombre total. SELECT COALESCE(Etude, '-- Total --') AS total, count(DISTINCT FK_Pers) AS nbr FROM t_pers INNER JOIN t_inscription ON PK_Pers = FK_Pers WHERE Sexe= 'M' GROUP BY Etude WITH ROLLUP; -- 7. -- Combien y a-t-il de localité différente abritant un professeur ou un étudiant faisant partie de l'établissement. SELECT count(*) FROM ( SELECT DISTINCT PK_Loc FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers union SELECT DISTINCT PK_Loc FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_prof ON t_pers.PK_Pers = t_prof.FK_Pers ) AS nbr -- 8. -- Quelle est la durée totale de la formation d’un étudiant désirant suivre les cours de Carrosserie, Horlogerie et Construction. SELECT SUM(Duree) FROM ( SELECT Duree FROM t_branche WHERE branche in('Carrosserie', 'Horlogerie', 'Construction') ) AS nbr; -- other Solution USE ecole; SELECT SUM( (SELECT Duree FROM t_branche WHERE Branche = 'Carrosserie') + (SELECT Duree FROM t_branche WHERE Branche = 'Horlogerie') + (SELECT Duree FROM t_branche WHERE Branche = 'Construction') ); -- 9. -- a. -- Quelle est(sont) la(les) localité(s) la(les) mieux représentée(s) dans l'école en -- tenant compte des étudiants uniquement. SELECT count(FK_Loc) AS nbr, localite FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers GROUP BY PK_loc HAVING nbr >= ( SELECT count(FK_Loc) AS nbrLoc FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers GROUP BY PK_loc ORDER BY nbrLoc DESC LIMIT 1,1 ) ORDER BY nbr DESC; -- b. -- Cela change-t-il si on tient compte des professeurs également ? SELECT count(FK_Loc) AS nbr, localite FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers GROUP BY PK_loc HAVING nbr >= ( SELECT count(FK_Loc) AS nbrLoc FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers GROUP BY PK_loc UNION ALL SELECT count(FK_Loc) AS nbrLoc FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_prof ON t_pers.PK_Pers = t_prof.FK_Pers GROUP BY PK_loc ORDER BY nbrLoc DESC LIMIT 1,1 ) ORDER BY nbr DESC; -- 10. -- Quelle est(sont) la(les) localité(s) qui ont le même nombre de représentants que la localité de "BOUGE" SELECT count(PK_Pers) AS nbr , localite FROM t_pers INNER JOIN t_loc ON t_pers.FK_Loc = t_loc.PK_Loc GROUP BY PK_Loc HAVING nbr = ( SELECT count(PK_Pers) FROM t_pers INNER JOIN t_loc ON t_pers.FK_Loc = t_loc.PK_Loc WHERE localite = 'BOUGE' GROUP BY PK_Loc ) ; -- 11. -- Quelles sont les étudiants (clé primaire, nom et prénom) inscrits à plus de 2 formations ? SELECT PK_Pers, Nom, prenom FROM t_pers INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers GROUP BY PK_Pers HAVING count(FK_Cours) > 2; -- ****************************************************** -- ****************************************************** -- Exercices 17/12/2019 -- ****************************************************** -- ****************************************************** -- 1. -- Afficher les initiales des professeurs (M.V.) SELECT DISTINCT Nom, Prenom, CONCAT(LEFT(Nom,1), '.', LEFT(Prenom,1), '.' )AS Initiales FROM T_Pers INNER JOIN T_Prof ON T_Prof.FK_Pers = T_Pers.PK_Pers ; SELECT DISTINCT Nom, Prenom, CONCAT(SUBSTRING(Nom FROM 1 FOR 1), '.', SUBSTRING(Prenom FROM 1 FOR 1), '.' )AS Initiales FROM T_Pers INNER JOIN T_Prof ON T_Prof.FK_Pers = T_Pers.PK_Pers ORDER BY Nom ; SELECT DISTINCT Nom, Prenom, CONCAT(SUBSTRING(Nom FROM 2 FOR 3), '.', SUBSTRING(Prenom FROM 1 FOR 1), '.' )AS Initiales FROM T_Pers INNER JOIN T_Prof ON T_Prof.FK_Pers = T_Pers.PK_Pers ; -- 2. -- Afficher les intitulés des cours qui ne sont suivis par personne SELECT branche FROM T_Branche LEFT JOIN T_Inscription ON T_Inscription.FK_Cours = T_Branche.PK_Branche WHERE FK_Pers IS NULL ; -- 3. -- Afficher les intitulés des cours qui sont donnés par plus d'un professeur SELECT branche, COUNT(FK_Pers) AS Prof FROM T_Branche INNER JOIN T_Prof ON T_Prof.FK_Branche = T_Branche.PK_Branche GROUP BY PK_Branche HAVING Prof > 1 ; -- 4. NOT END -- Afficher les noms et prénoms des étudiants inscrits à au moins un cours qui ont moins de 30 ans UPDATE T_Pers SET DateNaissance = ( SELECT FROM_UNIXTIME(FLOOR(RAND()*UNIX_TIMESTAMP())) ); UPDATE T_Pers SET DateNaissance = ( SELECT ADDDATE(DateNaissance, INTERVAL -18 YEAR) ) ; SELECT CURRENT_DATE; SELECT CURRENT_DATE(); SELECT CURRENT_TIMESTAMP; SELECT CURRENT_TIMESTAMP(); SELECT Prenom, DateNaissance, TIMESTAMPDIFF(YEAR, DateNaissance, CURDATE()) AS age FROM T_Pers WHERE PK_Pers <= 10; SELECT '1994-03-13', TIMESTAMPDIFF(second, '1994-03-13', CURDATE()) AS age; SELECT Prenom, DateNaissance, TIMESTAMPDIFF(SECOND, DateNaissance, CURDATE()) AS age FROM T_Pers WHERE PK_Pers <= 10; SELECT Nom, Prenom, DateNaissance, CONCAT(TIMESTAMPDIFF(YEAR, DateNaissance, CURDATE()), ' ans') AS age FROM T_Pers INNER JOIN T_Inscription ON T_Inscription.FK_Pers = T_Pers.PK_Pers HAVING age < 30 ORDER BY age; -- other UPDATE t_pers SET t_pers.DateNaissance = (SELECT FROM_UNIXTIME(FLOOR(RAND()*UNIX_TIMESTAMP()))); UPDATE t_pers SET DateNaissance = (SELECT ADDDATE(DateNaissance, INTERVAL -18 YEAR)); -- 5. -- Afficher les noms et prénoms des professeurs qui donnent un cours de plus de 70 heures SELECT Nom, Prenom, Nb_Heure FROM T_Pers INNER JOIN T_Prof ON T_Prof.FK_Pers = T_Pers.PK_Pers INNER JOIN T_Branche ON T_Prof.FK_Branche = T_Branche.PK_Branche WHERE Nb_Heure > 70 ; -- 6. NOT END -- Afficher le nombre d’élèves qui suivent les cours de Corentin PIGEON SELECT COUNT(DISTINCT PK_Pers) AS Nb_Etudiant FROM T_Pers INNER JOIN T_Inscription ON T_Inscription.FK_Pers = T_Pers.PK_Pers WHERE FK_Cours IN ( SELECT PK_Branche FROM T_Branche INNER JOIN T_Prof ON T_Prof.FK_Branche = T_Branche.PK_Branche INNER JOIN T_Pers ON T_Prof.FK_Pers = T_Pers.PK_Pers WHERE nom = 'Pigeon' AND Prenom = 'Corentin' AND Nb_Heure IS NOT NULL ) ; SELECT COUNT(DISTINCT PK_Pers) AS Nb_Etudiant FROM T_Pers INNER JOIN T_Inscription ON T_Inscription.FK_Pers = T_Pers.PK_Pers WHERE FK_Cours IN ( SELECT PK_Branche FROM T_Branche INNER JOIN T_Prof ON T_Prof.FK_Branche = T_Branche.PK_Branche INNER JOIN T_Pers ON T_Prof.FK_Pers = T_Pers.PK_Pers WHERE nom = 'Pigeon' AND Prenom = 'Corentin' ) ; -- 7. -- Afficher les élèves qui suivent les cours d’un professeur qui a un âge supérieur à la moyenne des -- âges des élèves -- Explication d'une solution possible -- a : 1ère Sous-requête -- Afin de ne pas fausser la moyenne, il faut éliminer les doublons "Etudiant" -- b : 2de Sous-requête -- Calcul de la moyenne d'age de ces "Etudiant" -- c : 3ème Sous-requête -- PK des Profs plus agé que cette moyenne -- d : 4ème Sous-requête -- Détermination des cours donnés par ces profs -- e : Requête finale -- Affichage des étudiants SELECT DISTINCT PK_Pers, Nom, Prenom FROM T_Pers INNER JOIN T_Inscription ON T_Pers.PK_Pers = T_Inscription.FK_Pers WHERE FK_Cours IN ( SELECT DISTINCT FK_Branche FROM T_Prof WHERE FK_Pers IN ( SELECT DISTINCT PK_Pers FROM T_Prof INNER JOIN T_Pers ON T_Pers.PK_Pers = T_Prof.FK_Pers WHERE TIMESTAMPDIFF(YEAR, DateNaissance, CURDATE()) > ( SELECT AVG(TIMESTAMPDIFF(YEAR, DateNaissance, CURDATE())) AS age FROM T_Pers WHERE PK_Pers IN ( SELECT DISTINCT PK_Pers FROM T_Pers INNER JOIN T_Inscription ON T_Pers.PK_Pers = T_Inscription.FK_Pers ) ) ) ) ;
true
e4820734800cfe15ca9af71cc8ec68f701ddef69
SQL
eeblaize2/E-Commerce
/db/schema.sql
UTF-8
980
3.8125
4
[]
no_license
-- DROP DATABASE DROP DATABASE IF EXISTS ecommerce_db; -- CREATE DATABASE CREATE DATABASE ecommerce_db; -- CREATE TABLES CREATE TABLE Category ( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, category_name VARCHAR(20) NOT NULL ); CREATE TABLE Product ( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, product_name VARCHAR(20) NOT NULL, price decimal (10,2) NOT NULL CHECK (price > 0), -- Validates that the value is a decimal. XXXXXX stock INTEGER NOT NULL default 10, -- Validates that the value is numeric. XXXXXX category_id INTEGER, FOREIGN KEY (category_id) REFERENCES Category(id) ) Tag id Integer. Doesn't allow null values. Set as primary key. Uses auto increment. tag_name String. ProductTag id Integer. Doesn't allow null values. Set as primary key. Uses auto increment. product_id Integer. References the Product model's id. tag_id Integer. References the Tag model's id.
true
738e1d779832325925abf3f251910272542e3d5e
SQL
silence-do-good/stress-test-Postgres-and-MySQL
/dump/high/day18/select0729.sql
UTF-8
178
2.625
3
[]
no_license
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o WHERE timestamp>'2017-11-17T07:29:00Z' AND timestamp<'2017-11-18T07:29:00Z' AND temperature>=50 AND temperature<=53
true
6aa1dfd553123f9a1684cf4454f9bd869b539636
SQL
OvidiuEDSgrup/TET
/TET/Views/yso_vIaTerti.sql
UTF-8
4,930
3.046875
3
[]
no_license
create view yso_vIaTerti as --/* select rtrim(t.tert) as tert, rtrim(t.denumire) as dentert, rtrim(t.cod_fiscal) as codfiscal, rtrim(t.localitate) as localitate, rtrim(isnull(l.oras, t.Localitate)) as denlocalitate, rtrim(case when isnull(it.zile_inc, 0)=0 then t.judet else '' end) as judet, rtrim(isnull(j.denumire, t.judet)) as denjudet, rtrim(case when isnull(it.zile_inc, 0)>0 then t.judet else '' end) as tara, rtrim(isnull(tari.denumire, '')) as dentara, rtrim(t.adresa) as adresa, rtrim(case when par.val_logica=1 then left(t.adresa, 30) else '' end) as strada, rtrim(case when par.val_logica=1 then substring(t.adresa, 31, 8) else '' end) as numar, rtrim(case when par.val_logica=1 then substring(t.adresa, 39, 6) else '' end) as bloc, rtrim(case when par.val_logica=1 then substring(t.adresa, 45, 5) else '' end) as scara, rtrim(case when par.val_logica=1 then substring(t.adresa, 50, 3) else '' end) as apartament, rtrim(case when par.val_logica=1 then substring(t.adresa, 53, 8) else '' end) as codpostal, rtrim(telefon_fax) as telefonfax, rtrim(t.banca) as banca, rtrim(isnull(b.denumire, '')) as denbanca, rtrim(t.cont_in_banca) as continbanca, convert(int, t.tert_extern) as decontarivaluta, rtrim(t.grupa) as grupa, rtrim(isnull(g.denumire, '')) as dengrupa, rtrim(t.cont_ca_furnizor) as contfurn, rtrim(isnull(cf.denumire_cont, '')) as dencontfurn, rtrim(t.cont_ca_beneficiar) as contben, rtrim(isnull(cb.denumire_cont, '')) as dencontben, convert(char(10), (case when t.sold_ca_furnizor<=693961 then '01/01/1901' when t.sold_ca_furnizor>1000000 then '12/31/2999' else dateadd(d, t.sold_ca_furnizor-693961, '01/01/1901') end), 101) as datatert, convert(int, t.sold_ca_beneficiar) as categpret, rtrim(isnull(categpret.denumire, '')) as dencategpret, convert(decimal(14, 2), t.sold_maxim_ca_beneficiar) as soldmaxben, convert(decimal(7, 2), t.disccount_acordat) as discount, convert(int, isnull(it.sold_ben, 0)) as termenlivrare, convert(int, isnull(it.discount, 0)) as termenscadenta, rtrim(isnull(it.nume_delegat, '')) as reprezentant, rtrim(isnull(it.eliberat, '')) as functiereprezentant, rtrim(isnull(it.loc_munca, '')) as lm, rtrim(isnull(lm.denumire, '')) as denlm, rtrim(isnull(it.descriere, '')) as responsabil, rtrim(isnull(p.nume, '')) as denresponsabil, rtrim(isnull(it.cont_in_banca2, '')) as info1, rtrim(isnull(it.cont_in_banca3, '')) as info2, rtrim(isnull(it.observatii, '')) as info3, rtrim(isnull(it.banca3, '')) as nrordreg, rtrim(isnull(it.e_mail, '')) as email, isnull(it.zile_inc, 0) as tiptert, (case when it.zile_inc=1 then 'UE' when it.zile_inc=2 then 'Extern' else 'Intern' end) as denTiptert, --(case when isnull(it.grupa13, '')='1' then 1 else 0 end) as neplatitortva, /*Se inlocuieste cu tipTva*/ isnull(ttva.tip_tva,'N') as tiptva, isnull(it.indicator, 0) as nomspec, convert(decimal(13, 2), isnull(ff.sold, 0)) as soldfurn, convert(decimal(13, 2), isnull(fb.sold, 0)) as soldben, (case when isnull(ff.sold, 0)=0 and isnull(fb.sold, 0)=0 then '#808080' -- fara sold when exists(select 1 from proprietati where Cod_proprietate='CI8' and tip='TERT' and valoare='42' and cod=t.Tert) then'#0000FF' when exists(select 1 from proprietati where Cod_proprietate='CI8' and tip='TERT' and valoare='43' and cod=t.Tert) then'#FF0000' else '#000000' end) as culoare --*/select * from terti t left join infotert it on it.subunitate=t.subunitate and it.tert=t.tert and it.identificator='' left join judete j on isnull(it.zile_inc, 0)=0 and j.cod_judet=t.judet left join tari on isnull(it.zile_inc, 0)>0 and tari.cod_tara=t.judet left join localitati l on l.cod_judet=t.judet and l.cod_oras=t.localitate left join bancibnr b on b.cod=t.banca left join gterti g on t.grupa=g.grupa left join conturi cf on cf.subunitate=t.subunitate and cf.cont=t.cont_ca_furnizor left join conturi cb on cb.subunitate=t.subunitate and cb.cont=t.cont_ca_beneficiar left join categpret on categpret.categorie=t.sold_ca_beneficiar left join lm on lm.cod=it.loc_munca left join personal p on p.marca=it.descriere left join par on par.Tip_parametru='GE' AND par.Parametru='ADRCOMP' left join (select t1.tert, sum(sold) as sold from facturi,terti t1 where t1.Subunitate=facturi.Subunitate and t1.tert=facturi.tert and facturi.subunitate='1' and tip=0x54 group by t1.tert) ff on ff.tert=t.tert left join (select t1.tert, sum(sold) as sold from facturi,terti t1 where t1.Subunitate=facturi.Subunitate and t1.tert=facturi.tert and facturi.subunitate='1' and tip=0x46 group by t1.tert) fb on fb.tert=t.tert outer apply (select top 1 t.tert,isnull(tv.tip_tva,(case when isnull(TipTVA.tip_tva,'P')='I' then 'I' else 'P' end)) as tip_tva from (select top 1 tip_tva from TvaPeTerti where TipF='B' and Tert is null and dela<=GETDATE() order by dela desc) tipTva cross join TvaPeTerti tv where tv.tipf='F' and t.tert=tv.tert order by dela desc ) ttva --where t.Denumire like '%abracom%'
true
1a6858747ed04ee07eb9e158d8ba5b2a13ca05f4
SQL
CarmineM74/GestioneViaggi
/GestioneViaggi/creation.sql
UTF-8
945
3.5
4
[]
no_license
CREATE TABLE "Cliente" ( "Id" INTEGER PRIMARY KEY AUTOINCREMENT, "RagioneSociale" VARCHAR(60) NOT NULL, "Tariffa" DECIMAL NOT NULL ); CREATE TABLE "Prodotto" ( "Id" INTEGER PRIMARY KEY AUTOINCREMENT, "Descrizione" VARCHAR(60) NOT NULL ); CREATE TABLE "Viaggio" ( "Id" INTEGER PRIMARY KEY AUTOINCREMENT, "ClienteId" INTEGER NOT NULL, "Data" VARCHAR(8000) NOT NULL, "TargaAutomezzo" VARCHAR(30) NULL, "Conducente" VARCHAR(60) NULL, "ProdottoId" INTEGER NOT NULL, "Pesata" DECIMAL NOT NULL, "CaloPesoPercentuale" INTEGER NOT NULL, CONSTRAINT "FK_Viaggio_Cliente_ClienteId" FOREIGN KEY ("ClienteId") REFERENCES "Cliente" ("Id"), CONSTRAINT "FK_Viaggio_Prodotto_ProdottoId" FOREIGN KEY ("ProdottoId") REFERENCES "Prodotto" ("Id") ); CREATE UNIQUE INDEX uidx_cliente_ragionesociale ON "Cliente" ("RagioneSociale" ASC); CREATE UNIQUE INDEX uidx_prodotto_descrizione ON "Prodotto" ("Descrizione" ASC);
true
9a443259b30dc60c86c6089ed9d9c364e70d57ec
SQL
Raymond-Wong/coursearea
/sql/180429_init.sql
UTF-8
18,878
3.21875
3
[]
no_license
-- MySQL dump 10.13 Distrib 5.6.27, for debian-linux-gnu (i686) -- -- Host: localhost Database: coursearea -- ------------------------------------------------------ -- Server version 5.6.27-0ubuntu1 /*!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 `auth_group` -- DROP TABLE IF EXISTS `auth_group`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `auth_group` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(80) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `auth_group_permissions` -- DROP TABLE IF EXISTS `auth_group_permissions`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `auth_group_permissions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `group_id` int(11) NOT NULL, `permission_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `group_id` (`group_id`,`permission_id`), KEY `auth_group_permissions_5f412f9a` (`group_id`), KEY `auth_group_permissions_83d7f98b` (`permission_id`), CONSTRAINT `group_id_refs_id_f4b32aac` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`), CONSTRAINT `permission_id_refs_id_6ba0f519` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `auth_permission` -- DROP TABLE IF EXISTS `auth_permission`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `auth_permission` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `content_type_id` int(11) NOT NULL, `codename` varchar(100) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `content_type_id` (`content_type_id`,`codename`), KEY `auth_permission_37ef4eb4` (`content_type_id`), CONSTRAINT `content_type_id_refs_id_d043b34a` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `auth_user` -- DROP TABLE IF EXISTS `auth_user`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `auth_user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `password` varchar(128) NOT NULL, `last_login` datetime NOT NULL, `is_superuser` tinyint(1) NOT NULL, `username` varchar(30) NOT NULL, `first_name` varchar(30) NOT NULL, `last_name` varchar(30) NOT NULL, `email` varchar(75) NOT NULL, `is_staff` tinyint(1) NOT NULL, `is_active` tinyint(1) NOT NULL, `date_joined` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `auth_user_groups` -- DROP TABLE IF EXISTS `auth_user_groups`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `auth_user_groups` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `group_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `user_id` (`user_id`,`group_id`), KEY `auth_user_groups_6340c63c` (`user_id`), KEY `auth_user_groups_5f412f9a` (`group_id`), CONSTRAINT `group_id_refs_id_274b862c` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`), CONSTRAINT `user_id_refs_id_40c41112` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `auth_user_user_permissions` -- DROP TABLE IF EXISTS `auth_user_user_permissions`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `auth_user_user_permissions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `permission_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `user_id` (`user_id`,`permission_id`), KEY `auth_user_user_permissions_6340c63c` (`user_id`), KEY `auth_user_user_permissions_83d7f98b` (`permission_id`), CONSTRAINT `permission_id_refs_id_35d9ac25` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`), CONSTRAINT `user_id_refs_id_4dc23c39` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_access_token` -- DROP TABLE IF EXISTS `coursearea_access_token`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_access_token` ( `id` int(11) NOT NULL AUTO_INCREMENT, `token` varchar(600) NOT NULL, `start_time` datetime NOT NULL, `end_time` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_audition` -- DROP TABLE IF EXISTS `coursearea_audition`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_audition` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `course_id` int(11) NOT NULL, `create_time` datetime NOT NULL, PRIMARY KEY (`id`), KEY `coursearea_audition_6340c63c` (`user_id`), KEY `coursearea_audition_6234103b` (`course_id`), CONSTRAINT `course_id_refs_id_2fa6895b` FOREIGN KEY (`course_id`) REFERENCES `coursearea_course` (`id`), CONSTRAINT `user_id_refs_id_763c5314` FOREIGN KEY (`user_id`) REFERENCES `coursearea_user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_collect` -- DROP TABLE IF EXISTS `coursearea_collect`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_collect` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `course_id` int(11) NOT NULL, `create_time` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `user_id` (`user_id`,`course_id`), KEY `coursearea_collect_6340c63c` (`user_id`), KEY `coursearea_collect_6234103b` (`course_id`), CONSTRAINT `course_id_refs_id_fa32cfea` FOREIGN KEY (`course_id`) REFERENCES `coursearea_course` (`id`), CONSTRAINT `user_id_refs_id_789d8401` FOREIGN KEY (`user_id`) REFERENCES `coursearea_user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_comment` -- DROP TABLE IF EXISTS `coursearea_comment`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_comment` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `create_time` datetime NOT NULL, `content` longtext NOT NULL, `course_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `coursearea_comment_6340c63c` (`user_id`), KEY `coursearea_comment_6234103b` (`course_id`), CONSTRAINT `course_id_refs_id_977fe23a` FOREIGN KEY (`course_id`) REFERENCES `coursearea_course` (`id`), CONSTRAINT `user_id_refs_id_a004750b` FOREIGN KEY (`user_id`) REFERENCES `coursearea_user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_course` -- DROP TABLE IF EXISTS `coursearea_course`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_course` ( `id` int(11) NOT NULL AUTO_INCREMENT, `info_id` int(11) NOT NULL, `group_id` int(11) NOT NULL, `series_id` int(11) NOT NULL, `is_selected` tinyint(1) NOT NULL, `is_released` tinyint(1) NOT NULL, `is_banner` tinyint(1) NOT NULL, `style_id` int(11) NOT NULL, `create_time` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `style_id` (`style_id`), KEY `coursearea_course_353211ae` (`info_id`), KEY `coursearea_course_5f412f9a` (`group_id`), KEY `coursearea_course_489757ad` (`series_id`), CONSTRAINT `group_id_refs_id_d8454875` FOREIGN KEY (`group_id`) REFERENCES `coursearea_group` (`id`), CONSTRAINT `info_id_refs_id_a949c261` FOREIGN KEY (`info_id`) REFERENCES `coursearea_course_info` (`id`), CONSTRAINT `series_id_refs_id_1f282aef` FOREIGN KEY (`series_id`) REFERENCES `coursearea_series` (`id`), CONSTRAINT `style_id_refs_id_1fecf75d` FOREIGN KEY (`style_id`) REFERENCES `coursearea_course_style` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_course_info` -- DROP TABLE IF EXISTS `coursearea_course_info`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_course_info` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `desc` longtext NOT NULL, `price` int(10) unsigned NOT NULL, `status` varchar(200) NOT NULL, `cover_url` varchar(500) DEFAULT NULL, `teacher_id` int(11) NOT NULL, `resource` varchar(500) DEFAULT NULL, PRIMARY KEY (`id`), KEY `coursearea_course_info_c12e9d48` (`teacher_id`), CONSTRAINT `teacher_id_refs_id_c41ed171` FOREIGN KEY (`teacher_id`) REFERENCES `coursearea_teacher` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_course_recommend_courses` -- DROP TABLE IF EXISTS `coursearea_course_recommend_courses`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_course_recommend_courses` ( `id` int(11) NOT NULL AUTO_INCREMENT, `from_course_id` int(11) NOT NULL, `to_course_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `from_course_id` (`from_course_id`,`to_course_id`), KEY `coursearea_course_recommend_courses_b7fe3600` (`from_course_id`), KEY `coursearea_course_recommend_courses_c47a8293` (`to_course_id`), CONSTRAINT `from_course_id_refs_id_e84e4bbd` FOREIGN KEY (`from_course_id`) REFERENCES `coursearea_course` (`id`), CONSTRAINT `to_course_id_refs_id_e84e4bbd` FOREIGN KEY (`to_course_id`) REFERENCES `coursearea_course` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_course_style` -- DROP TABLE IF EXISTS `coursearea_course_style`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_course_style` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name_x` double NOT NULL, `name_y` double NOT NULL, `font_size` double NOT NULL, `qrcode_x` double NOT NULL, `qrcode_y` double NOT NULL, `qrcode_size` double NOT NULL, `bg` varchar(500) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_group` -- DROP TABLE IF EXISTS `coursearea_group`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_group` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `avatar` longtext NOT NULL, `desc` longtext NOT NULL, `link` varchar(500) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_image` -- DROP TABLE IF EXISTS `coursearea_image`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_image` ( `id` int(11) NOT NULL AUTO_INCREMENT, `url` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_series` -- DROP TABLE IF EXISTS `coursearea_series`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_series` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `term_length` int(10) unsigned NOT NULL, `cover_url` varchar(500) DEFAULT NULL, `unlock_num` int(10) unsigned NOT NULL, `create_time` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_subscribe` -- DROP TABLE IF EXISTS `coursearea_subscribe`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_subscribe` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `series_id` int(11) NOT NULL, `create_time` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `user_id` (`user_id`,`series_id`), KEY `coursearea_subscribe_6340c63c` (`user_id`), KEY `coursearea_subscribe_489757ad` (`series_id`), CONSTRAINT `series_id_refs_id_3cd2961e` FOREIGN KEY (`series_id`) REFERENCES `coursearea_series` (`id`), CONSTRAINT `user_id_refs_id_ea754772` FOREIGN KEY (`user_id`) REFERENCES `coursearea_user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_teacher` -- DROP TABLE IF EXISTS `coursearea_teacher`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_teacher` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `avatar` longtext NOT NULL, `desc` longtext NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_user` -- DROP TABLE IF EXISTS `coursearea_user`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `create_time` datetime NOT NULL, `openid` varchar(200) NOT NULL, `session_key` varchar(200) NOT NULL, `credential` varchar(50) NOT NULL, `nickname` varchar(50) NOT NULL, `gender` int(10) unsigned NOT NULL, `city` varchar(50) NOT NULL, `province` varchar(50) NOT NULL, `country` varchar(50) NOT NULL, `avatar` varchar(500) DEFAULT NULL, `language` longtext NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `openid` (`openid`), UNIQUE KEY `credential` (`credential`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `coursearea_visit` -- DROP TABLE IF EXISTS `coursearea_visit`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `coursearea_visit` ( `id` int(11) NOT NULL AUTO_INCREMENT, `unlock` tinyint(1) NOT NULL, `user_id` int(11) NOT NULL, `course_id` int(11) NOT NULL, `invited_by_id` int(11) DEFAULT NULL, `access_time` datetime NOT NULL, `invite_url` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `user_id` (`user_id`,`course_id`), KEY `coursearea_visit_6340c63c` (`user_id`), KEY `coursearea_visit_6234103b` (`course_id`), KEY `coursearea_visit_b8f8d6fa` (`invited_by_id`), CONSTRAINT `course_id_refs_id_554d4c8a` FOREIGN KEY (`course_id`) REFERENCES `coursearea_course` (`id`), CONSTRAINT `invited_by_id_refs_id_3bef0503` FOREIGN KEY (`invited_by_id`) REFERENCES `coursearea_user` (`id`), CONSTRAINT `user_id_refs_id_3bef0503` FOREIGN KEY (`user_id`) REFERENCES `coursearea_user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `django_content_type` -- DROP TABLE IF EXISTS `django_content_type`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `django_content_type` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL, `app_label` varchar(100) NOT NULL, `model` varchar(100) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `app_label` (`app_label`,`model`) ) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `django_session` -- DROP TABLE IF EXISTS `django_session`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `django_session` ( `session_key` varchar(40) NOT NULL, `session_data` longtext NOT NULL, `expire_date` datetime NOT NULL, PRIMARY KEY (`session_key`), KEY `django_session_b7b81f0c` (`expire_date`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `django_site` -- DROP TABLE IF EXISTS `django_site`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `django_site` ( `id` int(11) NOT NULL AUTO_INCREMENT, `domain` varchar(100) NOT NULL, `name` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; /*!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 2018-04-30 0:37:58
true
49e219ec5b488caabecf7dc4359177abd0b4e102
SQL
wir0x/cow
/db/script versioning/v1.5.sql
UTF-8
1,662
3.6875
4
[]
no_license
-- CREATE NEW TABLE FOR CONTROL LIMIT OF SMS CREATE TABLE sms_control ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, device_id BIGINT, month_year DATE, max_sms INT, used_sms INT, FOREIGN KEY (device_id) REFERENCES device (id) ); -- Subscription for device CREATE TABLE subscription ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, end_date DATE, max_sms INT, start_date DATE, device_id BIGINT, comment VARCHAR(512), name_package VARCHAR(255), FOREIGN KEY (device_id) REFERENCES device (id) ); CREATE INDEX fk_subscription_device_id ON subscription (device_id); -- insert new role for buho admin INSERT INTO roles (id, name) VALUES (12, 'subscription'); -- insert new role for group admin INSERT INTO group_role (group_id, role_id) VALUES (1, 12); -- update new role of the key -- update table subscription (2015-05-28) UPDATE configurations SET description = '', key_ = 'default.admin.group.roles', value = '1,2,3,4,5,6,9,10,11,13' WHERE id = 3; INSERT INTO roles (id, name) VALUES (13, 'state-account'); INSERT INTO group_role (group_id, role_id) SELECT id, 13 FROM groups WHERE name = 'Administrador'; -- add new column to table sms_control ALTER TABLE sms_control ADD sent_mail BOOLEAN; -- update table subscription (2015-05-28) ALTER TABLE subscription ADD comment VARCHAR(512); ALTER TABLE subscription ADD name_package VARCHAR(255); UPDATE configurations SET description = '', key_ = 'default.admin.group.roles', value = '1,2,3,4,5,6,9,10,11,13' WHERE id = 3; INSERT INTO roles (id, name) VALUES (13, 'state-account'); INSERT INTO group_role (group_id, role_id) SELECT id, 13 FROM groups WHERE name = 'Administrador';
true
3ba9bea02b6c18db4b96d7c9cf9dd901d76c67b9
SQL
alan-turing-institute/DSSG19-HomelessLink-PUBLIC
/sql/setup/join_features_with_semantic_alerts.sql
UTF-8
9,406
3.015625
3
[ "MIT" ]
permissive
-- ====== -- Description: -- 1. Drops if exists semantic.alerts_with_features -- 2. Joins origin semantic.alerts table (which already has some initial features) with more tables with features -- Last Updated: Aug 29, 2019 -- ====== DROP TABLE IF EXISTS semantic.alerts_with_features; CREATE TABLE IF NOT EXISTS semantic.alerts_with_features as ( select t1.*, t2.gen_date_weather, t2.avg_temperature, t2.min_temperature, t2.max_temperature, t2.avg_windspeed, t2.max_windgust, t2.max_precipprobability, t2.min_precipprobability, t2.snowaccumulation_flag, t3.la_avg_response_time_7d, t3.la_avg_response_time_28d, t3.alerts_last_7d, t3.alerts_last_28d, t3.person_found_last_7d, t3.person_found_last_28d, t3.referrals_last_7d, t3.referrals_last_28d, t3.person_found_rate_last_7d, t3.person_found_rate_last_28d, t4.alerts_within_50m_7d, t4.alerts_within_50m_7d_web_origin, t4.alerts_within_50m_7d_phone_origin, t4.alerts_within_50m_7d_mobile_app_origin, t4.alerts_within_50m_28d, t4.alerts_within_50m_28d_web_origin, t4.alerts_within_50m_28d_phone_origin, t4.alerts_within_50m_28d_mobile_app_origin, t4.alerts_within_50m_60d, t4.alerts_within_50m_60d_web_origin, t4.alerts_within_50m_60d_phone_origin, t4.alerts_within_50m_60d_mobile_app_origin, t4.alerts_within_50m_6mo, t4.alerts_within_50m_6mo_web_origin, t4.alerts_within_50m_6mo_phone_origin, t4.alerts_within_50m_6mo_mobile_app_origin, t4.alerts_within_250m_7d, t4.alerts_within_250m_7d_web_origin, t4.alerts_within_250m_7d_phone_origin, t4.alerts_within_250m_7d_mobile_app_origin, t4.alerts_within_250m_28d, t4.alerts_within_250m_28d_web_origin, t4.alerts_within_250m_28d_phone_origin, t4.alerts_within_250m_28d_mobile_app_origin, t4.alerts_within_250m_60d, t4.alerts_within_250m_60d_web_origin, t4.alerts_within_250m_60d_phone_origin, t4.alerts_within_250m_60d_mobile_app_origin, t4.alerts_within_250m_6mo, t4.alerts_within_250m_6mo_web_origin, t4.alerts_within_250m_6mo_phone_origin, t4.alerts_within_250m_6mo_mobile_app_origin, t4.alerts_within_1000m_7d, t4.alerts_within_1000m_7d_web_origin, t4.alerts_within_1000m_7d_phone_origin, t4.alerts_within_1000m_7d_mobile_app_origin, t4.alerts_within_1000m_28d, t4.alerts_within_1000m_28d_web_origin, t4.alerts_within_1000m_28d_phone_origin, t4.alerts_within_1000m_28d_mobile_app_origin, t4.alerts_within_1000m_60d, t4.alerts_within_1000m_60d_web_origin, t4.alerts_within_1000m_60d_phone_origin, t4.alerts_within_1000m_60d_mobile_app_origin, t4.alerts_within_1000m_6mo, t4.alerts_within_1000m_6mo_web_origin, t4.alerts_within_1000m_6mo_phone_origin, t4.alerts_within_1000m_6mo_mobile_app_origin, t4.alerts_within_5000m_7d, t4.alerts_within_5000m_7d_web_origin, t4.alerts_within_5000m_7d_phone_origin, t4.alerts_within_5000m_7d_mobile_app_origin, t4.alerts_within_5000m_28d, t4.alerts_within_5000m_28d_web_origin, t4.alerts_within_5000m_28d_phone_origin, t4.alerts_within_5000m_28d_mobile_app_origin, t4.alerts_within_5000m_60d, t4.alerts_within_5000m_60d_web_origin, t4.alerts_within_5000m_60d_phone_origin, t4.alerts_within_5000m_60d_mobile_app_origin, t4.alerts_within_5000m_6mo, t4.alerts_within_5000m_6mo_web_origin, t4.alerts_within_5000m_6mo_phone_origin, t4.alerts_within_5000m_6mo_mobile_app_origin, t4.referrals_within_50m_7d, t4.referrals_within_50m_7d_web_origin, t4.referrals_within_50m_7d_phone_origin, t4.referrals_within_50m_7d_mobile_app_origin, t4.referrals_within_50m_28d, t4.referrals_within_50m_28d_web_origin, t4.referrals_within_50m_28d_phone_origin, t4.referrals_within_50m_28d_mobile_app_origin, t4.referrals_within_50m_60d, t4.referrals_within_50m_60d_web_origin, t4.referrals_within_50m_60d_phone_origin, t4.referrals_within_50m_60d_mobile_app_origin, t4.referrals_within_50m_6mo, t4.referrals_within_50m_6mo_web_origin, t4.referrals_within_50m_6mo_phone_origin, t4.referrals_within_50m_6mo_mobile_app_origin, t4.referrals_within_250m_7d, t4.referrals_within_250m_7d_web_origin, t4.referrals_within_250m_7d_phone_origin, t4.referrals_within_250m_7d_mobile_app_origin, t4.referrals_within_250m_28d, t4.referrals_within_250m_28d_web_origin, t4.referrals_within_250m_28d_phone_origin, t4.referrals_within_250m_28d_mobile_app_origin, t4.referrals_within_250m_60d, t4.referrals_within_250m_60d_web_origin, t4.referrals_within_250m_60d_phone_origin, t4.referrals_within_250m_60d_mobile_app_origin, t4.referrals_within_250m_6mo, t4.referrals_within_250m_6mo_web_origin, t4.referrals_within_250m_6mo_phone_origin, t4.referrals_within_250m_6mo_mobile_app_origin, t4.referrals_within_1000m_7d, t4.referrals_within_1000m_7d_web_origin, t4.referrals_within_1000m_7d_phone_origin, t4.referrals_within_1000m_7d_mobile_app_origin, t4.referrals_within_1000m_28d, t4.referrals_within_1000m_28d_web_origin, t4.referrals_within_1000m_28d_phone_origin, t4.referrals_within_1000m_28d_mobile_app_origin, t4.referrals_within_1000m_60d, t4.referrals_within_1000m_60d_web_origin, t4.referrals_within_1000m_60d_phone_origin, t4.referrals_within_1000m_60d_mobile_app_origin, t4.referrals_within_1000m_6mo, t4.referrals_within_1000m_6mo_web_origin, t4.referrals_within_1000m_6mo_phone_origin, t4.referrals_within_1000m_6mo_mobile_app_origin, t4.referrals_within_5000m_7d, t4.referrals_within_5000m_7d_web_origin, t4.referrals_within_5000m_7d_phone_origin, t4.referrals_within_5000m_7d_mobile_app_origin, t4.referrals_within_5000m_28d, t4.referrals_within_5000m_28d_web_origin, t4.referrals_within_5000m_28d_phone_origin, t4.referrals_within_5000m_28d_mobile_app_origin, t4.referrals_within_5000m_60d, t4.referrals_within_5000m_60d_web_origin, t4.referrals_within_5000m_60d_phone_origin, t4.referrals_within_5000m_60d_mobile_app_origin, t4.referrals_within_5000m_6mo, t4.referrals_within_5000m_6mo_web_origin, t4.referrals_within_5000m_6mo_phone_origin, t4.referrals_within_5000m_6mo_mobile_app_origin, t4.persons_found_within_50m_7d, t4.persons_found_within_50m_7d_web_origin, t4.persons_found_within_50m_7d_phone_origin, t4.persons_found_within_50m_7d_mobile_app_origin, t4.persons_found_within_50m_28d, t4.persons_found_within_50m_28d_web_origin, t4.persons_found_within_50m_28d_phone_origin, t4.persons_found_within_50m_28d_mobile_app_origin, t4.persons_found_within_50m_60d, t4.persons_found_within_50m_60d_web_origin, t4.persons_found_within_50m_60d_phone_origin, t4.persons_found_within_50m_60d_mobile_app_origin, t4.persons_found_within_50m_6mo, t4.persons_found_within_50m_6mo_web_origin, t4.persons_found_within_50m_6mo_phone_origin, t4.persons_found_within_50m_6mo_mobile_app_origin, t4.persons_found_within_250m_7d, t4.persons_found_within_250m_7d_web_origin, t4.persons_found_within_250m_7d_phone_origin, t4.persons_found_within_250m_7d_mobile_app_origin, t4.persons_found_within_250m_28d, t4.persons_found_within_250m_28d_web_origin, t4.persons_found_within_250m_28d_phone_origin, t4.persons_found_within_250m_28d_mobile_app_origin, t4.persons_found_within_250m_60d, t4.persons_found_within_250m_60d_web_origin, t4.persons_found_within_250m_60d_phone_origin, t4.persons_found_within_250m_60d_mobile_app_origin, t4.persons_found_within_250m_6mo, t4.persons_found_within_250m_6mo_web_origin, t4.persons_found_within_250m_6mo_phone_origin, t4.persons_found_within_250m_6mo_mobile_app_origin, t4.persons_found_within_1000m_7d, t4.persons_found_within_1000m_7d_web_origin, t4.persons_found_within_1000m_7d_phone_origin, t4.persons_found_within_1000m_7d_mobile_app_origin, t4.persons_found_within_1000m_28d, t4.persons_found_within_1000m_28d_web_origin, t4.persons_found_within_1000m_28d_phone_origin, t4.persons_found_within_1000m_28d_mobile_app_origin, t4.persons_found_within_1000m_60d, t4.persons_found_within_1000m_60d_web_origin, t4.persons_found_within_1000m_60d_phone_origin, t4.persons_found_within_1000m_60d_mobile_app_origin, t4.persons_found_within_1000m_6mo, t4.persons_found_within_1000m_6mo_web_origin, t4.persons_found_within_1000m_6mo_phone_origin, t4.persons_found_within_1000m_6mo_mobile_app_origin, t4.persons_found_within_5000m_7d, t4.persons_found_within_5000m_7d_web_origin, t4.persons_found_within_5000m_7d_phone_origin, t4.persons_found_within_5000m_7d_mobile_app_origin, t4.persons_found_within_5000m_28d, t4.persons_found_within_5000m_28d_web_origin, t4.persons_found_within_5000m_28d_phone_origin, t4.persons_found_within_5000m_28d_mobile_app_origin, t4.persons_found_within_5000m_60d, t4.persons_found_within_5000m_60d_web_origin, t4.persons_found_within_5000m_60d_phone_origin, t4.persons_found_within_5000m_60d_mobile_app_origin, t4.persons_found_within_5000m_6mo, t4.persons_found_within_5000m_6mo_web_origin, t4.persons_found_within_5000m_6mo_phone_origin, t4.persons_found_within_5000m_6mo_mobile_app_origin, t5.distance_to_nearest_hotspot, t5.hotspot_within_50m, t5.hotspot_within_100m, t5.hotspot_within_250m, t5.hotspot_within_500m, t5.hotspot_within_1000m, t5.hotspot_within_5000m, t5.hotspot_within_10km from semantic.alerts t1 left join features.weather t2 on CAST(t1.datetime_opened as DATE) = t2.gen_date_weather left join features.local_authority_metrics t3 on t3.alert = t1.alert left join features.distance_time_from_alert t4 on t4.alert = t1.alert left joinfeatures.distance_from_nearest_hotspot t5 on t5.alert = t1.alert )
true
afeef373738ddfc4f7e6dd9cbe950f2e89c6aed8
SQL
abidfr/Tugas-UI-Database-Abid
/dblatihan.sql
UTF-8
1,586
2.96875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.0.3 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Waktu pembuatan: 18 Nov 2020 pada 08.01 -- Versi server: 10.4.14-MariaDB -- Versi PHP: 7.4.11 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 */; -- -- Database: `dblatihan` -- -- -------------------------------------------------------- -- -- Struktur dari tabel `tmhs` -- CREATE TABLE `tmhs` ( `id_mhs` int(11) NOT NULL, `nim` varchar(9) NOT NULL, `nama` varchar(100) NOT NULL, `alamat` varchar(128) NOT NULL, `prodi` varchar(128) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data untuk tabel `tmhs` -- INSERT INTO `tmhs` (`id_mhs`, `nim`, `nama`, `alamat`, `prodi`) VALUES (1, '16.01.011', 'TUKIJO', 'JL.kebon sawo', 'Si-S3'), (2, '809.03.09', 'Abid Fadillah Rifky', 'Jl.Penatusan', 'D3-S3'); -- -- Indexes for dumped tables -- -- -- Indeks untuk tabel `tmhs` -- ALTER TABLE `tmhs` ADD PRIMARY KEY (`id_mhs`); -- -- AUTO_INCREMENT untuk tabel yang dibuang -- -- -- AUTO_INCREMENT untuk tabel `tmhs` -- ALTER TABLE `tmhs` MODIFY `id_mhs` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; 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
1297c56fcc332e0bb131c2a125e830219a6cb1e2
SQL
YaroslavTir/msh122
/metro-core/src/main/resources/db/migration/V00045__screensaver_remove_reference.sql
UTF-8
1,086
2.984375
3
[]
no_license
alter table im add column screensaver_url varchar(1024); alter table lobby add column screensaver_url varchar(1024); alter table station add column screensaver_url varchar(1024); alter table line add column screensaver_url varchar(1024); alter table schema add column screensaver_url varchar(1024); update im set screensaver_url = mf.url from (select id, url from media) as mf where im.screensaver = mf.id; update lobby set screensaver_url = mf.url from (select id, url from media) as mf where lobby.screensaver = mf.id; update station set screensaver_url = mf.url from (select id, url from media) as mf where station.screensaver = mf.id; update line set screensaver_url = mf.url from (select id, url from media) as mf where line.screensaver = mf.id; update schema set screensaver_url = mf.url from (select id, url from media) as mf where schema.screensaver = mf.id; alter table im drop column screensaver; alter table lobby drop column screensaver; alter table station drop column screensaver; alter table line drop column screensaver; alter table schema drop column screensaver;
true
141ce5521d3acf622ca4cc587e718ef64356bae4
SQL
Abdur-samad-siham/Online_Job_Portal
/db.sql
UTF-8
6,214
3.25
3
[]
no_license
-------------------------------Company Table---------------------------- CREATE TABLE company -------------------------------done ( company_id int IDENTITY(1000,1) PRIMARY KEY, password varchar(50) NOT NULL, company_name varchar(50) NOT NULL, website_url varchar(50) NULL, company_email varchar(30) NOT NULL unique, company_contact varchar(11) NOT NULL ) -------------------------------Job_Information---------------------------- CREATE TABLE Job_Information -------------------------done ( job_id int IDENTITY(1000,1) PRIMARY KEY, company_id int NOT NULL FOREIGN KEY REFERENCES company(company_id), application_LastDate varchar(20) NOT NULL, job_category varchar(30) NOT NULL, job_requirements varchar(500) NOT NULL, job_type varchar(50) NOT NULL, No_of_vacancy int NOT NULL, salary varchar(50) NOT NULL, form_fee varchar(50) NULL, age varchar(20) NULL, job_posting varchar(50) NOT NULL ) select * from Job_Information SELECT company.company_name FROM company INNER JOIN Job_Information ON company.company_id = Job_Information.company_id WHERE Job_Information.job_id = '1013' -------------------------------applicant---------------------------- CREATE TABLE applicant -------------------------------done ( applicant_id int IDENTITY(1001,1) PRIMARY KEY, password varchar(50) NOT NULL, applicant_name varchar(100) NOT NULL, applicant_phone varchar(11) NOT NULL, applicant_email varchar(50) NOT NULL unique, date_of_birth varchar(50) NOT NULL, applicant_age varchar(50) NOT NULL, image image NOT NULL, ------------------------- gender varchar(6) NOT NULL, present_address varchar(50) NOT NULL, permanent_address varchar(50) NOT NULL, education varchar(20) not null ) select * from applicant -------------------------------Application_details---------------------------- CREATE TABLE application_details ( application_id int IDENTITY(1,1) PRIMARY KEY, job_id int NOT NULL FOREIGN KEY REFERENCES Job_Information(job_id), applicant_id int NOT NULL FOREIGN KEY REFERENCES applicant(applicant_id), skills varchar(50) NOT NULL, experience varchar(50) NOT NULL, reason_for_hiring varchar(200) NOT NULL, --status varchar(50) NOT NULL, -------------------- ) ALTER TABLE application_details ADD emp_status varchar (30) select * from application_details -------------------------------Employee review---------------------------- CREATE TABLE employee_review ( review_id int IDENTITY(1,1) PRIMARY KEY, applicant_id int NOT NULL FOREIGN KEY REFERENCES applicant(applicant_id), company_id int NOT NULL FOREIGN KEY REFERENCES COMPANY(company_id), previous_company_post varchar(20) NOT NULL, review varchar(512) NOT NULL, ) -------------------------------Job Result---------------------------- CREATE TABLE job_result ( result_id int IDENTITY(1,1) PRIMARY KEY, job_id int NOT NULL FOREIGN KEY REFERENCES Job_Information(job_id), applicant_id int NOT NULL FOREIGN KEY REFERENCES applicant(applicant_id), status varchar(50) NOT NULL, --------------------------------------------- short_message varchar(100) NULL, interview_location varchar(50) NULL, interview_date varchar(20) NULL ) -------------------------------Applicant credential---------------------------- CREATE TABLE applicant_credential ( credential_id int IDENTITY(1,1) PRIMARY KEY, job_id int NOT NULL FOREIGN KEY REFERENCES Job_Information(job_id), applicant_id int NOT NULL FOREIGN KEY REFERENCES applicant(applicant_id), image1 image NULL, image2 image NULL, image3 image NULL, image4 image NULL, image5 image NULL, image6 image NULL, doc_name_1 varchar(30) NULL, doc_name_2 varchar(30) NULL, doc_name_3 varchar(30) NULL, doc_name_4 varchar(30) NULL, doc_name_5 varchar(30) NULL, doc_name_6 varchar(30) NULL, -------------------------------------------------- ) -------------------------------Transection---------------------------- CREATE TABLE transection ( trx_id varchar(50) PRIMARY KEY, job_id int NOT NULL FOREIGN KEY REFERENCES Job_Information(job_id), applicant_id int NOT NULL FOREIGN KEY REFERENCES applicant(applicant_id), transection_by varchar (15) not null, status varchar(20) null default 'not verified' ) SELECT application_details.applicant_id , skills,experience,reason_for_hiring,status,trx_id,transection_by FROM application_details LEFT JOIN transection ON application_details.applicant_id = transection.applicant_id WHERE application_details.job_id = '1013' SELECT application_details.applicant_id , skills,experience,reason_for_hiring,status,trx_id,transection_by ,application_details.job_id FROM application_details INNER JOIN transection ON application_details.applicant_id = transection.applicant_id AND application_details.job_id = transection.job_id WHERE application_details.job_id = '1013' SELECT company_contact FROM Job_Information INNER JOIN company ON Job_Information.company_id = company.company_id WHERE Job_Information.job_id = '1013' ----------------Display Table----------- select * from company select * from Job_Information select * from applicant select * from application_details select * from transection select * from employee_review select * from job_result select * from applicant_credential select * from Job_Information select * from application_details SELECT application_details.job_id,Job_Information.job_category,Job_Information.job_posting,Job_Information.job_type FROM application_details INNER JOIN Job_Information ON application_details.job_id = Job_Information.job_id WHERE application_details.applicant_id = '1001' select * from job_result where applicant_id= '1001' AND job_id='1001' Alter Table applicant drop column FirstName CREATE TABLE msg ( job_id int NOT NULL FOREIGN KEY REFERENCES Job_Information(job_id), applicant_id int NOT NULL FOREIGN KEY REFERENCES applicant(applicant_id), msg varchar (300) not null, rd varchar(20) null ) select * from msg drop table msg
true
0caf7bccea6d5f287dc6616dc0122ac782d95be8
SQL
kunalkalbande/SQLDM
/Development/Idera/SQLdm/CollectionService/Resources/Probes/Sql/Batches/QueryPlanEstRows2005_2.sql
UTF-8
688
3.234375
3
[]
no_license
-------------------------------------------------------------- -- SQLDM 11 - Recommended changes for Azure SQL Database v12 -------------------------------------------------------------- --RRG: Only works on User Databases for Azure SQL Database ;with xmlnamespaces (default 'http://schemas.microsoft.com/sqlserver/2004/07/showplan') select top 100 stmt.value('(@StatementText)[1]', 'varchar(max)') as Text, stmt.value('(@StatementEstRows)[1]', 'varchar(max)') as EstRows from sys.dm_exec_cached_plans as cp cross apply sys.dm_exec_query_plan(plan_handle) as qp cross apply query_plan.nodes('/ShowPlanXML/BatchSequence/Batch/Statements/StmtSimple') as batch(stmt)
true
e72b1f199aec45db3908899d98f9855a0aeb5d89
SQL
elangeladri28/Progra-Web-de-Capa-Intermedia
/CurSOS/db/CurSOS_SP_Functions_Triggers.sql
UTF-8
7,274
3.71875
4
[]
no_license
use cursos; -- Stored procedures DROP PROCEDURE IF EXISTS getChatEntero; DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `getChatEntero`(idprimero INT, idsegundo INT) BEGIN Select id_cp, persona.usuario, mensaje, persona2.usuario as usuario2 from chatPrivado inner join Usuario as persona on persona.id_usuario = usuarioid inner join Usuario as persona2 on persona2.id_usuario = usuarioid2 Where (usuarioid = idprimero and usuarioid2 = idsegundo) or (usuarioid = idsegundo and usuarioid2 = idprimero) order by fechamensaje desc; END$$ DELIMITER ; DROP PROCEDURE IF EXISTS getCursoVentas; DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `getCursoVentas`(idcurso INT) BEGIN Select nombre, (Select Count(usuarioid) from Contrata where cursoid = idcurso) as cantidad_personas, ((Select Count(usuarioid) from Contrata where cursoid = idcurso) * (Select costo from Curso where id_curso = idcurso)) as cantidad_total from Curso WHERE id_curso = idcurso; END$$ DELIMITER ; DROP PROCEDURE IF EXISTS getPersonasChateas; DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `getPersonasChateas`(idusuario INT) BEGIN SELECT usuario FROM (Select persona.usuario, mensaje from chatPrivado inner join Usuario as persona on persona.id_usuario = usuarioid2 Where usuarioid = idusuario UNION Select persona.usuario, mensaje from chatPrivado inner join Usuario as persona on persona.id_usuario = usuarioid Where usuarioid2 = idusuario) AS T3 GROUP BY usuario; END$$ DELIMITER ; DROP PROCEDURE IF EXISTS getUserByUsername; DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `getUserByUsername`(Username VARCHAR(50)) BEGIN SELECT id_usuario, rol, usuario, nombre, apellidos, correo, contra, avatar FROM Usuario WHERE Usuario = Username and activo = TRUE; END$$ DELIMITER ; DROP PROCEDURE IF EXISTS aumentaSuProgreso; DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `aumentaSuProgreso`(idusuario int,idcurso int) BEGIN DECLARE cuentamelasLecciones INT; DECLARE contadorleccionesvistas INT; DECLARE progresoactual DOUBLE; SET cuentamelasLecciones = ( Select Count(id_leccion) FROM LasLecciones WHERE cursoid = idcurso); -- Traemos el numero de lecciones SET contadorleccionesvistas = ( Select contadorLecciones from Contrata WHERE usuarioid = idusuario and cursoid = idcurso)+1; SET progresoactual = contadorleccionesvistas * 100 / cuentamelasLecciones; UPDATE Contrata SET progreso = progresoactual, contadorLecciones = contadorleccionesvistas WHERE usuarioid = idusuario and cursoid = idcurso; END$$ DELIMITER ; -- Funciones SET GLOBAL log_bin_trust_function_creators = 1; DROP FUNCTION IF EXISTS TraerIDPersonaChateas; DELIMITER $$ CREATE DEFINER=`root`@`localhost` FUNCTION `TraerIDPersonaChateas`(nombre VARCHAR(255)) RETURNS int BEGIN DECLARE suid INT; SET suid = (Select id_usuario from Usuario where usuario = nombre); RETURN suid; END$$ DELIMITER ; DROP FUNCTION IF EXISTS RevisaEstaContratado; DELIMITER $$ CREATE DEFINER=`root`@`localhost` FUNCTION `RevisaEstaContratado`(idusuario int,idcurso int) RETURNS int BEGIN DECLARE numero INT; SET numero = (SELECT COUNT(id_contrata) FROM Contrata WHERE usuarioid = idusuario and cursoid = idcurso); RETURN numero; END$$ DELIMITER ; DROP FUNCTION IF EXISTS RevisaSiYaTienesLasLecciones; DELIMITER $$ CREATE DEFINER=`root`@`localhost` FUNCTION `RevisaSiYaTienesLasLecciones`(idusuario int,idcurso int ) RETURNS int BEGIN DECLARE progresoactual DOUBLE; DECLARE numero int; SET progresoactual = (SELECT progreso FROM Contrata WHERE usuarioid = idusuario and cursoid = idcurso); IF progresoactual >= 100 THEN SET numero = 1; -- YaCompletoElCurso ELSE SET numero = 0; -- Le falta al chabon por ver END IF; RETURN numero; END$$ DELIMITER ; DROP FUNCTION IF EXISTS ContadorContratados; DELIMITER $$ CREATE DEFINER=`root`@`localhost` FUNCTION `ContadorContratados`(idcurso int) RETURNS int BEGIN DECLARE numero INT; SET numero = (SELECT COUNT(cursoid) FROM Contrata WHERE cursoid = idcurso); RETURN numero; END$$ DELIMITER ; -- Triggers DELIMITER $$ CREATE TRIGGER after_contrata_insert AFTER INSERT ON Contrata FOR EACH ROW BEGIN DELETE FROM Carrito WHERE NEW.usuarioid = Carrito.usuarioid AND NEW.cursoid = Carrito.cursoid; END$$ DELIMITER ; DELIMITER $$ CREATE TRIGGER after_contrata_insert2 AFTER INSERT ON Contrata FOR EACH ROW BEGIN INSERT INTO `cursos`.`historial`(`id_historial`,`cursoid`,`usuarioid`)VALUES(null,NEW.cursoid,NEW.usuarioid); END$$ DELIMITER ; -- Views DROP VIEW IF EXISTS LasCategorias; CREATE VIEW LasCategorias AS SELECT `categoria`.`id_categoria`, `categoria`.`categoria`,`categoria`.`descripcion`, `categoria`.`activo` FROM `cursos`.`categoria`; DROP VIEW IF EXISTS LosCursos; CREATE VIEW LosCursos AS SELECT `curso`.`id_curso`,`curso`.`nombre`,`curso`.`descripcion`,`curso`.`costo`,`curso`.`foto`,`curso`.`video`,`curso`.`categoriaid`,`curso`.`activo`,`curso`.`fechaCreado`,`curso`.`usuid`FROM `cursos`.`curso`; DROP VIEW IF EXISTS LosCursosBuscados; CREATE VIEW LosCursosBuscados AS SELECT `curso`.`id_curso`,`curso`.`nombre`,`curso`.`descripcion`,`curso`.`costo`,`curso`.`foto`,`curso`.`video`,`curso`.`categoriaid`,`curso`.`activo`,`curso`.`fechaCreado`,`curso`.`usuid`,Usuario.nombre as CreadorCurso FROM `cursos`.`curso` inner join Usuario on Usuario.id_usuario = curso.usuid; DROP VIEW IF EXISTS HistorialDeCursos; CREATE VIEW HistorialDeCursos AS SELECT curso.id_curso,curso.nombre,curso.descripcion,curso.costo,curso.foto,curso.video,curso.categoriaid,curso.activo,curso.fechaCreado,curso.usuid, Usuario.usuario as CreadorCurso, usuarioid FROM Historial inner join curso on curso.usuid = Historial.cursoid inner join Usuario on Usuario.id_usuario = Curso.usuid; DROP VIEW IF EXISTS LasLecciones; CREATE VIEW LasLecciones AS SELECT `leccion`.`id_leccion`,`leccion`.`nombre`,`leccion`.`cursoid`,`leccion`.`nivel`,`leccion`.`archivo`,`leccion`.`foto`,`leccion`.`video`,`leccion`.`extra`,`leccion`.`activo`,`leccion`.`fechaCreado`FROM `cursos`.`leccion`; DROP VIEW IF EXISTS ElCarrito; CREATE VIEW ElCarrito AS SELECT id_carrito,Curso.nombre as NombreCurso,Usuario.nombre as NombreUsuario, usuarioid, cursoid FROM `cursos`.`carrito` inner join Usuario on Usuario.id_usuario = Carrito.usuarioid inner join Curso on Curso.id_curso = Carrito.cursoid; DROP VIEW IF EXISTS LosCursosCarrito; CREATE VIEW LosCursosCarrito AS SELECT id_carrito,Curso.nombre as NombreCurso, Curso.foto as FotoCurso, Curso.descripcion as DescripcionCurso, Curso.costo as PrecioCurso, cursoid, usuarioid FROM `cursos`.`carrito` inner join Curso on Curso.id_curso = Carrito.cursoid; DROP VIEW IF EXISTS ComentariosDelCurso; CREATE VIEW ComentariosDelCurso AS SELECT id_comencurs,cursoid, comentario, Usuario.nombre as NombreUsuario, usuid FROM `cursos`.`ComentarioCurso` inner join Usuario on Usuario.id_usuario = ComentarioCurso.usuid; DROP VIEW IF EXISTS CursosDelUsuario; CREATE VIEW CursosDelUsuario AS SELECT `contrata`.`id_contrata`,`contrata`.`usuarioid`,`contrata`.`cursoid`,`contrata`.`calificacioncurso`,`contrata`.`progreso`,Curso.nombre as Nombrecurso FROM `cursos`.`contrata` inner join Curso on Curso.id_curso = Contrata.cursoid;
true
072ea0d4a862f22ef4e67020ca59c5b5f8d80fa5
SQL
Niko123321-ops/SamoSpletnaStran
/hi-fi.sql
UTF-8
4,485
3.09375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.8.5 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jun 29, 2020 at 05:54 PM -- Server version: 10.1.40-MariaDB -- PHP Version: 7.3.5 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: `hi-fi` -- -- -------------------------------------------------------- -- -- Table structure for table `hifi_zvocniki` -- CREATE TABLE `hifi_zvocniki` ( `id` bigint(20) UNSIGNED NOT NULL, `ime` varchar(50) COLLATE utf8mb4_slovenian_ci NOT NULL, `opis` text COLLATE utf8mb4_slovenian_ci NOT NULL, `slika` varchar(255) COLLATE utf8mb4_slovenian_ci DEFAULT NULL, `uporabnik_id` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_slovenian_ci; -- -- Dumping data for table `hifi_zvocniki` -- INSERT INTO `hifi_zvocniki` (`id`, `ime`, `opis`, `slika`, `uporabnik_id`) VALUES (13, 'Titanic', 'ok', 'uploads/titanic1.jpg', 5), (14, 'Joker', 'ok', 'uploads/joker.jpg', 4); -- -------------------------------------------------------- -- -- Table structure for table `ocene` -- CREATE TABLE `ocene` ( `id` bigint(20) UNSIGNED NOT NULL, `hifi_zvocniki_id` bigint(20) UNSIGNED NOT NULL, `uporabnik_id` bigint(20) UNSIGNED NOT NULL, `datum` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `ocena` varchar(2) COLLATE utf8mb4_slovenian_ci NOT NULL, `prednosti` varchar(100) COLLATE utf8mb4_slovenian_ci NOT NULL, `slabosti` varchar(100) COLLATE utf8mb4_slovenian_ci NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_slovenian_ci; -- -- Dumping data for table `ocene` -- INSERT INTO `ocene` (`id`, `hifi_zvocniki_id`, `uporabnik_id`, `datum`, `ocena`, `prednosti`, `slabosti`) VALUES (21, 13, 4, '2020-06-29 15:45:29', '', 'koko', 'koko'), (20, 10, 5, '2020-06-29 15:17:31', '', 'ok', 'ok'), (18, 9, 0, '2020-06-29 13:55:24', '4', 'k', 'k'), (19, 12, 4, '2020-06-29 15:00:36', '3', 'xvfc', 'xvfc'), (17, 9, 5, '2020-06-29 13:54:54', '3', 'lol', 'lol'), (22, 13, 4, '2020-06-29 15:45:33', '', 'kokook', 'kokook'), (23, 13, 4, '2020-06-29 15:51:19', '', 'vdf', 'vdf'), (24, 13, 4, '2020-06-29 15:51:23', '', 'fsdfsd', 'fsdfsd'); -- -------------------------------------------------------- -- -- Table structure for table `uporabniki` -- CREATE TABLE `uporabniki` ( `id` bigint(20) UNSIGNED NOT NULL, `ime` varchar(50) COLLATE utf8mb4_slovenian_ci NOT NULL, `priimek` varchar(50) COLLATE utf8mb4_slovenian_ci NOT NULL, `pass` varchar(100) COLLATE utf8mb4_slovenian_ci NOT NULL, `email` varchar(100) COLLATE utf8mb4_slovenian_ci NOT NULL, `tip` varchar(100) COLLATE utf8mb4_slovenian_ci DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_slovenian_ci; -- -- Dumping data for table `uporabniki` -- INSERT INTO `uporabniki` (`id`, `ime`, `priimek`, `pass`, `email`, `tip`) VALUES (5, 'Anonymous', ' ', 'superhardpassword', 'Anonymous@gmail.com', '0'), (4, 'test', 'test', 'aa5e16c3cf524125ec46c2dcfcf6b6cf14594f72', 'test@gmail.com', '0'), (6, 'Tilen', 'Krivec', 'c484f3a8cf4627d8c3e816d72ac929614a94ff26', 'pegasus221krivec@gmail.com', '0'); -- -- Indexes for dumped tables -- -- -- Indexes for table `hifi_zvocniki` -- ALTER TABLE `hifi_zvocniki` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`); -- -- Indexes for table `ocene` -- ALTER TABLE `ocene` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`), ADD KEY `hifi_zvocniki_id` (`hifi_zvocniki_id`), ADD KEY `uporabnik_id` (`uporabnik_id`); -- -- Indexes for table `uporabniki` -- ALTER TABLE `uporabniki` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `hifi_zvocniki` -- ALTER TABLE `hifi_zvocniki` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15; -- -- AUTO_INCREMENT for table `ocene` -- ALTER TABLE `ocene` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25; -- -- AUTO_INCREMENT for table `uporabniki` -- ALTER TABLE `uporabniki` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; 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
c106bbdd153a5366a2a8c53c7c1ccb1f7a173ebe
SQL
haojingus/pycms
/sql/template_create.sql
UTF-8
916
3.25
3
[]
no_license
CREATE TABLE `{$tblname}` ( `document_id` int(11) NOT NULL COMMENT '文档id', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `publish_time` timestamp NULL DEFAULT NULL COMMENT '发布时间', `is_delete` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除 ', `create_user` char(32) NOT NULL COMMENT '创建者', `modify_user` char(32) NOT NULL COMMENT '修改者', `publish_user` char(32) DEFAULT NULL COMMENT '发布人', `publish_url` varchar(1024) DEFAULT NULL COMMENT '发布url' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT = DYNAMIC; ALTER TABLE `{$tblname}` ADD PRIMARY KEY (`document_id`), ADD KEY `create_time` (`create_time`), ADD KEY `is_delete` (`is_delete`), ADD KEY `create_user` (`create_user`), ADD KEY `publish_user` (`publish_user`); ALTER TABLE `{$tblname}` MODIFY `document_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '文档id';
true
22b491ade5f9332d178183fddcc3759b15c6ecc1
SQL
RHFarfsing/sql-tutorial
/Sales v1.0 group and having .sql
UTF-8
318
3.828125
4
[]
no_license
select city,sum(sales) as 'Total of sales', max(sales) as 'Max sales', min(sales) as 'Min sales', avg(sales) as 'Avg sales', count(sales) as 'Number of customers' from Customers --where sales > 50000 group by city having sum(sales)>600000 --order by sales desc; --order by and having and agrigates
true
ab85fa39a29ad66b05f770acf3a4dab3735ef1d6
SQL
ppeprojetcv/ProjetCV
/SQL.sql
UTF-8
2,688
3.515625
4
[]
no_license
CREATE TABLE types ( typ_id serial, typ_nom varchar(50), typ_duree varchar(30), typ_nbCreer int, typ_nbAccepter int, CONSTRAINT typ_pk PRIMARY KEY (typ_id) ); CREATE TABLE niveaux ( niv_id serial, niv_nom varchar(50), CONSTRAINT niv_pk PRIMARY KEY (niv_id) ); CREATE TABLE diplomes ( dip_id serial, dip_nom varchar(50), dip_niv_id int, CONSTRAINT dip_pk PRIMARY KEY (dip_id), CONSTRAINT dip_fk FOREIGN KEY (dip_niv_id) REFERENCES niveaux (niv_id) ); CREATE TABLE adresses ( adr_id serial, adr_rue varchar(100), adr_codePostal int(5), adr_ville varchar(50), CONSTRAINT adr_pk PRIMARY KEY (adr_id) ); CREATE TABLE candidats ( can_id serial, can_nom varchar(50), can_prenom varchar(50), can_dateNaissance date, can_numTelephone int(12), can_nationalite varchar(50), can_permisConduire boolean, can_voiturePersonnelle boolean, can_photo varchar(100), can_adresseMail varchar(100), can_sexe boolean, can_adr_id int, CONSTRAINT can_pk PRIMARY KEY (can_id), CONSTRAINT can_fk FOREIGN KEY (can_adr_id) REFERENCES adresses (adr_id) ); CREATE TABLE curiculum ( cur_can_id int, cur_expPofessionnel char, cur_formation char, cur_competence char, cur_langue char, cur_centredInteret char, CONSTRAINT cur_pk PRIMARY KEY (cur_can_id), CONSTRAINT cur_fk FOREIGN KEY (cur_can_id) REFERENCES candidats (can_id) ); CREATE TABLE obt_diplomes_candidats ( obt_dip_id int, obt_can_id int, obt_date date, CONSTRAINT obt_pk PRIMARY KEY (obt_dip_id, obt_can_id), CONSTRAINT obt_dip_fk FOREIGN KEY (obt_dip_id) REFERENCES diplomes (dip_id), CONSTRAINT obt_can_fk FOREIGN KEY (obt_can_id) REFERENCES candidats (can_id) ); CREATE TABLE entreprises ( ent_id serial, ent_nom varchar(50), ent_description varchar(300), ent_adr_id int, CONSTRAINT ent_pk PRIMARY KEY (ent_id), CONSTRAINT ent_fk FOREIGN KEY (ent_adr_id) REFERENCES adresses (adr_id) ); CREATE TABLE postes ( pos_id serial, pos_nomPoste varchar(100), pos_duree varchar(30), pos_description char, pos_typ_id int, pos_ent_id int, CONSTRAINT pos_pk PRIMARY KEY (pos_id), CONSTRAINT pos_typ_fk FOREIGN KEY (pos_typ_id) REFERENCES types (typ_id), CONSTRAINT pos_ent_fk FOREIGN KEY (pos_ent_id) REFERENCES entreprises (ent_id) ); CREATE TABLE dem_postes_curriculum ( dem_pos_id int, dem_cur_can_id int, CONSTRAINT dem_pk PRIMARY KEY (dem_pos_id, dem_cur_can_id), CONSTRAINT dem_pos_fk FOREIGN KEY (dem_pos_id) REFERENCES postes (pos_id), CONSTRAINT dem_cur_can_fk FOREIGN KEY (dem_cur_can_id) REFERENCES curiculum (cur_can_id) );
true
85740be6ba3ab5853350b2e65f1f6e3d9738efdd
SQL
Spring-Secrity/Spring-Secrity-hibernate
/src/main/java/sql/createdb.sql
UTF-8
2,954
4.15625
4
[ "MIT" ]
permissive
/*All User's are stored in APP_USER table*/ create table APP_USER ( id BIGINT NOT NULL AUTO_INCREMENT, sso_id VARCHAR(30) NOT NULL, password VARCHAR(100) NOT NULL, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(30) NOT NULL, email VARCHAR(30) NOT NULL, state VARCHAR(30) NOT NULL, PRIMARY KEY (id), UNIQUE (sso_id) ); /* USER_PROFILE table contains all possible roles */ create table USER_PROFILE( id BIGINT NOT NULL AUTO_INCREMENT, type VARCHAR(30) NOT NULL, PRIMARY KEY (id), UNIQUE (type) ); /* JOIN TABLE for MANY-TO-MANY relationship*/ CREATE TABLE APP_USER_USER_PROFILE ( user_id BIGINT NOT NULL, user_profile_id BIGINT NOT NULL, PRIMARY KEY (user_id, user_profile_id), CONSTRAINT FK_APP_USER FOREIGN KEY (user_id) REFERENCES APP_USER (id), CONSTRAINT FK_USER_PROFILE FOREIGN KEY (user_profile_id) REFERENCES USER_PROFILE (id) ); /* Populate USER_PROFILE Table */ INSERT INTO USER_PROFILE(type) VALUES ('USER'); INSERT INTO USER_PROFILE(type) VALUES ('ADMIN'); INSERT INTO USER_PROFILE(type) VALUES ('DBA'); /* Populate APP_USER Table */ INSERT INTO APP_USER(sso_id, password, first_name, last_name, email, state) VALUES ('yiibai','123456', 'Yiibai','Watcher','admin@yiibai.com', 'Active'); INSERT INTO APP_USER(sso_id, password, first_name, last_name, email, state) VALUES ('danny','123456', 'Danny','Theys','danny@xyz.com', 'Active'); INSERT INTO APP_USER(sso_id, password, first_name, last_name, email, state) VALUES ('sam','123456', 'Sam','Smith','samy@xyz.com', 'Active'); INSERT INTO APP_USER(sso_id, password, first_name, last_name, email, state) VALUES ('nicole','123456', 'Nicole','warner','nicloe@xyz.com', 'Active'); INSERT INTO APP_USER(sso_id, password, first_name, last_name, email, state) VALUES ('kenny','123456', 'Kenny','Roger','kenny@xyz.com', 'Active'); /* Populate JOIN Table */ INSERT INTO APP_USER_USER_PROFILE (user_id, user_profile_id) SELECT user.id, profile.id FROM app_user user, user_profile profile where user.sso_id='bill' and profile.type='USER'; INSERT INTO APP_USER_USER_PROFILE (user_id, user_profile_id) SELECT user.id, profile.id FROM app_user user, user_profile profile where user.sso_id='danny' and profile.type='USER'; INSERT INTO APP_USER_USER_PROFILE (user_id, user_profile_id) SELECT user.id, profile.id FROM app_user user, user_profile profile where user.sso_id='sam' and profile.type='ADMIN'; INSERT INTO APP_USER_USER_PROFILE (user_id, user_profile_id) SELECT user.id, profile.id FROM app_user user, user_profile profile where user.sso_id='nicole' and profile.type='DBA'; INSERT INTO APP_USER_USER_PROFILE (user_id, user_profile_id) SELECT user.id, profile.id FROM app_user user, user_profile profile where user.sso_id='kenny' and profile.type='ADMIN'; INSERT INTO APP_USER_USER_PROFILE (user_id, user_profile_id) SELECT user.id, profile.id FROM app_user user, user_profile profile where user.sso_id='kenny' and profile.type='DBA';
true
630afe28eabc9cba365ed7e2705efce323375b40
SQL
ealparslan/broccoli-rest
/classes/production/api/data.sql
UTF-8
2,200
2.703125
3
[]
no_license
INSERT INTO `user` (`id`, `address`, `birth_date`, `country`, `email`, `facebook_id`, `full_name`, `gender`, `google_id`, `language`, `linkedid_id`, `password`, `photo`, `signup_on`, `state`, `twitter_id`, `zipcode`) VALUES (1,'deneme','2010-01-01 00:00:00','US','ealparslan@gmail.com',NULL,'Erhan Alparslan','M','ealparslan','Turkish',NULL,'deneme',NULL,'2017-01-01 00:00:00','CA',NULL,95117), (2,'dkdekdj','2010-01-01 00:00:00','US','ouuuz@gmail.com',NULL,'Oguzhan Topgul','F','oguzzz','English',NULL,'deneme',NULL,'2017-05-01 00:00:00','CA',NULL,94432), (3,'371 Aloe Vera Ave','2010-01-01 00:00:00','US','johnwick@gmail.com','johnwick','John Wick','M','jwick','English',NULL,'deneme',NULL,'2017-06-01 00:00:00','NJ',NULL,70041); INSERT INTO `speciality` (`id`, `description`, `title`) VALUES (1,'regular','Basic Diet'); INSERT INTO `dietician` (`id`, `intro`, `is_approved`, `rate`, `user_id`) VALUES (1,'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor i',b'1',4.2,2), (2,'At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt molliti',b'1',3.8,3); INSERT INTO `bank_account` (`id`, `account_number`, `added_on`, `bank`, `routing_number`, `dietician_id`) VALUES (1,'1237453','2017-01-01 00:00:00','Bank of America','4829',1), (2,'2876344','2017-01-01 00:00:00','Bank of America','2344',2); INSERT INTO `dieter` (`id`, `user_id`) VALUES (1,1); INSERT INTO `aggreement` (`offer_date`, `approved_date`, `pay_amount`, `pay_period`, `status`, `dietician_id`, `dieter_id`) VALUES ('2010-01-01 00:00:00','2010-01-03 00:00:00',121,'month',2,1,1); INSERT INTO `dietician_speciality` (`submit_date`, `approve_date`, `fee`, `is_approved`, `proof`, `dietician_id`, `speciality_id`) VALUES ('2017-07-10 00:00:00','2017-07-13 00:00:00',20,b'1',X'70726F6F66',1,1), ('2017-07-11 00:00:00','2017-07-14 00:00:00',14,b'1',NULL,2,1);
true
26b148adc2450c36ab769a7266df0526ae136d08
SQL
KaarkS797/The-Product-Company
/DW Aggregate/DW Aggregate/Shruken/shruken_quarter_insert.sql
UTF-8
422
2.703125
3
[]
no_license
INSERT INTO `dw-2205-team4_shrunkendimension`.`sale_quarter_dim` (`Sales_Quarter_SK`, `Sales_Quarter`, `Sales_Month`, `Sales_Fiscal_Quarter`, `Sales_Fiscal_Month`) SELECT `SalesDate_SK`, `Sales_Quarter`, `Sales_Month`, `Sales_Fiscal_Quarter`, `Sales_Fiscal_Month` FROM `dw-2205-team4_salesorders`.`saledate_dim` WHERE `Sales_Quarter` IS NOT NULL GROUP BY Sales_Quarter,Sales_Month,Sales_Fiscal_Quarter,Sales_Fiscal_Month;
true
3aa991e994c8d92e15d8125d876ab7dabf9fbd09
SQL
serener91/ITW
/lab_oracle/sql15.sql
UTF-8
1,530
4.1875
4
[]
no_license
-- call_chicken.csv 파일 다운로드 -- 테이블 이름: call_chicken -- 컬럼: call_date, call_day, gu, ages, gender, calls create table call_chicken ( call_date date, call_day varchar2(1 char), gu varchar2(5 char), ages varchar2(5 char), gender varchar2(1 char), calls number(4) ); select * from call_chicken; -- 1. 통화건수의 최댓값, 최솟값 select max(calls), min(calls) from call_chicken; -- 2. 통화건수가 최댓값이거나 또는 최솟값인 레코드를 출력 select * from call_chicken where calls = (select max(calls) from call_chicken) or calls = (select min(calls) from call_chicken) ; select * from call_chicken where calls = (select max(calls), min(calls) from call_chicken); -- 에러 발생: 다중 컬럼 서브 쿼리를 컬럼 하나와 비교할 수 없음! select max(calls) from call_chicken union select min(calls) from call_chicken; select * from call_chicken where calls in ( -- 다중 행 서브쿼리 select max(calls) from call_chicken union select min(calls) from call_chicken ); -- 3. 통화요일별 통화건수의 평균 -- 4. 연령대별 통화건수의 평균 -- 5. 통화요일별, 연령대별 통화건수의 평균 -- 6. 구별, 성별 통화건수의 평균 -- 7. 요일별, 구별, 연령대별 통화건수의 평균 -- 3 ~ 7 문제의 출력은 통화건수 평균의 내림차순 정렬. 소숫점 1자리까지 반올림.
true
f976c2e85bab7d12d27c14714c458172c3c99b84
SQL
mosawo/backup
/ecsite2/sql/ecsite2.sql
UTF-8
902
2.859375
3
[]
no_license
set names utf8; set foreign_key_checks = 0; drop database if exists ecsite2; create database if not exists ecsite2; use ecsite2; drop table if exists login_user_info; /*ユーザー情報テーブル*/ create table login_user_info( id int not null primary key auto_increment,/*ユーザーID*/ login_pass varchar(16),/*パスワード*/ user_name varchar(50),/*ユーザー名*/ insert_date datetime,/*登録日時*/ update_date datetime/*更新日時*/ ); drop table if exists item_info; create table item_info( id int not null primary key auto_increment, item_name varchar(30), item_detail varchar(500), item_price int, item_stock int, item_img varchar(255) ); INSERT INTO item_info(item_name, item_detail, item_price, item_img) VALUES ("頭文字D","頭文字DのCDです!", 2000, "C:\Users\internousdev\Desktop\initiald.jpeg"), ("ひまわりの種","ハムスターの大好物!",300);
true
e37115e44e08f73d974ee481abfe6ebe86883059
SQL
veilin/jpa_jdbc_testing
/db/migrations/V5.1.0___adding_passwords.sql
UTF-8
393
3.546875
4
[]
no_license
-- First add the column ALTER TABLE employees ADD password VARCHAR(255) AFTER email; -- Then set the value to some default for every employee that does not have this set (which should be everyone) UPDATE employees SET password = SHA2('pass123', 256) WHERE password IS NULL; -- Now add the NOT NULL requirement to the data type ALTER TABLE employees MODIFY password VARCHAR (255) NOT NULL;
true
e54afe361eb6421f6068fffb6bc68c0257e70ba1
SQL
cps/DIS_06
/data/sales.sql
UTF-8
321
2.78125
3
[]
no_license
CREATE TABLE sales( saleID SERIAL PRIMARY KEY, day int NOT NULL, month int NOT NULL, year int NOT NULL, quarter int NOT NULL, shopID int REFERENCES shop (shopid), articleID int REFERENCES article (articleid), sold int NOT NULL, revenue double precision ); CREATE EXTENSION tablefunc;
true
90e5a05810db1be0642db008480551bf230e997f
SQL
rodmendoza07/classAdminer
/database/sp_tokenlogin.sql
UTF-8
2,296
3.796875
4
[]
no_license
USE `nemachtilkali`; DROP procedure IF EXISTS `sp_tokenlogin`; DELIMITER $$ USE `nemachtilkali`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_tokenlogin`( in username varchar(50) , in passwordd varchar(50) ) BEGIN declare comparepass1 varchar(50); declare comparepass2 varchar(50); declare activetoken int; declare tokenid int; declare megakey varchar(50); declare userid int; declare tokencompare1 varchar(50); DECLARE `_rollback` BOOL DEFAULT 0; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN SET `_rollback` = 1; ROLLBACK; RESIGNAL; END; set userid = (select ifnull(nmu_id,0) from nm_usuario where nmu_uname = username); set activetoken = (select count(*) from nm_usess where nmus_status = 1 and nmus_userid = userid ); set tokenid = (select nmus_id from nm_usess where nmus_status = 1 and nmus_userid = userid ); set megakey = (select nmconf_value from nm_config where nmconf_id = 1); set comparepass1 = (select md5(concat(username,'__',passwordd,megakey))); set comparepass2 = (select nmu_pass from nm_usuario where nmu_id = userid); set tokencompare1 = (select md5(concat(username,megakey,'-',curdate(),'-',passwordd))); if comparepass1 = comparepass2 then if activetoken = 0 then START TRANSACTION; update nm_usess set nmus_status = 0 where nmus_id = tokenid; insert into nm_usess ( nmus_token , nmus_userid ) values ( tokencompare1 , userid ); IF `_rollback` THEN SIGNAL SQLSTATE '45000' SET message_text = 'Algo ha ido mal, intentalo más tarde.'; ELSE COMMIT; select tokencompare1 as response; end if; else START TRANSACTION; update nm_usess set nmus_status = 0 where nmus_id = tokenid; insert into nm_usess ( nmus_token , nmus_userid ) values ( tokencompare1 , userid ); IF `_rollback` THEN SIGNAL SQLSTATE '45000' SET message_text = 'Algo ha ido mal, intentalo más tarde.'; ELSE COMMIT; select tokencompare1 as response; end if; end if; else SIGNAL SQLSTATE '45000' SET message_text = 'Credenciales inválidas2.'; end if; END$$ DELIMITER ;
true
06288002636a491238e543389f37e2082c4c2277
SQL
CelsoLJunior/dba_scripts
/big_obj_owner.sql
UTF-8
315
3.09375
3
[]
no_license
col owner for a15 col segment_name for a50 select * from (select owner, segment_name, SEGMENT_TYPE, ROUND(sum(bytes)/1024/1024/1024,2) TAM_GB from dba_segments where owner = upper('&OWNER') GROUP BY owner, SEGMENT_TYPE, SEGMENT_NAME having sum(bytes)/1024/1024/1024 > 1 ORDER BY 3 desc) where ROWNUM <= 10;
true
5cacaec486b5d24a95d9f47a02036203acd45a61
SQL
KaisNeffati/projet_PLSQL
/Gestion_des_Emprunts/Trigger_dateEmp_anterieur_DateAdh.sql
UTF-8
282
2.71875
3
[]
no_license
CREATE OR REPLACE TRIGGER dateEmp_anterieur BEFORE INSERT OR UPDATE ON EMPRUNT FOR EACH ROW DECLARE vdateAdh date; BEGIN SELECT dateAdh INTO vdateAdh FROM ADHERENT WHERE ADHERENT.noAdh=:new.noAdh; IF(:new.dateEmp<vdateAdh) THEN :new.dateEmp:=vdateAdh; END IF; END dateEmp_anterieur;
true
dd35909106670fae3fe99014319a154127bafd83
SQL
tnt1701/locastic_tasks
/todo.sql
UTF-8
3,679
3.203125
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.7.0 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jan 22, 2018 at 03:40 PM -- Server version: 10.1.25-MariaDB -- PHP Version: 7.1.7 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: `todo` -- -- -------------------------------------------------------- -- -- Table structure for table `items` -- CREATE TABLE `items` ( `id` int(10) NOT NULL, `task_name` varchar(150) COLLATE utf8_unicode_ci NOT NULL, `priority` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', `deadline` date NOT NULL, `status` tinyint(4) NOT NULL DEFAULT '0', `list_id` int(10) NOT NULL, `task_date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `items` -- INSERT INTO `items` (`id`, `task_name`, `priority`, `deadline`, `status`, `list_id`, `task_date_created`) VALUES (1, 'Promjena filtera i ulja', 'Normal', '2018-01-30', 0, 1, '2018-01-22 14:37:08'); -- -------------------------------------------------------- -- -- Table structure for table `lists` -- CREATE TABLE `lists` ( `id` int(10) UNSIGNED NOT NULL, `list_name` varchar(150) COLLATE utf8_unicode_ci NOT NULL, `user_id` int(10) NOT NULL, `list_date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `lists` -- INSERT INTO `lists` (`id`, `list_name`, `user_id`, `list_date_created`) VALUES (1, 'Popraviti auto', 1, '2018-01-22 14:36:51'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `id` int(10) UNSIGNED NOT NULL, `email` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `surname` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `date_registered` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `last_login` datetime DEFAULT NULL, `status` int(10) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `email`, `password`, `name`, `surname`, `date_registered`, `last_login`, `status`) VALUES (1, 'tomislavnebojsatokic@yahoo.com', '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92', 'Tomislav Nebojsa', 'Tokic', '2018-01-22 15:34:46', NULL, 0); -- -- Indexes for dumped tables -- -- -- Indexes for table `items` -- ALTER TABLE `items` ADD PRIMARY KEY (`id`); -- -- Indexes for table `lists` -- ALTER TABLE `lists` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `list_name` (`list_name`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `items` -- ALTER TABLE `items` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `lists` -- ALTER TABLE `lists` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` int(10) UNSIGNED 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
6ea4f3acaba95cd1fcbe45da79ff0effac491afb
SQL
fengsiri/PECI-Java-MAR-2015
/Recursos/CD_Libros-master/CD_Desarrollando_Soluciones_Con_Java/BaseDatos/funciones/fn_consulta_saldo.sql
UTF-8
263
2.8125
3
[]
no_license
delimiter // create function fn_consulta_saldo( p_cuenta char(8) ) returns decimal(12,2) begin declare saldo decimal(12,2); select dec_cuensaldo into saldo from cuenta where chr_cuencodigo = p_cuenta; return saldo; end // delimiter ;
true
0f32b430447ddcd3ad47cc9a2bd78d2c115e295d
SQL
radtek/OracleScripts
/SQL/TUNE/usedtemps.sql
UTF-8
550
3.734375
4
[]
no_license
select /*+ ORDERED*/ s.sid,s.username,s.osuser,su.tablespace, round(sum(su.blocks*p.value)/1024/1024) "Mb", round(sum(su.blocks/t.blocks)*100,2) "%" from v$parameter p,v$sort_usage su,v$session s, (select tablespace_name,sum(blocks) blocks from dba_data_files group by tablespace_name union select tablespace_name,sum(blocks) blocks from DBA_TEMP_FILES group by tablespace_name) t where s.serial#=su.session_num and su.tablespace=t.tablespace_name and p.name='db_block_size' group by s.sid,s.username,s.osuser,su.tablespace order by "Mb" desc;
true
b5ea89aa05781103a98eb132709e3ae1b8207389
SQL
hrr16-project-crystal/project-crystal
/server/db/sql/couples/getBothUsers.sql
UTF-8
107
2.609375
3
[]
no_license
SELECT * FROM Couples INNER JOIN Users ON Couples.couple_id = Users.couple_id WHERE Couples.couple_id = $1
true
696664bb1c950d341552f60b12243ba0e5d2ff2b
SQL
ClemCornet/P4_UML_OCR
/BDD_express_food.sql
UTF-8
20,485
3.25
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.8.5 -- https://www.phpmyadmin.net/ -- -- Hôte : 127.0.0.1:3307 -- Généré le : mer. 24 juil. 2019 à 16:08 -- Version du serveur : 10.3.14-MariaDB -- Version de PHP : 7.2.18 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 : `express_food` -- -- -------------------------------------------------------- -- -- Structure de la table `administrateur` -- DROP TABLE IF EXISTS `administrateur`; CREATE TABLE IF NOT EXISTS `administrateur` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `nom` varchar(50) NOT NULL, `prenom` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `mot_de_passe` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `administrateur` -- INSERT INTO `administrateur` (`id`, `nom`, `prenom`, `email`, `mot_de_passe`) VALUES (1, 'Arpin', 'Thomas', 'arpin.t@expressfood.com', 'yjM46k6X2Y'), (2, 'Pelland', 'Philippe', 'pelland.p@expressfood.com', '68UvT3Nrq9'), (3, 'Lassaux', 'Colinne', 'lassaux.c@expressfood.com', 'dG678nD3Ea'), (4, 'Langlet', 'Melisande', 'langlet.m@expressfood.com', 'sJ6p496BNx'); -- -------------------------------------------------------- -- -- Structure de la table `adresse_client` -- DROP TABLE IF EXISTS `adresse_client`; CREATE TABLE IF NOT EXISTS `adresse_client` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `rue` varchar(150) NOT NULL, `code_postal` int(5) DEFAULT NULL, `ville` varchar(45) NOT NULL, `pos_latitude` float DEFAULT NULL, `pos_longitude` float DEFAULT NULL, `client_id` smallint(5) UNSIGNED DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_user_id` (`client_id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `adresse_client` -- INSERT INTO `adresse_client` (`id`, `rue`, `code_postal`, `ville`, `pos_latitude`, `pos_longitude`, `client_id`) VALUES (1, '15 rue de l\'église', 75005, 'Paris', 1.12585, -54.1259, 3), (2, '3 avenue Kleber', 75012, 'Paris', 22.5466, 33.1249, 4), (3, '35 avenue des champs elysées', 75020, 'Paris', 44.1259, 44.125, 7), (4, '37 rue de turbigo', 75008, 'Paris', -11.1585, -56.1586, 3), (5, '28 place de la Nation', 75001, 'Paris', 45.1254, 12.1259, 9), (6, '14 place des vosges', 75004, 'Paris', 57.5647, 45.2457, 4), (7, '23 rue de montmartre', 75010, 'Paris', 57.5647, 45.2457, 7), (8, '45 rue marboeuf', 75020, 'Paris', 57.5647, 45.2457, 1), (9, '10 place du tertre', 75012, 'Paris', 57.5647, 45.2457, 7), (10, '144 avenue de la république', 75017, 'Paris', 57.5647, 45.2457, 1), (11, '22 rue de saint denis', 75018, 'Paris', 57.5647, 45.2457, 9), (12, '364 avenue du faubourg du temple', 75010, 'Paris', 57.5647, 45.2457, 4), (13, '30 Rue du Faubourg Saint-Denis', 75010, 'Paris', 48.8606, 2.3521, 2), (14, '146 Avenue du Maine', 75014, 'Paris', 48.8607, 2.41024, 2), (15, '32 Boulevard de Bonne Nouvelle', 75010, 'Paris', 48.8607, 2.4011, 5), (16, '28 Rue Cler', 75007, 'Paris', 48.8602, 2.35278, 6), (17, '343 Rue Lecourbe', 75015, 'Paris', 48.8602, 2.78978, 6), (18, '166 Avenue de Suffren', 75015, 'Paris', 48.8608, 2.5001, 8); -- -------------------------------------------------------- -- -- Structure de la table `carte_credit` -- DROP TABLE IF EXISTS `carte_credit`; CREATE TABLE IF NOT EXISTS `carte_credit` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `nom` varchar(50) NOT NULL, `numero` bigint(20) NOT NULL, `cvv` smallint(3) NOT NULL, `date_expiration` varchar(50) DEFAULT NULL, `reseau` varchar(50) NOT NULL, `user` smallint(5) UNSIGNED NOT NULL, PRIMARY KEY (`id`), KEY `fk_user_id_cards` (`user`) ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `carte_credit` -- INSERT INTO `carte_credit` (`id`, `nom`, `numero`, `cvv`, `date_expiration`, `reseau`, `user`) VALUES (1, 'cornet', 4976912629610914, 761, '10/2019', 'Visa', 1), (2, 'cornet', 4811029922339890, 169, '01/2020', 'Mastercard', 2), (3, 'dupond', 4539093679976875, 487, '05/2021', 'Visa', 3), (4, 'foucault', 4058803001118710, 102, '08/2022', 'Visa', 4), (5, 'hanouna', 4110355613046777, 805, '12/2023', 'Mastercard', 5), (6, 'dumerc', 4730694241426070, 701, '03/2019', 'Visa', 6), (7, 'achouline', 4407357264043832, 658, '11/2021', 'American Express', 7), (8, 'leblanc', 4778893252930359, 456, '04/2020', 'Visa', 8), (9, 'cornet', 4976912629610914, 789, '04/2019', 'Visa', 1), (10, 'leblanc', 4317828277151019, 123, '09/2025', 'Visa', 8), (11, 'dumerc', 4852454057698193, 159, '11/2019', 'Mastercard', 6), (12, 'dupond', 4693093212912694, 753, '07/2022', 'Visa', 3), (13, 'andrieu', 4563246323181842, 654, '06/2022', 'Mastercard', 9), (14, 'foucault', 4057902257760604, 987, '12/2024', 'Mastercard', 4), (15, 'achouline', 4193868727175969, 321, '02/2020', 'American Express', 7); -- -------------------------------------------------------- -- -- Structure de la table `categorie` -- DROP TABLE IF EXISTS `categorie`; CREATE TABLE IF NOT EXISTS `categorie` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `nom_categorie` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT; -- -- Déchargement des données de la table `categorie` -- INSERT INTO `categorie` (`id`, `nom_categorie`) VALUES (1, 'plat principal'), (2, 'dessert'); -- -------------------------------------------------------- -- -- Structure de la table `client` -- DROP TABLE IF EXISTS `client`; CREATE TABLE IF NOT EXISTS `client` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `nom` varchar(50) NOT NULL, `prenom` varchar(50) DEFAULT NULL, `email` varchar(100) NOT NULL, `telephone` varchar(10) DEFAULT NULL, `date_inscription` date NOT NULL, `mot_de_passe` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `client` -- INSERT INTO `client` (`id`, `nom`, `prenom`, `email`, `telephone`, `date_inscription`, `mot_de_passe`) VALUES (1, 'cornet', 'clement', 'cornet.clement@gmail.com', '0626824812', '2019-02-20', '6eAQ56Euk5'), (2, 'cornet', 'adrien', 'cornet.adrien@gmail.com', '0624844747', '2019-06-02', '7Q6CZ26jnj'), (3, 'dupond', 'françois', 'dupond.françois@gmail.com', '0726224882', '2019-04-22', '882pYuMSj2'), (4, 'foucault', 'caroline', 'foucault.caroline@gmail.com', '0126474883', '2019-02-18', 'W5n67vcHF9'), (5, 'hanouna', 'farid', 'hanouna.farid@gmail.com', '0610834801', '2019-01-12', '8m9b7Z7xWA'), (6, 'dumerc', 'celine', 'dumerc.celine@gmail.com', '0144281678', '2019-05-05', '8Ff6MQ9xq4'), (7, 'achouline', 'anissa', 'achouline.anissa@gmail.com', '0624789698', '2019-03-20', '5Hi2M4Eep9'), (8, 'leblanc', 'edouard', 'leblanc.edouard@gmail.com', '0702252789', '2019-04-11', '6BRG69rse8'), (9, 'andrieu', 'jennyfer', 'andrieu.jennyfer@gmail.com', '0658595412', '2019-02-28', 'q564Z2AYkp'); -- -------------------------------------------------------- -- -- Structure de la table `commande` -- DROP TABLE IF EXISTS `commande`; CREATE TABLE IF NOT EXISTS `commande` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `reference` varchar(50) NOT NULL, `nombre_plats` smallint(6) DEFAULT NULL, `prix_total` float DEFAULT NULL, `statut_paiement` tinyint(1) DEFAULT NULL, `client_id` smallint(5) UNSIGNED NOT NULL, `adresse_livraison` smallint(5) UNSIGNED NOT NULL, PRIMARY KEY (`id`), KEY `fk_user` (`client_id`), KEY `fk_adresse_client_id` (`adresse_livraison`) ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `commande` -- INSERT INTO `commande` (`id`, `reference`, `nombre_plats`, `prix_total`, `statut_paiement`, `client_id`, `adresse_livraison`) VALUES (1, 'przv8x011a', 3, 29.5, 1, 2, 13), (2, '7stefp11ah', 3, 14.5, 1, 2, 13), (3, 'ojfjwvjvt4', 1, 13.5, 1, 5, 15), (4, 'jaf1p7ti6', 5, 9.5, 1, 3, 4), (5, '9fmut13endq', 1, 40.5, 0, 3, 4), (6, '79rjr51sysp', 2, 12, 1, 4, 6), (7, 'mv4bpy4vcag', 4, 17.5, 1, 4, 12), (8, 'l6hwi662ldh', 1, 28, 1, 6, 16), (9, 'lj57ai0m3xn', 6, 3.5, 1, 6, 16), (10, 'rmrg7hkchmi', 3, 29.5, 0, 9, 5); -- -------------------------------------------------------- -- -- Structure de la table `commande_plats` -- DROP TABLE IF EXISTS `commande_plats`; CREATE TABLE IF NOT EXISTS `commande_plats` ( `commande` smallint(5) UNSIGNED NOT NULL, `plat_du_jour` smallint(5) UNSIGNED NOT NULL, KEY `fk_commande_id` (`commande`), KEY `fk_plat_jour_id` (`plat_du_jour`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `commande_plats` -- INSERT INTO `commande_plats` (`commande`, `plat_du_jour`) VALUES (1, 2), (1, 2), (1, 3), (2, 2), (2, 1), (2, 4), (3, 2), (4, 4), (4, 4), (4, 4), (4, 4), (4, 4), (5, 1), (6, 1), (6, 3), (7, 1), (7, 2), (7, 3), (7, 4), (8, 3), (9, 2), (9, 2), (9, 2), (9, 2), (9, 2), (9, 2), (10, 1), (10, 4), (10, 4); -- -------------------------------------------------------- -- -- Structure de la table `etat_commande` -- DROP TABLE IF EXISTS `etat_commande`; CREATE TABLE IF NOT EXISTS `etat_commande` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `etat` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `etat_commande` -- INSERT INTO `etat_commande` (`id`, `etat`) VALUES (1, 'en attente'), (2, 'en cours'), (3, 'livrée'), (4, 'annulée'); -- -------------------------------------------------------- -- -- Structure de la table `livreur` -- DROP TABLE IF EXISTS `livreur`; CREATE TABLE IF NOT EXISTS `livreur` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `nom` varchar(50) NOT NULL, `prenom` varchar(50) NOT NULL, `mot_de_passe` varchar(50) NOT NULL, `telephone` varchar(10) NOT NULL, `pos_latitude` float DEFAULT NULL, `pos_longitude` float DEFAULT NULL, `statut` smallint(5) UNSIGNED NOT NULL, `nb_commandes_livrees` tinyint(4) DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_statut_livreur_id` (`statut`) ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `livreur` -- INSERT INTO `livreur` (`id`, `nom`, `prenom`, `mot_de_passe`, `telephone`, `pos_latitude`, `pos_longitude`, `statut`, `nb_commandes_livrees`) VALUES (1, 'Chartier', 'Fred', 'sJ6p496BNx', '0625789610', 48.8595, 2.35736, 1, 0), (2, 'Rossignol', 'Clément', '7Zbe89P8hK', '0645790622', 49.8595, 5.35564, 1, 0), (3, 'Forlini', 'Philippe', 'h2Z2b4r6SC', '0618789647', 47.8595, 4.35456, 3, 3), (4, 'Fortier', 'Laurent', '6K5B49gmjN', '0625809683', 47.8585, 2.35786, 3, 10), (5, 'Endren', 'Kevin', 'wS54w74zBQ', '0725819602', 54.8599, 3.35745, 2, 5), (6, 'Randall', 'Pedro', 'e9Q57mVd6K', '0625722601', 41.8592, 3.45836, 2, 7), (7, 'Miller', 'Chris', '68UvT3Nrq9', '0725289644', 44.9995, 1.35459, 3, 1); -- -------------------------------------------------------- -- -- Structure de la table `plat_du_jour` -- DROP TABLE IF EXISTS `plat_du_jour`; CREATE TABLE IF NOT EXISTS `plat_du_jour` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `date_ajout` date DEFAULT NULL, `numero_plat` varchar(50) NOT NULL, `produit` smallint(5) UNSIGNED DEFAULT NULL, `quantite` smallint(6) DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_produit_id` (`produit`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `plat_du_jour` -- INSERT INTO `plat_du_jour` (`id`, `date_ajout`, `numero_plat`, `produit`, `quantite`) VALUES (1, '2019-07-01', 'plat n1', 3, 250), (2, '2019-07-01', 'plat n2', 5, 180), (3, '2019-07-01', 'plat n3', 7, 200), (4, '2019-07-01', 'plat n4', 9, 220); -- -------------------------------------------------------- -- -- Structure de la table `produit` -- DROP TABLE IF EXISTS `produit`; CREATE TABLE IF NOT EXISTS `produit` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `nom` varchar(100) NOT NULL, `description` text DEFAULT NULL, `ingredients` text DEFAULT NULL, `image` text DEFAULT NULL, `prix` float DEFAULT NULL, `date_ajout` date DEFAULT NULL, `categorie` smallint(5) UNSIGNED DEFAULT NULL, `ajoute_par` smallint(5) UNSIGNED NOT NULL, PRIMARY KEY (`id`), KEY `fk_categorie_id` (`categorie`), KEY `fk_admin_id` (`ajoute_par`) ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `produit` -- INSERT INTO `produit` (`id`, `nom`, `description`, `ingredients`, `image`, `prix`, `date_ajout`, `categorie`, `ajoute_par`) VALUES (1, 'Boeuf bourguignon', 'Le bœuf bourguignon est une recette de cuisine d\'estouffade de bœuf, traditionnelle de la cuisine bourguignonne, cuisinée au vin rouge de Bourgogne, avec une garniture de champignons, de petits oignons et de lardons.', 'Boeuf français, champignons, oignons, vin rouge AOP', 'img/boeuf-bourguignon.jpg', 15.5, '2019-06-15', 1, 1), (2, 'Tarte aux pommes', 'La tarte aux pommes est un type de tarte sucrée, faite d\'une pâte feuilletée ou brisée garnie de pommes émincées. Cette tarte peut être consommée chaude, tiède ou froide.', 'pâte feuilletée, pommes du limousin, beurre AOP, sucre vanillé', 'img/tarte_pommes.jpg', 3.5, '2019-12-12', 2, 1), (3, 'Blanquette de veau', 'La blanquette ou blanquette de veau ou blanquette de veau à l\'ancienne est une recette de cuisine traditionnelle de la cuisine française, à base de ragoût de viande de veau marinée', 'Veau AOP, oeufs, lait, champignons, carottes, riz', 'img/blanquette_veau.jpg', 10.5, '2018-11-24', 1, 4), (4, 'Fondant au chocolat', 'Fondant au chocolat ou moelleux tout choco, le succès de ce petit gâteau au coeur fondant ou coulant est incroyable.', 'chocolat superieur, beurre AOP, oeufs, sucre, vanille', 'img/fondant_chocolat.jpg', 3.5, '2018-09-26', 2, 4), (5, 'Tajines aux legumes', 'Un mélange de légumes aux saveurs orientales qui vous met les papilles en folie.', 'Aubergines, carottes, navets, patates douces, epices', 'img/tajine_legumes.jpg', 8.5, '2018-07-14', 1, 2), (6, 'Poulet basquaise', 'Le poulet basquaise ou poulet à la basquaise est une spécialité culinaire de cuisine traditionnelle emblématique de la cuisine basque.', 'Poulet fermier AOP, pommes de terre, piperade, piment d\'espelette, epices', 'img/poulet_basquaise.jpg', 12.5, '2018-06-23', 1, 3), (7, 'Tarte au citron meringuée', 'La tarte au citron est une tarte sucrée garnie de crème à base de citron. Elle ne comprend aucun fruit. La crème est un mélange d\'œufs, de sucre, de jus de citron et de zeste de citron.', 'pâte brisée, citrons de menton, beurre AOP, meringue', 'img/tarte_citron.jpg', 4.5, '2019-01-12', 2, 3), (8, 'Curry d\'agneau à l’indienne', 'Viande d\'agneau cuite à base température et son mélange d\'epices, voyage en Inde assuré !', 'Viande d\'agneau, riz, epices', 'img/curry_agneau.jpg', 13.5, '2019-02-18', 1, 4), (9, 'Cheese cake', 'Dessert sucré composé d\'un mélange de fromage à la crème, d\'œufs, de sucre et de parfums de vanille et de citron, sur une croûte de miettes de biscuits.', 'fromage blanc, beurre AOP, sucre, oeufs, biscuit', 'img/cheese_cake.jpg', 3.5, '2018-11-23', 2, 1), (10, 'Gratin dauphinois', 'Le gratin dauphinois, ou pommes de terre à la dauphinoise, est un mets français d\'origine dauphinoise, à base de pommes de terre et de lait.', 'pommes de terre, lait, emmental, muscade', 'img/gratin_dauphinois.jpg', 8.5, '2019-05-22', 1, 1); -- -------------------------------------------------------- -- -- Structure de la table `statut_commande` -- DROP TABLE IF EXISTS `statut_commande`; CREATE TABLE IF NOT EXISTS `statut_commande` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `temps_livraison` time DEFAULT NULL, `commande_id` smallint(5) UNSIGNED NOT NULL, `livreur_id` smallint(5) UNSIGNED DEFAULT NULL, `etat` smallint(5) UNSIGNED NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `commande` (`commande_id`), KEY `fk_livreur` (`livreur_id`), KEY `fk_etat_commande` (`etat`) ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `statut_commande` -- INSERT INTO `statut_commande` (`id`, `temps_livraison`, `commande_id`, `livreur_id`, `etat`) VALUES (1, '15:00:00', 3, 4, 2), (2, '00:00:00', 5, NULL, 1), (3, '00:00:00', 7, 4, 3), (4, '08:00:00', 6, 4, 2), (5, '00:00:00', 10, NULL, 4), (6, '05:30:00', 1, 7, 2), (7, '00:00:00', 2, NULL, 1), (8, '00:00:00', 4, NULL, 4), (9, '00:00:00', 8, 5, 3), (10, '07:30:00', 9, 3, 2); -- -------------------------------------------------------- -- -- Structure de la table `statut_livreur` -- DROP TABLE IF EXISTS `statut_livreur`; CREATE TABLE IF NOT EXISTS `statut_livreur` ( `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, `statut` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `statut_livreur` -- INSERT INTO `statut_livreur` (`id`, `statut`) VALUES (1, 'offline'), (2, 'en attente'), (3, 'en livraison'); -- -------------------------------------------------------- -- -- Structure de la table `stock_livreur` -- DROP TABLE IF EXISTS `stock_livreur`; CREATE TABLE IF NOT EXISTS `stock_livreur` ( `livreur_id` smallint(5) UNSIGNED NOT NULL, `plat_id` smallint(5) UNSIGNED NOT NULL, `quantite` smallint(6) DEFAULT NULL, KEY `fk_livreur_id` (`livreur_id`), KEY `fk_plat_id` (`plat_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `stock_livreur` -- INSERT INTO `stock_livreur` (`livreur_id`, `plat_id`, `quantite`) VALUES (1, 1, 3), (1, 2, 10), (1, 3, 10), (1, 4, 10), (2, 1, 10), (2, 2, 10), (2, 3, 10), (2, 4, 10), (3, 1, 10), (3, 2, 10), (3, 3, 10), (3, 4, 10), (4, 1, 10), (4, 2, 10), (4, 3, 10), (4, 4, 10), (5, 1, 10), (5, 2, 10), (5, 3, 10), (5, 4, 10), (6, 1, 10), (6, 2, 10), (6, 3, 10), (6, 4, 10), (7, 1, 10), (7, 2, 10), (7, 3, 10), (7, 4, 10); -- -- Contraintes pour les tables déchargées -- -- -- Contraintes pour la table `adresse_client` -- ALTER TABLE `adresse_client` ADD CONSTRAINT `fk_user_id` FOREIGN KEY (`client_id`) REFERENCES `client` (`id`); -- -- Contraintes pour la table `carte_credit` -- ALTER TABLE `carte_credit` ADD CONSTRAINT `fk_test` FOREIGN KEY (`user`) REFERENCES `client` (`id`), ADD CONSTRAINT `fk_user_id_cards` FOREIGN KEY (`user`) REFERENCES `client` (`id`); -- -- Contraintes pour la table `commande` -- ALTER TABLE `commande` ADD CONSTRAINT `fk_adresse_client_id` FOREIGN KEY (`adresse_livraison`) REFERENCES `adresse_client` (`id`), ADD CONSTRAINT `fk_user` FOREIGN KEY (`client_id`) REFERENCES `client` (`id`); -- -- Contraintes pour la table `commande_plats` -- ALTER TABLE `commande_plats` ADD CONSTRAINT `fk_commande_id` FOREIGN KEY (`commande`) REFERENCES `commande` (`id`), ADD CONSTRAINT `fk_plat_jour_id` FOREIGN KEY (`plat_du_jour`) REFERENCES `plat_du_jour` (`id`); -- -- Contraintes pour la table `livreur` -- ALTER TABLE `livreur` ADD CONSTRAINT `fk_statut_livreur_id` FOREIGN KEY (`statut`) REFERENCES `statut_livreur` (`id`); -- -- Contraintes pour la table `plat_du_jour` -- ALTER TABLE `plat_du_jour` ADD CONSTRAINT `fk_produit_id` FOREIGN KEY (`produit`) REFERENCES `produit` (`id`); -- -- Contraintes pour la table `produit` -- ALTER TABLE `produit` ADD CONSTRAINT `fk_admin_id` FOREIGN KEY (`ajoute_par`) REFERENCES `administrateur` (`id`), ADD CONSTRAINT `fk_categorie_id` FOREIGN KEY (`categorie`) REFERENCES `categorie` (`id`); -- -- Contraintes pour la table `statut_commande` -- ALTER TABLE `statut_commande` ADD CONSTRAINT `fk_commande` FOREIGN KEY (`commande_id`) REFERENCES `commande` (`id`), ADD CONSTRAINT `fk_etat_commande` FOREIGN KEY (`etat`) REFERENCES `etat_commande` (`id`), ADD CONSTRAINT `fk_livreur` FOREIGN KEY (`livreur_id`) REFERENCES `livreur` (`id`); -- -- Contraintes pour la table `stock_livreur` -- ALTER TABLE `stock_livreur` ADD CONSTRAINT `fk_livreur_id` FOREIGN KEY (`livreur_id`) REFERENCES `livreur` (`id`), ADD CONSTRAINT `fk_plat_id` FOREIGN KEY (`plat_id`) REFERENCES `plat_du_jour` (`id`); 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
a7cdeff47738176bded8b4fb34d3725905e2d31d
SQL
daiyunhang/Java
/myjava2/数据库/jdbc.sql
UTF-8
3,863
3.65625
4
[]
no_license
mysql -uroot -p Aa123456 create database jt_db default character set utf8; show databases; use jt_db; -- 1.1 创建account表 id自增 create table account( id int primary key auto_increment, name varchar(50), money double ); show tables; -- 1.2 往account表中插入两条数据 insert into account values(null,'wanght',100); select * from account; insert into account values(null,'xiongda',1000); select * from account; -- 1.3 在jt_db表中创建User表,有id,username,password字段 create table user( id int primary key auto_increment, username varchar(50), password varchar(50) ); show tables; -- 1.4 user表插入两条数据 insert into user values(null,'guangtouqiang','123'); select * from user; insert into user values(null,'chenzs','123'); select * from user; -- 1.5 创建dept 表,有id,name字段 create table dept( id int primary key auto_increment, name varchar(50) ); show tables; -- 1.6 在dept 插入两条记录 insert into dept values(null,'dept1'); insert into dept values(null,'dept2'); select * from dept; -- 2,3.1 JDBC原理,JDBC概述 java database connectivity, java数据库连接. 专用用来通过一段java代码操作数据库的一门技术 -- 3.2 如何使用jdbc -- 3.2.1 需求 通过jdbc技术,查询account表中的所有数据 -- 3.2.2 开发步骤 创建dd_web_01的动态web工程,创建HelloJDBC类,创建hello方法 ------------------------------------------------------------------------------- -- 4.1 注册驱动 -------------------优化---------------------- DriverManager.registerDriver(new Driver()); 缺点: 1.驱动名和程序产生了紧耦合的关系 2.使得驱动被注册了两次 解决方案: Class.forName("com.mysql.jdbc.Driver"); -- 4.2 获取数据库连接 jdbc:mysql://localhost:3306/jt_db ---------- --------- ---- --- 协议名 域名 端口号 数据库名字 -- 简写: jdbc:mysql:///jt_db --前提:必须访问本地数据库服务器 localhost+必须使用默认端口号3306 -- 4.3 数据库连接对象 Connection -- 4.3.1 作用: 通过三个数据库的链接参数,链接到数据库进行数据库的管理 -- 4.3.2 常用方法 createStatement() ------ 获取传输器对象 prepareStatement() ----- 获取带有预编译效果的传输器对象 -- 4.4 传输器对象 Statement -- 4.4.1 作用 用来执行SQL -- 4.4.2 常用方法 executeQuery() ------ 执行查询的SQL execteUpdate() ------ 执行增删改的SQL -- 4.5 结果集对象 ResultSet -- 4.5.1 作用 用来封装SQL执行完的数据 -- 4.5.2 常用方法 Next() ------ 查询结果集中是否有数据,指针的效果 getString(String column) ------ 根据指定列名获取数据 getString(int index) ----------根据列的索引获取数据 -- 4.6 关闭资源 -- 4.6.1 在jdbc中,资源是十分稀缺的,需要我们每次使用完之后必须释放资源. 当我们在释放资源时,有可能会发生异常,为了保证资源释放一定会被执行 需要把释放资源的代码放入finally代码块中 -- 4.6.2 现状 //6.释放资源,正着开,倒着关 rs.close(); st.close(); conn.close(); -- 4.6.3 改造 -- 5 JDBC增删改查 -- 5.1 新增 向user表中插入一条记录 -- 5.2 修改 修改account表中id为1的记录,money为200 -- 5.3 删除 删除user表里id为4的记录 -- 6 JDBC 在jdbc的开发中,存在大量重复的代码,讲这些重复的代码提取出来, 封装起来,提高代码的复用性,简化开发. -- 私有化构造函数 提供静态方法 getConnection 用来对外提供数据库连接对象 提供静态方法 close 用来释放资源
true
450e238d8548f5bacb7476be51e8e8cba1bd3864
SQL
Cliente-Servido/socom
/src/main/webapp/sql/consultitas.sql
UTF-8
20,071
2.890625
3
[]
no_license
CREATE DATABASE IF NOT EXISTS `socom` /*!40100 DEFAULT CHARACTER SET utf8 */; USE `socom`; -- MySQL dump 10.13 Distrib 5.6.23, for Win32 (x86) -- -- Host: localhost Database: socom -- ------------------------------------------------------ -- Server version 5.7.7-rc-log /*!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 `camiones` -- DROP TABLE IF EXISTS `camiones`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `camiones` ( `idCamion` int(11) NOT NULL AUTO_INCREMENT, `marca` varchar(12) DEFAULT NULL, `modelo` varchar(60) DEFAULT NULL, `dominio` char(6) DEFAULT NULL, `anio` int(11) DEFAULT NULL, `descripcion` varchar(60) DEFAULT NULL, `idRuta` int(11) DEFAULT NULL, PRIMARY KEY (`idCamion`), KEY `idRuta` (`idRuta`), CONSTRAINT `camiones_ibfk_1` FOREIGN KEY (`idRuta`) REFERENCES `rutas` (`idRuta`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `camiones` -- LOCK TABLES `camiones` WRITE; /*!40000 ALTER TABLE `camiones` DISABLE KEYS */; /*!40000 ALTER TABLE `camiones` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `clientes` -- DROP TABLE IF EXISTS `clientes`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientes` ( `idCliente` int(11) NOT NULL AUTO_INCREMENT, `apellido` char(20) NOT NULL, `nombre` char(30) NOT NULL, `direccion` varchar(50) NOT NULL, `telefono` varchar(20) DEFAULT NULL, `email` varchar(30) DEFAULT NULL, PRIMARY KEY (`idCliente`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `clientes` -- LOCK TABLES `clientes` WRITE; /*!40000 ALTER TABLE `clientes` DISABLE KEYS */; INSERT INTO `clientes` VALUES (1,'Simpson','Homero','Av. Siempre viva 78','3434-4342343','homero.simpson@es.si'),(2,'Perez','Roberto','Hernandarias 54','3434-4833943','perez.sgffgfson@es.si'),(3,'Ayala','aida','Av Italia 900','3434-45442343','aida.gofdfa@es.si'),(5,'Balbuena','Igor','San Martin s/n','343434-44334343','IGOR.fdfddfdon@es.si'); /*!40000 ALTER TABLE `clientes` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `empleados` -- DROP TABLE IF EXISTS `empleados`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `empleados` ( `idEmpleado` int(11) NOT NULL AUTO_INCREMENT, `apellido` char(20) NOT NULL, `nombre` char(30) NOT NULL, `legajo` int(11) DEFAULT NULL, `cargo` char(15) DEFAULT NULL, `area` char(15) DEFAULT NULL, `idSucursal` int(11) NOT NULL, `fechaAlta` date DEFAULT NULL, PRIMARY KEY (`idEmpleado`), KEY `idSucursal` (`idSucursal`), CONSTRAINT `empleados_ibfk_1` FOREIGN KEY (`idSucursal`) REFERENCES `sucursales` (`idSucursal`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `empleados` -- LOCK TABLES `empleados` WRITE; /*!40000 ALTER TABLE `empleados` DISABLE KEYS */; INSERT INTO `empleados` VALUES (1,'carca','Juan',18000,'capo','Ventas',1,'2000-02-02'),(3,'luigui','sssss',33534325,NULL,'prostituto',1,NULL); /*!40000 ALTER TABLE `empleados` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `estados` -- DROP TABLE IF EXISTS `estados`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `estados` ( `idEstado` int(11) NOT NULL AUTO_INCREMENT, `idPaquete` int(11) NOT NULL, `descripcion` char(15) NOT NULL, `idEmpleado` int(11) DEFAULT NULL, `fecha` date DEFAULT NULL, `idSucursal` int(11) DEFAULT NULL, PRIMARY KEY (`idEstado`), KEY `idPaquete` (`idPaquete`), KEY `idEmpleado` (`idEmpleado`), KEY `idSucursal` (`idSucursal`), CONSTRAINT `estados_ibfk_1` FOREIGN KEY (`idPaquete`) REFERENCES `paquetes` (`idPaquete`), CONSTRAINT `estados_ibfk_2` FOREIGN KEY (`idEmpleado`) REFERENCES `empleados` (`idEmpleado`), CONSTRAINT `estados_ibfk_3` FOREIGN KEY (`idSucursal`) REFERENCES `sucursales` (`idSucursal`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `estados` -- LOCK TABLES `estados` WRITE; /*!40000 ALTER TABLE `estados` DISABLE KEYS */; INSERT INTO `estados` VALUES (1,1,'En proceso',1,'2015-04-01',1),(2,1,'En tránsito',1,'2015-04-02',1); /*!40000 ALTER TABLE `estados` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `facturas` -- DROP TABLE IF EXISTS `facturas`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `facturas` ( `idFactura` int(11) NOT NULL AUTO_INCREMENT, `fecha` date DEFAULT NULL, `monto` float DEFAULT NULL, `idCliente` int(11) DEFAULT NULL, `idEmpleado` int(11) DEFAULT NULL, PRIMARY KEY (`idFactura`), KEY `idCliente` (`idCliente`), KEY `idEmpleado` (`idEmpleado`), CONSTRAINT `facturas_ibfk_1` FOREIGN KEY (`idCliente`) REFERENCES `clientes` (`idCliente`), CONSTRAINT `facturas_ibfk_2` FOREIGN KEY (`idEmpleado`) REFERENCES `empleados` (`idEmpleado`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `facturas` -- LOCK TABLES `facturas` WRITE; /*!40000 ALTER TABLE `facturas` DISABLE KEYS */; INSERT INTO `facturas` VALUES (1,'2015-04-01',100,5,1); /*!40000 ALTER TABLE `facturas` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `gerentes` -- DROP TABLE IF EXISTS `gerentes`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `gerentes` ( `idGerente` int(11) NOT NULL AUTO_INCREMENT, `apellido` char(20) NOT NULL, `nombre` char(30) NOT NULL, `legajo` int(11) DEFAULT NULL, `idSucursal` int(11) NOT NULL, PRIMARY KEY (`idGerente`), KEY `idSucursal` (`idSucursal`), CONSTRAINT `gerentes_ibfk_1` FOREIGN KEY (`idSucursal`) REFERENCES `sucursales` (`idSucursal`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `gerentes` -- LOCK TABLES `gerentes` WRITE; /*!40000 ALTER TABLE `gerentes` DISABLE KEYS */; INSERT INTO `gerentes` VALUES (1,'argento','pipo',1234,1); /*!40000 ALTER TABLE `gerentes` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `localidades` -- DROP TABLE IF EXISTS `localidades`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `localidades` ( `idLocalidad` int(11) NOT NULL AUTO_INCREMENT, `idProvincia` int(11) NOT NULL, `nombre` char(25) NOT NULL, PRIMARY KEY (`idLocalidad`), KEY `idProvincia` (`idProvincia`), CONSTRAINT `localidades_ibfk_1` FOREIGN KEY (`idProvincia`) REFERENCES `provincias` (`idProvincia`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `localidades` -- LOCK TABLES `localidades` WRITE; /*!40000 ALTER TABLE `localidades` DISABLE KEYS */; INSERT INTO `localidades` VALUES (1,1,'Corrientes'),(2,2,'Resistencia'),(4,3,'Rosario'),(5,3,'Ocampo'); /*!40000 ALTER TABLE `localidades` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `paises` -- DROP TABLE IF EXISTS `paises`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `paises` ( `idPais` int(11) NOT NULL AUTO_INCREMENT, `nombre` char(15) NOT NULL, PRIMARY KEY (`idPais`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `paises` -- LOCK TABLES `paises` WRITE; /*!40000 ALTER TABLE `paises` DISABLE KEYS */; INSERT INTO `paises` VALUES (1,'argentina'),(2,'paraguay'); /*!40000 ALTER TABLE `paises` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `paquetes` -- DROP TABLE IF EXISTS `paquetes`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `paquetes` ( `idPaquete` int(11) NOT NULL AUTO_INCREMENT, `peso` float DEFAULT NULL, `costoTotal` float DEFAULT NULL, `idFactura` int(11) DEFAULT NULL, `idServicio` int(11) DEFAULT NULL, `origen` int(11) NOT NULL, `destino` int(11) NOT NULL, `destinatarioNombre` varchar(50) NOT NULL, `destinatarioDNI` int(11) NOT NULL, `destinatarioDireccion` char(50) DEFAULT NULL, `destinatarioTelefono` varchar(20) DEFAULT NULL, `destinatarioEmail` varchar(30) DEFAULT NULL, `idCliente` int, PRIMARY KEY (`idPaquete`), KEY `idFactura` (`idFactura`), KEY `idServicio` (`idServicio`), KEY `origen` (`origen`), KEY `destino` (`destino`), KEY `idCliente` (`idCliente`), CONSTRAINT `paquetes_ibfk_5` FOREIGN KEY (`idCliente`) REFERENCES `clientes` (`idCliente`), CONSTRAINT `paquetes_ibfk_1` FOREIGN KEY (`idFactura`) REFERENCES `facturas` (`idFactura`), CONSTRAINT `paquetes_ibfk_2` FOREIGN KEY (`idServicio`) REFERENCES `servicios` (`idServicio`), CONSTRAINT `paquetes_ibfk_3` FOREIGN KEY (`origen`) REFERENCES `sucursales` (`idSucursal`), CONSTRAINT `paquetes_ibfk_4` FOREIGN KEY (`destino`) REFERENCES `sucursales` (`idSucursal`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `paquetes` -- LOCK TABLES `paquetes` WRITE; /*!40000 ALTER TABLE `paquetes` DISABLE KEYS */; INSERT INTO `paquetes` VALUES (1,10,100,1,1,1,8,'PepeArgento',434343,'Villa Mojarra','264-15456452','pepe@se.se',1); /*!40000 ALTER TABLE `paquetes` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `paquetesxviaje` -- DROP TABLE IF EXISTS `paquetesxviaje`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `paquetesxviaje` ( `idViaje` int(11) NOT NULL, `idPaquete` int(11) NOT NULL, PRIMARY KEY (`idViaje`,`idPaquete`), KEY `idPaquete` (`idPaquete`), CONSTRAINT `paquetesxviaje_ibfk_1` FOREIGN KEY (`idViaje`) REFERENCES `viajes` (`idViaje`), CONSTRAINT `paquetesxviaje_ibfk_2` FOREIGN KEY (`idPaquete`) REFERENCES `paquetes` (`idPaquete`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `paquetesxviaje` -- LOCK TABLES `paquetesxviaje` WRITE; /*!40000 ALTER TABLE `paquetesxviaje` DISABLE KEYS */; /*!40000 ALTER TABLE `paquetesxviaje` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `provincias` -- DROP TABLE IF EXISTS `provincias`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `provincias` ( `idProvincia` int(11) NOT NULL AUTO_INCREMENT, `idPais` int(11) NOT NULL, `nombre` char(20) NOT NULL, PRIMARY KEY (`idProvincia`), KEY `idPais` (`idPais`), CONSTRAINT `provincias_ibfk_1` FOREIGN KEY (`idPais`) REFERENCES `paises` (`idPais`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `provincias` -- LOCK TABLES `provincias` WRITE; /*!40000 ALTER TABLE `provincias` DISABLE KEYS */; INSERT INTO `provincias` VALUES (1,1,'corrientes'),(2,1,'Chaco'),(3,1,'Santa Fe'); /*!40000 ALTER TABLE `provincias` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `rutas` -- DROP TABLE IF EXISTS `rutas`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `rutas` ( `idRuta` int(11) NOT NULL AUTO_INCREMENT, `origen` int(11) NOT NULL, `destino` int(11) NOT NULL, `descripcion` varchar(60) DEFAULT NULL, `cantidadSucursales` int(11) DEFAULT NULL, PRIMARY KEY (`idRuta`), KEY `origen` (`origen`), KEY `destino` (`destino`), CONSTRAINT `rutas_ibfk_1` FOREIGN KEY (`origen`) REFERENCES `sucursales` (`idSucursal`), CONSTRAINT `rutas_ibfk_2` FOREIGN KEY (`destino`) REFERENCES `sucursales` (`idSucursal`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `rutas` -- LOCK TABLES `rutas` WRITE; /*!40000 ALTER TABLE `rutas` DISABLE KEYS */; INSERT INTO `rutas` VALUES (1,1,2,'qwqwq',NULL); /*!40000 ALTER TABLE `rutas` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `servicios` -- DROP TABLE IF EXISTS `servicios`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `servicios` ( `idServicio` int(11) NOT NULL AUTO_INCREMENT, `nombre` varchar(30) DEFAULT NULL, `descripcion` varchar(60) DEFAULT NULL, `costokg` float DEFAULT NULL, `costoseguro` float DEFAULT NULL, `montoasegurado` float DEFAULT NULL, PRIMARY KEY (`idServicio`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `servicios` -- LOCK TABLES `servicios` WRITE; /*!40000 ALTER TABLE `servicios` DISABLE KEYS */; INSERT INTO `servicios` VALUES (1,'sevicio basico','este servicio consta de una atencion alalal',5,67,6789),(2,'sevicio hot','este servicio consta de una atencion de la puta madre',100,90,6.7891e15),(3,'premium','recibis el paquete al otro dia',200,50,10000),(4,' megapremium','recibis el paquete a las 2 horas',600,400,100000),(5,'Rapido','super rapido',300,50,25); /*!40000 ALTER TABLE `servicios` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `sucursales` -- DROP TABLE IF EXISTS `sucursales`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sucursales` ( `idSucursal` int(11) NOT NULL AUTO_INCREMENT, `idLocalidad` int(11) NOT NULL, `direccion` varchar(30) DEFAULT NULL, `horario` varchar(30) DEFAULT NULL, `descripcion` varchar(30) DEFAULT NULL, PRIMARY KEY (`idSucursal`), KEY `idLocalidad` (`idLocalidad`), CONSTRAINT `sucursales_ibfk_1` FOREIGN KEY (`idLocalidad`) REFERENCES `localidades` (`idLocalidad`) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `sucursales` -- LOCK TABLES `sucursales` WRITE; /*!40000 ALTER TABLE `sucursales` DISABLE KEYS */; INSERT INTO `sucursales` VALUES (1,1,'Carlos Pellegrini','8 hs a 20hs','Primera Sucursal'),(2,2,'San Martin 32256','comercial',''),(5,5,'Sarmiento 23','comercial',''),(6,1,'2 de abril 23','comercial',''),(8,4,'Alberdi 23','comercial',''); /*!40000 ALTER TABLE `sucursales` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `sucursalesxruta` -- DROP TABLE IF EXISTS `sucursalesxruta`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sucursalesxruta` ( `idSucursalesxRuta` int(11) NOT NULL AUTO_INCREMENT, `idRuta` int(11) NOT NULL, `origen` int(11) NOT NULL, `destino` int(11) NOT NULL, `secuencia` int(11) DEFAULT NULL, PRIMARY KEY (`idSucursalesxRuta`), KEY `origen` (`origen`), KEY `destino` (`destino`), KEY `idRuta` (`idRuta`), CONSTRAINT `sucursalesxruta_ibfk_1` FOREIGN KEY (`origen`) REFERENCES `sucursales` (`idSucursal`), CONSTRAINT `sucursalesxruta_ibfk_2` FOREIGN KEY (`destino`) REFERENCES `sucursales` (`idSucursal`), CONSTRAINT `sucursalesxruta_ibfk_3` FOREIGN KEY (`idRuta`) REFERENCES `rutas` (`idRuta`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `sucursalesxruta` -- LOCK TABLES `sucursalesxruta` WRITE; /*!40000 ALTER TABLE `sucursalesxruta` DISABLE KEYS */; /*!40000 ALTER TABLE `sucursalesxruta` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `usuarios` -- DROP TABLE IF EXISTS `usuarios`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `usuarios` ( `idUsuario` int(11) NOT NULL AUTO_INCREMENT, `usuario` char(20) DEFAULT NULL, `pass` char(20) NOT NULL, `idEmpleado` int(11) DEFAULT NULL, `idGerente` int(11) DEFAULT NULL, `idCliente` int(11) DEFAULT NULL, PRIMARY KEY (`idUsuario`), UNIQUE KEY `usuario` (`usuario`), KEY `idEmpleado` (`idEmpleado`), KEY `idGerente` (`idGerente`), KEY `idCliente` (`idCliente`), CONSTRAINT `usuarios_ibfk_1` FOREIGN KEY (`idEmpleado`) REFERENCES `empleados` (`idEmpleado`), CONSTRAINT `usuarios_ibfk_2` FOREIGN KEY (`idGerente`) REFERENCES `gerentes` (`idGerente`), CONSTRAINT `usuarios_ibfk_3` FOREIGN KEY (`idCliente`) REFERENCES `clientes` (`idCliente`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `usuarios` -- LOCK TABLES `usuarios` WRITE; /*!40000 ALTER TABLE `usuarios` DISABLE KEYS */; INSERT INTO `usuarios` VALUES (1,'pepe','1234',NULL,1,NULL),(2,'sahlawi','123',NULL,NULL,1); /*!40000 ALTER TABLE `usuarios` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `viajes` -- DROP TABLE IF EXISTS `viajes`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `viajes` ( `idViaje` int(11) NOT NULL AUTO_INCREMENT, `origen` int(11) NOT NULL, `destino` int(11) NOT NULL, `idCamion` int(11) NOT NULL, `fechaSalida` date DEFAULT NULL, `fechaLlegada` date DEFAULT NULL, `horaSalida` char(5) DEFAULT NULL, `horaLlegada` char(5) DEFAULT NULL, PRIMARY KEY (`idViaje`), KEY `origen` (`origen`), KEY `destino` (`destino`), KEY `idCamion` (`idCamion`), CONSTRAINT `viajes_ibfk_1` FOREIGN KEY (`origen`) REFERENCES `sucursales` (`idSucursal`), CONSTRAINT `viajes_ibfk_2` FOREIGN KEY (`destino`) REFERENCES `sucursales` (`idSucursal`), CONSTRAINT `viajes_ibfk_3` FOREIGN KEY (`idCamion`) REFERENCES `camiones` (`idCamion`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `viajes` -- LOCK TABLES `viajes` WRITE; /*!40000 ALTER TABLE `viajes` DISABLE KEYS */; /*!40000 ALTER TABLE `viajes` 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 2015-07-09 21:44:27
true
45efcde53fc255db1bc59f5d36be5bc38218df5c
SQL
davido322/CSE572
/SQL COMMANDS/CSE572.bak/LAB07_8.sql
UTF-8
244
3.453125
3
[]
no_license
DESC JOB_GRADES SELECT e.last_name, e.job_id, d.department_name, e.salary, j.grade_level FROM hr.employees e JOIN hr.departments d ON(e.department_id = d.department_id) JOIN hr.job_grades j ON(e.salary BETWEEN j.lowest_sal AND j.highest_sal);
true
97ac5beaa1c70002c49f4dbda90c11e159901eb8
SQL
OpenConext/OpenConext-attribute-aggregation
/aa-server/src/main/resources/db/migration/V4___attribute_skip_consent.sql
UTF-8
453
2.546875
3
[ "Apache-2.0" ]
permissive
-- -- We can at this stage of development -- DELETE FROM aggregations; DELETE FROM aggregations_attributes; DELETE FROM aggregations_service_providers; DELETE FROM attributes; DELETE FROM service_providers; -- -- Because an attribute can be marked as skip_consent we can't re-use attributes over aggregations -- ALTER TABLE attributes DROP INDEX attributes_attribute_authority_id_name; ALTER TABLE attributes ADD skip_consent TINYINT(1) DEFAULT 0;
true
5f08e4ca367d10618180e84169577e1c342d6927
SQL
bylee5/awesome-dba
/PostgreSQL/queries/tables_with_no_pkey.sql
UTF-8
263
3.609375
4
[ "Apache-2.0" ]
permissive
SELECT n.nspname AS schema, c.relname AS table FROM pg_class c JOIN pg_namespace n ON (n.oid = c.relnamespace) WHERE relkind = 'r' AND relname NOT LIKE 'pg_%' AND relname NOT LIKE 'sql_%' AND relhaspkey = FALSE ORDER BY n.nspname, c.relname;
true
6599f42780fd27ada57e1fea256a4e6b2e7565e9
SQL
MrLys/vicissitudes
/groove-api/migrations/groove.sql
UTF-8
343
3.171875
3
[ "MIT", "GPL-1.0-or-later", "Classpath-exception-2.0", "EPL-2.0" ]
permissive
CREATE TABLE IF NOT EXISTS "groove" ( id BIGSERIAL PRIMARY KEY, state VARCHAR(10), user_habit_id INTEGER REFERENCES public.user_habit(id) ON DELETE CASCADE, date TIMESTAMP NOT NULL, owner_id INTEGER REFERENCES public.user(id) ON DELETE CASCADE, CONSTRAINT unq_habit_date_owner UNIQUE (user_habit_id, date, owner_id) );
true
eac077ecd5c181301c235321b29544659a1e3f35
SQL
radtek/abs3
/sql/mmfo/bars/View/not_nls98.sql
UTF-8
3,477
3.234375
3
[]
no_license
PROMPT ===================================================================================== PROMPT *** Run *** ========== Scripts /Sql/BARS/View/NOT_NLS98.sql =========*** Run *** ==== PROMPT ===================================================================================== PROMPT *** Create view NOT_NLS98 *** CREATE OR REPLACE FORCE VIEW BARS.NOT_NLS98 ("BRANCH", "NBSOB22", "NAME", "NLS_CENN", "NLS_DOR", "NLS_POGA", "NLS_DORP") AS SELECT B.branch, v.ob22, v.name, SUBSTR ( nbs_ob22_null('9819',SUBSTR (ob22,5,2), b.branch), 1,14) NLS_CENN, SUBSTR (NVL(nbs_ob22_null('9899',v.ob22_dor, b.branch), DECODE (v.ob22_dor, NULL, '', '9899*' || v.ob22_dor)), 1,14) NLS_DOR, SUBSTR (NVL(nbs_ob22_null('9812',v.ob22_spl, b.branch), DECODE(v.ob22_spl, NULL, '', '9812*' || v.ob22_spl)), 1,14) NLS_POGA, SUBSTR (NVL(nbs_ob22_null('9899',v.ob22_dors, b.branch), DECODE(v.ob22_dors,NULL, '', '9899*' ||v.ob22_dors)), 1,14) NLS_DORP FROM branch b, valuables v WHERE nbs_ob22_null ('9819', SUBSTR (ob22, 5, 2), b.branch) IS NOT NULL AND LENGTH (b.branch) = 15 AND v.ob22 LIKE '9819%' AND ( v.ob22_dor IS NOT NULL AND nbs_ob22_null('9899', v.ob22_dor, b.branch) IS NULL OR v.ob22_spl IS NOT NULL AND nbs_ob22_null('9812', v.ob22_spl, b.branch) IS NULL OR v.ob22_dors IS NOT NULL AND nbs_ob22_null('9899', v.ob22_dors,b.branch) IS NULL ) UNION ALL SELECT B.branch, v.ob22, v.name, substr ( nbs_ob22_null('9820',SUBSTR (ob22,5,2), b.branch), 1,14) NLS_CENN, substr (NVL(nbs_ob22_null('9891', v.ob22_dor, b.branch), DECODE(v.ob22_dor, NULL, '', '9891*' || v.ob22_dor)), 1,14) NLS_DOR, '' NLS_POGA, '' NLS_DORP FROM branch b, valuables v WHERE nbs_ob22_null ('9820', SUBSTR (ob22, 5, 2), b.branch) IS NOT NULL AND LENGTH (b.branch) = 15 AND v.ob22 LIKE '9820%' AND v.ob22_dor IS NOT NULL AND nbs_ob22_null('9891', v.ob22_dor, b.branch) IS NULL UNION ALL SELECT B.branch, v.ob22, v.name, substr ( nbs_ob22_null('9821',SUBSTR (ob22,5,2), b.branch) ,1,14) NLS_CENN, substr (NVL(nbs_ob22_null('9893', v.ob22_dor, b.branch), DECODE(v.ob22_dor, NULL, '', '9893*' || v.ob22_dor)) ,1,14) NLS_DOR, '' NLS_POGA, '' NLS_DORP FROM branch b, valuables v WHERE nbs_ob22_null ('9821', SUBSTR (ob22, 5, 2), b.branch) IS NOT NULL AND LENGTH (b.branch) = 15 AND v.ob22 LIKE '9821%' AND v.ob22_dor IS NOT NULL AND nbs_ob22_null('9893', v.ob22_dor, b.branch) IS NULL; PROMPT *** Create grants NOT_NLS98 *** grant SELECT on NOT_NLS98 to BARSREADER_ROLE; grant SELECT on NOT_NLS98 to BARS_ACCESS_DEFROLE; grant SELECT on NOT_NLS98 to CUST001; grant SELECT on NOT_NLS98 to UPLD; PROMPT ===================================================================================== PROMPT *** End *** ========== Scripts /Sql/BARS/View/NOT_NLS98.sql =========*** End *** ==== PROMPT =====================================================================================
true
c0bbd60e370e52b33068e300bc207aad5ea7332b
SQL
PMikhail/SQL-Reports
/contracts/facts_contract_rate/New 1.sql
UTF-8
2,098
3.765625
4
[]
no_license
CREATE TABLE TEMP_CONT_RATE AS ( select dim_contract_id , dim_service_id , case when srv.eff_dt < dc.effective_date then dc.effective_date else srv.eff_dt end as eff_dt , case when srv.term_dt > dc.termination_date then dc.termination_date else srv.term_dt end as end_dt , case when rate is null then 0 else age_from end as age_from , case when rate is null then 999 else age_to end as age_to , dim_provider_id , dim_agency_id , nvl(auth_req_ind, 'N') dim_yn_id_auth_required , case when rate is null then srv.rate_sp else rate end as daily_rate , case when rate is null then srv.rate_sp else max_maint_rate end as daily_rate_max_maint from dhs_core.dim_contract dc inner join ( select *--nvl(serv_type, '_') s_type -- , nvl(rate_cat, -1) r_category -- , nvl(cost_center, '_') c_center -- , nvl(dep_dlq, '_') dd -- , srv.* from staging.x_cont_srv srv where row_dlt_trnsct_id = 0) srv on srv.mdoc_no = dc.contract_document_id inner join staging.x_cont_srv_rates_p1 rp on rp.parnt_id = srv.id --left join ( select * --vl(serv_type, '_') s_type ---- , nvl(rate_category, -1) r_category ---- , nvl(cost_center, '_') c_center ---- , nvl(dep_dlq, '_') dd ---- , serv_cd -- from dhs_core.dim_service ) ds --on DS.SERV_CD = SRV.SERV_CD --and nvl(SRV.Rate_CAT, -1) = nvl(DS.Rate_CATEGORY, -1) where rp.row_dlt_trnsct_id = 0 ) SELECT * FROM FACT_CONTRACT_RATE1 INSERT INTO DHS_CORE.FACT_CONTRACT_RATE1 ( DIM_CONTRACT_ID , DIM_SERVICE_ID , EFF_DT , END_DT , AGE_FROM , AGE_TO , DIM_PROVIDER_ID , DIM_AGENCY_ID , DIM_YN_ID_AUTH_REQUIRED , DAILY_RATE , DAILY_RATE_MAX_MAINT , LAST_MODIFIED_DT ) SELECT TEMP.*, SYSDATE FROM TEMP_FACT_RATE TEMP SELECT COUNT(DIM_SERVICE_ID) FROM TEMP_FACT_RATE
true
f3d3356a408d8d9f42433caabf380de374539a39
SQL
ardha27/PemWebFP
/online_shop.sql
UTF-8
6,985
3.109375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.0.3 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jan 08, 2021 at 02:15 PM -- Server version: 10.4.14-MariaDB -- PHP Version: 7.2.34 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 */; -- -- Database: `online_shop` -- -- -------------------------------------------------------- -- -- Table structure for table `admin` -- CREATE TABLE `admin` ( `id_admin` int(5) NOT NULL, `nama_admin` varchar(40) NOT NULL, `user_admin` varchar(15) NOT NULL, `pass_admin` varchar(32) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `admin` -- INSERT INTO `admin` (`id_admin`, `nama_admin`, `user_admin`, `pass_admin`) VALUES (1, 'ardha', 'ardha27', '9a22fdb17ad926f7f2d5064e85760aea'), (2, 'tegar', 'tegar23', '9a22fdb17ad926f7f2d5064e85760aea'); -- -------------------------------------------------------- -- -- Table structure for table `barang` -- CREATE TABLE `barang` ( `id_barang` int(5) NOT NULL, `nama_barang` varchar(100) NOT NULL, `gambar_barang` varchar(200) NOT NULL, `harga_barang` int(10) NOT NULL, `id_kategori` int(5) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `barang` -- INSERT INTO `barang` (`id_barang`, `nama_barang`, `gambar_barang`, `harga_barang`, `id_kategori`) VALUES (6, 'Cireng', 'cireng.jpg', 10000, 11), (7, 'Es Kopi Susu', 'es kopi susu.jpg', 11000, 10), (8, 'Es Teh', 'es teh.jpg', 10000, 10), (9, 'Kentang Goreng', 'kentang goreng.jpg', 10000, 11), (10, 'Mie Ayam', 'mie ayam.jpg', 12500, 9), (11, 'Pisang Goreng', 'pisang goreng.jpg', 10000, 11), (12, 'Risol Mayo', 'risol mayo.jpg', 10000, 11), (13, 'Spaghetti', 'spaghetti.jpg', 18000, 9), (14, 'Thai Tea', 'thai tea.jpg', 12000, 10); -- -------------------------------------------------------- -- -- Table structure for table `customer` -- CREATE TABLE `customer` ( `id_customer` int(5) NOT NULL, `nama_customer` varchar(40) NOT NULL, `alamat_customer` text NOT NULL, `telp_customer` varchar(15) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `customer` -- INSERT INTO `customer` (`id_customer`, `nama_customer`, `alamat_customer`, `telp_customer`) VALUES (40, 'Ardha', 'Singaraja', '123123123'), (41, 'Ardha', 'singaraja', '12344432'), (42, 'Tegar', 'Singaraja', '21312431'), (43, 'Ardha', 'Surabaya', '2132141341'), (44, 'Budi', 'Bandung', '12312341'), (45, 'Panji', 'Gianyar', '2356563254'), (46, 'cosmos', 'Lombok', '2356563254'), (47, 'rangga', 'Bandung', '2132141341'); -- -------------------------------------------------------- -- -- Table structure for table `kategori` -- CREATE TABLE `kategori` ( `id_kategori` int(5) NOT NULL, `nama_kategori` varchar(40) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `kategori` -- INSERT INTO `kategori` (`id_kategori`, `nama_kategori`) VALUES (9, 'Makanan'), (10, 'Minuman'), (11, 'Cemilan'); -- -------------------------------------------------------- -- -- Table structure for table `penjualan` -- CREATE TABLE `penjualan` ( `id_penjualan` int(5) NOT NULL, `tgl_penjualan` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `qty_penjualan` int(5) NOT NULL, `id_barang` int(5) NOT NULL, `id_customer` int(5) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `penjualan` -- INSERT INTO `penjualan` (`id_penjualan`, `tgl_penjualan`, `qty_penjualan`, `id_barang`, `id_customer`) VALUES (17, '2021-01-04 04:28:53', 2, 13, 40), (18, '2021-01-04 04:46:31', 2, 12, 41), (19, '2021-01-05 02:55:25', 2, 9, 42), (20, '2021-01-05 03:07:23', 2, 10, 43), (21, '2021-01-05 04:28:58', 2, 8, 44), (22, '2021-01-05 14:14:18', 5, 11, 45), (23, '2021-01-08 03:36:39', 2, 10, 46), (24, '2021-01-08 13:13:18', 2, 7, 47); -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE `user` ( `id_user` int(5) NOT NULL, `nama_user` varchar(40) NOT NULL, `user_user` varchar(15) NOT NULL, `pass_user` varchar(100) NOT NULL, `role` int(4) NOT NULL DEFAULT 1 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `user` -- INSERT INTO `user` (`id_user`, `nama_user`, `user_user`, `pass_user`, `role`) VALUES (1, 'rizki', 'rizki', '9592638716b04b52fe6e041429822a79', 1), (2, 'dava', 'dava', '9fa0a70dda901fa08bc5d4f37ecbb719', 1), (3, 'widhi', 'widhi', '$2y$10$HUqzsXuB0Ma/xyyPdf79weDq1', 1), (4, 'yudi', 'yudi', '$2y$10$cwFZ3qpOdhM6Q9BqESFbnuHi9QjAEmc8F2a7YPkp/g6etP91fIVHy', 1), (5, 'kevin', 'kevin', '$2y$10$.JgpwbHRgUoqIuZjQT4mkeXwLRlc6E0a/ZBLXnlKhXDQyGOzcAUZy', 1), (6, 'ardha', 'ardha', '$2y$10$1gtSqPKChD18KNI.6vbLjOtqu7bcbcrKYTOBh/p/.GC5i2a2laGh6', 2), (7, 'cosmos', 'cosmos', '$2y$10$APQUS4yMH9rslGW6UQI6NOJgZI2KJtWADmBK2yrN4e6wgrbtLqELO', 1), (8, 'carlo', 'carlo', '$2y$10$blpnHNhkjBpACY84ot/6kuh1DxUebPeL1GrBBGlYW2r/fuQ43Vjx2', 1), (9, 'arthaka', 'arthaka', '$2y$10$.Od4TGmjwCDHL7Pi0nY.Fe3LN5gMRw6tchGUSWHRUNkPmJg63nvNO', 1), (10, 'rangga', 'rangga', '$2y$10$tji40JYfZV4mn50Af4ixnu11/baS76UIP6t8UYVcrjpH/GfyvJlqS', 1); -- -- Indexes for dumped tables -- -- -- Indexes for table `admin` -- ALTER TABLE `admin` ADD PRIMARY KEY (`id_admin`); -- -- Indexes for table `barang` -- ALTER TABLE `barang` ADD PRIMARY KEY (`id_barang`); -- -- Indexes for table `customer` -- ALTER TABLE `customer` ADD PRIMARY KEY (`id_customer`); -- -- Indexes for table `kategori` -- ALTER TABLE `kategori` ADD PRIMARY KEY (`id_kategori`); -- -- Indexes for table `penjualan` -- ALTER TABLE `penjualan` ADD PRIMARY KEY (`id_penjualan`); -- -- Indexes for table `user` -- ALTER TABLE `user` ADD PRIMARY KEY (`id_user`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `admin` -- ALTER TABLE `admin` MODIFY `id_admin` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `barang` -- ALTER TABLE `barang` MODIFY `id_barang` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16; -- -- AUTO_INCREMENT for table `customer` -- ALTER TABLE `customer` MODIFY `id_customer` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=48; -- -- AUTO_INCREMENT for table `kategori` -- ALTER TABLE `kategori` MODIFY `id_kategori` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12; -- -- AUTO_INCREMENT for table `penjualan` -- ALTER TABLE `penjualan` MODIFY `id_penjualan` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25; -- -- AUTO_INCREMENT for table `user` -- ALTER TABLE `user` MODIFY `id_user` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; 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
7603cdb677cb0eb82eecda8c086191961bb8b446
SQL
iDaeun/Self_Study_bitcamp
/Database/localhost-SYS.sql
UTF-8
516
2.671875
3
[]
no_license
-- [미라콤 IT연계과정] DB수업 /* 테이블 스페이스 테이블을 저장하는 장소를 테이블 스페이스라고함 테이블 스페이스 생성 */ create TABLESPACE multi datafile 'c:\multi.dbf' size 50m AUTOEXTEND on next 10m MAXSIZE UNLIMITED; --테이블 스페이스 확인하기 select * from USER_TABLESPACES; --사용자 계정 생성하기 create user multi IDENTIFIED BY multi1234 DEFAULT TABLESPACE multi; --사용자 권한 부여 grant connect, RESOURCE, dba to multi;
true
a0022fc5407116db2b963b8ad0cf8e8ffc9e083a
SQL
altamira/visualstudio
/Sistema de Informação Altamira/EGISADMIN.Database/dbo/Stored Procedures/pr_consulta_tabela.sql
UTF-8
1,550
3.5
4
[]
no_license
 ------------------------------------------------------------------------------- --pr_consulta_tabela ------------------------------------------------------------------------------- --GBS Global Business Solution Ltda 2004 ------------------------------------------------------------------------------- --Stored Procedure : Microsoft SQL Server 2000 --Autor(es) : Carlos Cardoso Fernandes --Banco de Dados : EgisAdmin --Objetivo : Consulta de Tabelas --Data : 24/12/2004 --Atualizado -------------------------------------------------------------------------------------------------- create procedure pr_consulta_tabela @dt_inicial datetime, @dt_final datetime as select t.cd_tabela as Codigo, t.nm_tabela as Tabela, t.ds_tabela as Descricao, t.dt_criacao_tabela as Data, t.ic_parametro_tabela as Parametro, t.ic_implantacao_tabela as ZeraImplantacao, t.ic_fixa_tabela as Fixa, t.ic_supervisor_altera as Supervisor, t.ic_nucleo_tabela as Nucleo, t.ic_inativa_tabela as Inativa, pt.nm_prioridade_tabela as Prioridade, Banco = case when isnull(ic_sap_admin,'N') = 'S' then 'EGISADMIN' else 'EGISSQL' end, u.nm_fantasia_usuario as Usuario from Tabela t, Prioridade_Tabela pt, Usuario u where t.cd_prioridade_tabela = pt.cd_prioridade_tabela and t.cd_usuario = u.cd_usuario order by t.nm_tabela --select * from tabela
true
a6ecc3d42758de9e7be1d4dca9c9d80c23037b80
SQL
962464wa20jr/humanresource
/src/main/resources/sql/register.sql
UTF-8
862
3.21875
3
[]
no_license
drop table if exists t_register; /*==============================================================*/ /* Table: t_register */ /*==============================================================*/ create table t_register ( id bigint(20) not null, apply_ids bigint(20), approver_id bigint(20), create_time date, update_time date, status tinyint(2), primary key (id) ); alter table t_register comment '记录申请注册职员的信息'; alter table t_register add constraint FK_Reference_42 foreign key (apply_ids) references t_user (id) on delete restrict on update restrict; alter table t_register add constraint FK_Reference_43 foreign key (approver_id) references t_user (id) on delete restrict on update restrict;
true
e44011d421733ce2ed1d237b440c9c2170a42718
SQL
rebeccalarner/Google-Cloud-Skills-Challenge
/Create ML Models with BigQuery ML/Bracketology with Google Machine Learning/compare_model_performance.sql
UTF-8
972
3.84375
4
[]
no_license
#where did the naive model (comparing seeds) got it wrong but the advanced model got it right? SELECT CONCAT(opponent_school_ncaa, " (", opponent_seed, ") was ",CAST(ROUND(ROUND(p.prob,2)*100,2) AS STRING),"% predicted to upset ", school_ncaa, " (", seed, ") and did!") AS narrative, predicted_label, # what the model thought n.label, # what actually happened ROUND(p.prob,2) AS probability, season, # us seed, school_ncaa, pace_rank, efficiency_rank, # them opponent_seed, opponent_school_ncaa, opp_pace_rank, opp_efficiency_rank, (CAST(opponent_seed AS INT64) - CAST(seed AS INT64)) AS seed_diff FROM `bracketology.ncaa_2018_predictions` AS n, UNNEST(predicted_label_probs) AS p WHERE predicted_label = 'loss' AND predicted_label = n.label # model got it right AND p.prob >= .55 # by 55%+ confidence AND (CAST(opponent_seed AS INT64) - CAST(seed AS INT64)) > 2 # seed difference magnitude ORDER BY (CAST(opponent_seed AS INT64) - CAST(seed AS INT64)) DESC
true
67dcbb49d28a409d4651d7648802d78e2cee86c0
SQL
graphile/graphile-engine
/packages/postgraphile-core/__tests__/mutations/v4-base/rbac.leftArmIdentity.sql
UTF-8
989
2.75
3
[ "MIT" ]
permissive
SAVEPOINT graphql_mutation with __local_0__ as ( select __local_1__.* from "c"."left_arm_identity"( row( $1::"pg_catalog"."int4", $2::"pg_catalog"."int4", $3::"pg_catalog"."float8", $4::"pg_catalog"."text" )::"c"."left_arm" ) __local_1__ ) select ( ( case when __local_0__ is null then null else __local_0__ end ) )::text from __local_0__ with __local_0__ as ( select ( str::"c"."left_arm" ).* from unnest( ( $1 )::text[] ) str ) select to_json( ( json_build_object( '__identifiers'::text, json_build_array(__local_0__."id"), 'id'::text, (__local_0__."id"), 'personId'::text, (__local_0__."person_id"), 'lengthInMetres'::text, (__local_0__."length_in_metres"), 'mood'::text, (__local_0__."mood") ) ) ) as "@leftArm" from __local_0__ as __local_0__ where ( not (__local_0__ is null) ) and (TRUE) and (TRUE) RELEASE SAVEPOINT graphql_mutation
true
8615d6ac87e66d9b39b0ec1fec9651bf8af3c0bb
SQL
ifanka/10118089_akademik
/10118089_Akademik.sql
UTF-8
3,028
2.890625
3
[]
no_license
-- MySQL dump 10.13 Distrib 5.6.46, for Win64 (x86_64) -- -- Host: localhost Database: 10118089_akademik -- ------------------------------------------------------ -- Server version 5.5.5-10.4.11-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 `admin` -- DROP TABLE IF EXISTS `admin`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `admin` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(25) NOT NULL, `password` varchar(25) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `admin` -- LOCK TABLES `admin` WRITE; /*!40000 ALTER TABLE `admin` DISABLE KEYS */; INSERT INTO `admin` VALUES (1,'admin','admin123'),(4,'ifanka','admin'),(6,'testing','123'); /*!40000 ALTER TABLE `admin` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `mahasiswa` -- DROP TABLE IF EXISTS `mahasiswa`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mahasiswa` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nama` varchar(25) NOT NULL, `nim` int(11) NOT NULL, `kelas` varchar(5) NOT NULL, `kd_mk` int(11) NOT NULL, `nama_mk` varchar(25) NOT NULL, `indeks` varchar(10) NOT NULL, `alamat` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `mahasiswa` -- LOCK TABLES `mahasiswa` WRITE; /*!40000 ALTER TABLE `mahasiswa` DISABLE KEYS */; INSERT INTO `mahasiswa` VALUES (1,'Ifanka Wiralangga',10118089,'IF-03',112233,'Basis Data 2','B','Banten '),(12,'TEST',10118,'IF-',113345,'PROVIS','A','JL.Merdeka'); /*!40000 ALTER TABLE `mahasiswa` 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-08-18 19:55:31
true
257e384adea18c3dcbe781f8e6cf0626f87b1b32
SQL
BaudouinW/Aion-Rising-Back-end
/DB/siteaionrising.sql
UTF-8
27,723
3.15625
3
[ "MIT", "BSD-3-Clause" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.1.4 -- http://www.phpmyadmin.net -- -- Client : 127.0.0.1 -- Généré le : Lun 13 Octobre 2014 à 21:39 -- Version du serveur : 5.6.15-log -- Version de PHP : 5.4.24 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 */; -- -- Base de données : `siteaionrising` -- -- -------------------------------------------------------- -- -- Structure de la table `categoriearme` -- CREATE TABLE IF NOT EXISTS `categoriearme` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nom` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=14 ; -- -- Contenu de la table `categoriearme` -- INSERT INTO `categoriearme` (`id`, `nom`) VALUES (1, 'Canon'), (2, 'Pistolet'), (3, 'Espadon'), (4, 'Guisarme'), (5, 'Arc'), (6, 'Ouvrage'), (7, 'Joyaux'), (8, 'Dague'), (9, 'Epée'), (10, 'Bâton'), (11, 'Bouclier'), (12, 'Masse'), (13, 'Harpe'); -- -------------------------------------------------------- -- -- Structure de la table `commande` -- CREATE TABLE IF NOT EXISTS `commande` ( `id` int(11) NOT NULL AUTO_INCREMENT, `Joueur` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `idAchat` bigint(20) NOT NULL, `quantite` smallint(6) NOT NULL, `nomPersonnage` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `Prix` smallint(6) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ; -- -- Contenu de la table `commande` -- INSERT INTO `commande` (`id`, `Joueur`, `idAchat`, `quantite`, `nomPersonnage`, `Prix`) VALUES (1, 'admin', 110101566, 1, 'test', 350), (2, 'admin', 110101566, 1, 'test', 350), (3, 'admin', 110101566, 1, 'test', 350), (4, 'admin', 164002011, 100, 'test', 20), (5, 'admin', 164002116, 50, 'test', 40), (6, 'admin', 164002057, 100, 'test', 20); -- -------------------------------------------------------- -- -- Structure de la table `emplacement` -- CREATE TABLE IF NOT EXISTS `emplacement` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nom` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ; -- -- Contenu de la table `emplacement` -- INSERT INTO `emplacement` (`id`, `nom`) VALUES (1, 'Torse'), (2, 'Epaules'), (3, 'Mains'), (4, 'Jambière'), (5, 'Bottes'); -- -------------------------------------------------------- -- -- Structure de la table `emplacementautre` -- CREATE TABLE IF NOT EXISTS `emplacementautre` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nom` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ; -- -- Contenu de la table `emplacementautre` -- INSERT INTO `emplacementautre` (`id`, `nom`) VALUES (3, 'Pierre Divine'), (4, 'Titre'), (5, 'Divers'), (6, 'Conso PvP'); -- -------------------------------------------------------- -- -- Structure de la table `emplacementbijoux` -- CREATE TABLE IF NOT EXISTS `emplacementbijoux` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nom` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ; -- -- Contenu de la table `emplacementbijoux` -- INSERT INTO `emplacementbijoux` (`id`, `nom`) VALUES (1, 'Anneau'), (2, 'Boucle d''oreille'), (3, 'Collier'), (4, 'Casque'); -- -------------------------------------------------------- -- -- Structure de la table `emplacementenchant` -- CREATE TABLE IF NOT EXISTS `emplacementenchant` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nom` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ; -- -- Contenu de la table `emplacementenchant` -- INSERT INTO `emplacementenchant` (`id`, `nom`) VALUES (1, 'Basique Ancienne'), (2, 'Double'); -- -------------------------------------------------------- -- -- Structure de la table `items` -- CREATE TABLE IF NOT EXISTS `items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nom` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `idItem` int(11) NOT NULL, `packet` int(11) NOT NULL, `prix` int(11) NOT NULL, `lien` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `categorie` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `niv` int(11) NOT NULL, `emplacement_id` int(11) DEFAULT NULL, `type` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `emplacementAutre_id` int(11) DEFAULT NULL, `emplacementEnchant_id` int(11) DEFAULT NULL, `emplacementBijoux_id` int(11) DEFAULT NULL, `categorieArme_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `IDX_20DFC649C4598A51` (`emplacement_id`), KEY `IDX_20DFC649513D3FC8` (`emplacementAutre_id`), KEY `IDX_20DFC649154F9761` (`emplacementEnchant_id`), KEY `IDX_20DFC6495F4E346C` (`emplacementBijoux_id`), KEY `IDX_20DFC649B2B5E82C` (`categorieArme_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=107 ; -- -- Contenu de la table `items` -- INSERT INTO `items` (`id`, `nom`, `idItem`, `packet`, `prix`, `lien`, `categorie`, `niv`, `emplacement_id`, `type`, `emplacementAutre_id`, `emplacementEnchant_id`, `emplacementBijoux_id`, `categorieArme_id`) VALUES (1, 'Parchemin supérieur de course', 164002011, 100, 20, 'http://aiondatabase.net/fr/item/164002011/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (2, '[Événement] Parchemin supérieur de course immortel', 164002116, 50, 40, 'http://aiondatabase.net/fr/item/164002116/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (3, '[Événement] Parchemin d''éveil supérieur', 164002057, 100, 20, 'http://aiondatabase.net/fr/item/164002057/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (4, '[Événement] Parchemin supérieur d''éveil immortel', 164002118, 50, 40, 'http://aiondatabase.net/fr/item/164002118/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (5, '[Événement] Parchemin supérieur de Courage', 164002010, 100, 20, 'http://aiondatabase.net/fr/item/164002010/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (6, '[Événement] Parchemin de courage supérieur immortel', 164002117, 50, 40, 'http://aiondatabase.net/fr/item/164002117/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (7, 'Parchemin majeur de crit. physique', 164000118, 50, 15, 'http://aiondatabase.net/fr/item/164000118/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (8, 'Parchemin majeur de crit. magiques', 164000122, 50, 15, 'http://aiondatabase.net/fr/item/164000122/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (9, 'Parchemin supérieur de vent enragé', 164002012, 100, 20, 'http://aiondatabase.net/fr/item/164002012/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (10, '[Événement] Parchemin majeur de vent rageur', 164002272, 50, 40, 'http://aiondatabase.net/fr/item/164002272/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (11, 'Parchemin excellent de résistance au vent', 164000117, 50, 10, 'http://aiondatabase.net/fr/item/164000117/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (12, 'Parchemin excellent de protection contre le feu', 164000114, 50, 10, 'http://aiondatabase.net/fr/item/164000114/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (13, 'Parchemin excellent d''imperméabilité', 164000116, 50, 10, 'http://aiondatabase.net/fr/item/164000116/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (14, 'Parchemin excellent de protection contre la terre', 164000115, 50, 10, 'http://aiondatabase.net/fr/item/164000115/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (15, 'Parchemin antichocs excellent', 164000131, 10, 10, 'http://aiondatabase.net/fr/item/164000131/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (16, '[Événement] Sérum de récupération de premier choix', 162001033, 100, 35, 'http://aiondatabase.net/fr/item/162001033/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (17, 'Potion de soins supérieure', 162000023, 100, 35, 'http://aiondatabase.net/fr/item/162000023/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (18, '[Événement] Potion de mana de premier choix', 162001029, 100, 25, 'http://aiondatabase.net/fr/item/162001029/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (19, '[Événement] Potion de vie de premier choix', 162001028, 100, 25, 'http://aiondatabase.net/fr/item/162001028/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (20, 'Sérum de vie divin honorable', 162001027, 20, 25, 'http://aiondatabase.net/fr/item/162001027/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (21, 'Cristal pur de récupération', 162000146, 10, 20, 'http://aiondatabase.net/fr/item/162000146/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (22, '[Événement] Sérum de vent de premier choix', 162001034, 50, 30, 'http://aiondatabase.net/fr/item/162001034/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (23, '[Événement] Gelée à la citrouille', 160005026, 10, 15, 'http://aiondatabase.net/fr/item/160005026/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (24, '[Événement] Gelée à la bière', 160005027, 5, 20, 'http://aiondatabase.net/fr/item/160005027/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (25, 'Graine de détection améliorée', 164000266, 10, 20, 'http://aiondatabase.net/fr/item/164000266/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (26, 'Don de mana béni majeur : niveau 2', 168310018, 1, 50, 'http://aiondatabase.net/fr/item/168310018/', 'Conso PvP', 1, NULL, 'Autre', 6, NULL, NULL, NULL), (27, 'Tunique de commandant gardien d''élite', 110101566, 1, 350, 'http://aiondatabase.net/fr/item/110101566/', 'Item PvP', 65, 1, 'Tissu', NULL, NULL, NULL, NULL), (28, 'Spallières de commandant gardien d''élite', 112101365, 1, 250, 'http://aiondatabase.net/fr/item/112101365/', 'Item PvP', 65, 2, 'Tissu', NULL, NULL, NULL, NULL), (29, 'Gants de commandant gardien d''élite', 111101411, 1, 250, 'http://aiondatabase.net/fr/item/111101411/', 'Item PvP', 65, 3, 'Tissu', NULL, NULL, NULL, NULL), (30, 'Jambières de commandant gardien d''élite', 113101429, 1, 300, 'http://aiondatabase.net/fr/item/113101429/', 'Item PvP', 65, 4, 'Tissu', NULL, NULL, NULL, NULL), (31, 'Chaussures de commandant gardien d''élite', 114101458, 1, 250, 'http://aiondatabase.net/fr/item/114101458/', 'Item PvP', 65, 5, 'Tissu', NULL, NULL, NULL, NULL), (32, 'Tunique sacrée de l''unité spéciale d''archons', 110101705, 1, 400, 'http://aiondatabase.net/fr/item/110101705/', 'Item PvP', 65, 1, 'Tissu', NULL, NULL, NULL, NULL), (33, 'Spallières sacrées de l''unité spéciale d''archons', 112101487, 1, 300, 'http://aiondatabase.net/fr/item/112101487/', 'Item PvP', 65, 2, 'Tissu', NULL, NULL, NULL, NULL), (34, 'Gants sacrés de l''unité spéciale d''archons', 111101535, 1, 300, 'http://aiondatabase.net/fr/item/111101535/', 'Item PvP', 65, 3, 'Tissu', NULL, NULL, NULL, NULL), (35, 'Jambières sacrées de l''unité spéciale d''archons', 113101549, 1, 350, 'http://aiondatabase.net/fr/item/113101549/', 'Item PvP', 65, 4, 'Tissu', NULL, NULL, NULL, NULL), (36, 'Chaussures sacrées de l''unité spéciale d''archons', 114101583, 1, 300, 'http://aiondatabase.net/fr/item/114101583/', 'Item PvP', 65, 5, 'Tissu', NULL, NULL, NULL, NULL), (37, 'Cotte de mailles de commandant gardien d''élite', 110501424, 1, 350, 'http://aiondatabase.net/fr/item/110501424/', 'Item PvP', 65, 1, 'Maille', NULL, NULL, NULL, NULL), (38, 'Spallières de mailles de commandant gardien d''élite', 112501323, 1, 250, 'http://aiondatabase.net/fr/item/112501323/', 'Item PvP', 65, 2, 'Maille', NULL, NULL, NULL, NULL), (39, 'Gants de mailles de commandant gardien d''élite', 111501381, 1, 250, 'http://aiondatabase.net/fr/item/111501381/', 'Item PvP', 65, 3, 'Maille', NULL, NULL, NULL, NULL), (40, 'Grèves de mailles de commandant gardien d''élite', 113501398, 1, 300, 'http://aiondatabase.net/fr/item/113501398/', 'Item PvP', 65, 4, 'Maille', NULL, NULL, NULL, NULL), (41, 'Bottes de mailles de commandant gardien d''élite', 114501406, 1, 250, 'http://aiondatabase.net/fr/item/114501406/', 'Item PvP', 65, 5, 'Maille', NULL, NULL, NULL, NULL), (42, 'Cotte de mailles sacrée de l''unité spéciale d''archons', 110551038, 1, 400, 'http://aiondatabase.net/fr/item/110551038/', 'Item PvP', 65, 1, 'Maille', NULL, NULL, NULL, NULL), (43, 'Spallières de mailles sacrées de l''unité spéciale d''archons', 112501538, 1, 300, 'http://aiondatabase.net/fr/item/112501538/', 'Item PvP', 65, 2, 'Maille', NULL, NULL, NULL, NULL), (44, 'Gants de mailles sacrés de l''unité spéciale d''archons', 111501596, 1, 300, 'http://aiondatabase.net/fr/item/111501596/', 'Item PvP', 65, 3, 'Maille', NULL, NULL, NULL, NULL), (45, 'Grèves de mailles sacrées de l''unité spéciale d''archons', 113501614, 1, 350, 'http://aiondatabase.net/fr/item/113501614/', 'Item PvP', 65, 4, 'Maille', NULL, NULL, NULL, NULL), (46, 'Bottes de mailles sacrées de l''unité spéciale d''archons', 114501623, 1, 300, 'http://aiondatabase.net/fr/item/114501623/', 'Item PvP', 65, 5, 'Maille', NULL, NULL, NULL, NULL), (47, 'Cotte de mailles d''exécuteur archon d''élite', 110501481, 1, 350, 'http://aiondatabase.net/fr/item/110501481/', 'Item PvP', 65, 1, 'Maille Physique', NULL, NULL, NULL, NULL), (48, 'Gants de mailles d''exécuteur archon d''élite', 111501438, 1, 250, 'http://aiondatabase.net/fr/item/111501438/', 'Item PvP', 65, 3, 'Maille Physique', NULL, NULL, NULL, NULL), (49, 'Spallières de mailles d''exécuteur archon d''élite', 112501380, 1, 250, 'http://aiondatabase.net/fr/item/112501380/', 'Item PvP', 65, 2, 'Maille Physique', NULL, NULL, NULL, NULL), (50, 'Grèves de mailles de l''exécuteur archon d''élite', 113501454, 1, 300, 'http://aiondatabase.net/fr/item/113501454/', 'Item PvP', 65, 4, 'Maille Physique', NULL, NULL, NULL, NULL), (51, 'Bottes de mailles d''exécuteur gardien d''élite', 114501458, 1, 250, 'http://aiondatabase.net/fr/item/114501458/', 'Item PvP', 65, 5, 'Maille Physique', NULL, NULL, NULL, NULL), (52, 'Cotte de mailles sacrée de l''unité spéciale de gardiens', 110551039, 1, 400, 'http://aiondatabase.net/fr/item/110551039/', 'Item PvP', 65, 1, 'Maille Physique', NULL, NULL, NULL, NULL), (53, 'Spallières de mailles sacrées de l''unité spéciale de gardiens', 112501539, 1, 300, 'http://aiondatabase.net/fr/item/112501539/', 'Item PvP', 65, 2, 'Maille Physique', NULL, NULL, NULL, NULL), (54, 'Gants de mailles sacrés de l''unité spéciale de gardiens', 111501597, 1, 300, 'http://aiondatabase.net/fr/item/111501597/', 'Item PvP', 65, 3, 'Maille Physique', NULL, NULL, NULL, NULL), (55, 'Grèves de mailles sacrées de l''unité spéciale de gardiens', 113501615, 1, 350, 'http://aiondatabase.net/fr/item/113501615/', 'Item PvP', 65, 4, 'Maille Physique', NULL, NULL, NULL, NULL), (56, 'Bottes de mailles sacrées de l''unité spéciale de gardiens', 114501624, 1, 300, 'http://aiondatabase.net/fr/item/114501624/', 'Item PvP', 65, 5, 'Maille Physique', NULL, NULL, NULL, NULL), (57, 'Pourpoint de cuir d''exécuteur archon d''élite', 110301631, 1, 350, 'http://aiondatabase.net/fr/item/110301631/', 'Item PvP', 65, 1, 'Cuir Magique', NULL, NULL, NULL, NULL), (58, 'Spallières de cuir de l''exécuteur archon d''élite', 112301511, 1, 250, 'http://aiondatabase.net/fr/item/112301511/', 'Item PvP', 65, 2, 'Cuir Magique', NULL, NULL, NULL, NULL), (59, 'Gants de cuir de l''exécuteur archon d''élite', 111301572, 1, 250, 'http://aiondatabase.net/fr/item/111301572/', 'Item PvP', 65, 3, 'Cuir Magique', NULL, NULL, NULL, NULL), (60, 'Jambières de cuir d''exécuteur archon d''élite', 113301597, 1, 300, 'http://aiondatabase.net/fr/item/113301597/', 'Item PvP', 65, 4, 'Cuir Magique', NULL, NULL, NULL, NULL), (61, 'Bottes de cuir d''exécuteur archon d''élite', 114301636, 1, 250, 'http://aiondatabase.net/fr/item/114301636/', 'Item PvP', 65, 5, 'Cuir Magique', NULL, NULL, NULL, NULL), (62, 'Pourpoint sacré de l''unité spéciale de gardiens', 110301709, 1, 400, 'http://aiondatabase.net/fr/item/110301709/', 'Item PvP', 65, 1, 'Cuir Magique', NULL, NULL, NULL, NULL), (63, 'Spallières de cuir sacrées de l''unité spéciale de gardiens', 112301586, 1, 300, 'http://aiondatabase.net/fr/item/112301586/', 'Item PvP', 65, 2, 'Cuir Magique', NULL, NULL, NULL, NULL), (64, 'Gants de cuir sacrés de l''unité spéciale de gardiens', 111301647, 1, 300, 'http://aiondatabase.net/fr/item/111301647/', 'Item PvP', 65, 3, 'Cuir Magique', NULL, NULL, NULL, NULL), (65, 'Jambières de cuir sacrées de l''unité spéciale de gardiens', 113301678, 1, 350, 'http://aiondatabase.net/fr/item/113301678/', 'Item PvP', 65, 4, 'Cuir Magique', NULL, NULL, NULL, NULL), (66, 'Chaussures de cuir sacrées de l''unité spéciale de gardiens', 114301715, 1, 300, 'http://aiondatabase.net/fr/item/114301715/', 'Item PvP', 65, 5, 'Cuir Magique', NULL, NULL, NULL, NULL), (67, 'Pourpoint de cuir de commandant gardien d''élite', 110301463, 1, 350, 'http://aiondatabase.net/fr/item/110301463/', 'Item PvP', 65, 1, 'Cuir', NULL, NULL, NULL, NULL), (68, 'Spallières de cuir de commandant gardien d''élite', 112301347, 1, 250, 'http://aiondatabase.net/fr/item/112301347/', 'Item PvP', 65, 2, 'Cuir', NULL, NULL, NULL, NULL), (69, 'Gants de cuir de commandant gardien d''élite', 111301403, 1, 250, 'http://aiondatabase.net/fr/item/111301403/', 'Item PvP', 65, 3, 'Cuir', NULL, NULL, NULL, NULL), (70, 'Jambières de cuir de commandant gardien d''élite', 113301428, 1, 300, 'http://aiondatabase.net/fr/item/113301428/', 'Item PvP', 65, 4, 'Cuir', NULL, NULL, NULL, NULL), (71, 'Chaussures de cuir de commandant gardien d''élite', 114301464, 1, 250, 'http://aiondatabase.net/fr/item/114301464/', 'Item PvP', 65, 5, 'Cuir', NULL, NULL, NULL, NULL), (72, 'Pourpoint sacré de l''unité spéciale d''archons', 110301708, 1, 400, 'http://aiondatabase.net/fr/item/110301708/', 'Item PvP', 65, 1, 'Cuir', NULL, NULL, NULL, NULL), (73, 'Spallières de cuir sacrées de l''unité spéciale d''archons', 112301585, 1, 300, 'http://aiondatabase.net/fr/item/112301585/', 'Item PvP', 65, 2, 'Cuir', NULL, NULL, NULL, NULL), (74, 'Gants de cuir sacrés de l''unité spéciale d''archons', 111301646, 1, 300, 'http://aiondatabase.net/fr/item/111301646/', 'Item PvP', 65, 3, 'Cuir', NULL, NULL, NULL, NULL), (75, 'Jambières de cuir sacrées de l''unité spéciale d''archons', 113301677, 1, 350, 'http://aiondatabase.net/fr/item/113301677/', 'Item PvP', 65, 4, 'Cuir', NULL, NULL, NULL, NULL), (76, 'Chaussures de cuir sacrées de l''unité spéciale d''archons', 114301714, 1, 300, 'http://aiondatabase.net/fr/item/114301714/', 'Item PvP', 65, 5, 'Cuir', NULL, NULL, NULL, NULL), (77, 'Plastron de commandant gardien d''élite', 110601399, 1, 350, 'http://aiondatabase.net/fr/item/110601399/', 'Item PvP', 65, 1, 'Plate', NULL, NULL, NULL, NULL), (78, 'Spallières de plates de commandant gardien d''élite', 112601343, 1, 250, 'http://aiondatabase.net/fr/item/112601343/', 'Item PvP', 65, 2, 'Plate', NULL, NULL, NULL, NULL), (79, 'Gantelets de commandant gardien d''élite', 111601361, 1, 250, 'http://aiondatabase.net/fr/item/111601361/', 'Item PvP', 65, 3, 'Plate', NULL, NULL, NULL, NULL), (80, 'Grèves de plates de commandant gardien d''élite', 113601351, 1, 300, 'http://aiondatabase.net/fr/item/113601351/', 'Item PvP', 65, 4, 'Plate', NULL, NULL, NULL, NULL), (81, 'Bottes de plates de commandant gardien d''élite', 114601349, 1, 250, 'http://aiondatabase.net/fr/item/114601349/', 'Item PvP', 65, 5, 'Plate', NULL, NULL, NULL, NULL), (82, 'Plastron sacré de l''unité spéciale d''archons', 110601512, 1, 400, 'http://aiondatabase.net/fr/item/110601512/', 'Item PvP', 65, 1, 'Plate', NULL, NULL, NULL, NULL), (83, 'Spallières de plates sacrées de l''unité spéciale d''archons', 112601456, 1, 300, 'http://aiondatabase.net/fr/item/112601456/', 'Item PvP', 65, 2, 'Plate', NULL, NULL, NULL, NULL), (84, 'Gantelets sacrés de l''unité spéciale d''archons', 111601475, 1, 300, 'http://aiondatabase.net/fr/item/111601475/', 'Item PvP', 65, 3, 'Plate', NULL, NULL, NULL, NULL), (85, 'Grèves de plates sacrées de l''unité spéciale d''archons', 113601458, 1, 350, 'http://aiondatabase.net/fr/item/113601458/', 'Item PvP', 65, 4, 'Plate', NULL, NULL, NULL, NULL), (86, 'Bottes de plates sacrées de l''unité spéciale d''archons', 114601465, 1, 300, 'http://aiondatabase.net/fr/item/114601465/', 'Item PvP', 65, 5, 'Plate', NULL, NULL, NULL, NULL), (87, 'Mets épicés de noble maître', 160002414, 50, 80, 'http://aiondatabase.net/fr/item/160002414/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (88, 'Mets sucrés de noble maître', 160002415, 50, 80, 'http://aiondatabase.net/fr/item/160002415/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (89, 'Bouillon à la viande de Dragon épicé', 160002505, 50, 50, 'http://aiondatabase.net/fr/item/160002505/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (90, 'Viande de Dragon épicée frite à l''huile', 160002504, 50, 50, 'http://aiondatabase.net/fr/item/160002504/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (91, 'Viande de Dragon pimentée frite à l''huile', 160002506, 50, 50, 'http://aiondatabase.net/fr/item/160002506/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (92, 'Pépento grillé au fromage', 160002436, 50, 30, 'http://aiondatabase.net/fr/item/160002436/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (93, 'Bouillon à la viande de Dragon épicé', 160002505, 50, 30, 'http://aiondatabase.net/fr/item/160002505/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (94, 'salade de viande de Dragon à la vinaigrette accompagnée de Plumebo', 160002453, 50, 30, 'http://aiondatabase.net/fr/item/160002453/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (95, 'Savoureuse viande braisée de l''empereur Dragon à cornes', 160002394, 50, 30, 'http://aiondatabase.net/fr/item/160002394/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (96, 'Savoureuse viande rôtie de l''empereur Dragon à cornes', 160002397, 50, 30, 'http://aiondatabase.net/fr/item/160002397/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (97, 'Savoureux curry de l''empereur Dragon à cornes', 160002393, 50, 30, 'http://aiondatabase.net/fr/item/160002393/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (98, 'Omelette au fromage d''Abex', 160002432, 50, 30, 'http://aiondatabase.net/fr/item/160002432/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (99, 'Plumebo épicé au fromage', 160002433, 50, 30, 'http://aiondatabase.net/fr/item/160002433/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (100, 'Plumebo frais frit au fromage', 160002478, 50, 30, 'http://aiondatabase.net/fr/item/160002478/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (101, 'Omelette à la viande de Dragon frite à l''huile accompagnée de Plumebo', 160002456, 50, 30, 'http://aiondatabase.net/fr/item/160002456/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (102, 'Nourriture bouillie de l''empereur Dragon à cornes', 160002389, 50, 30, 'http://aiondatabase.net/fr/item/160002389/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (103, 'Savoureuse omelette de l''empereur Dragon à cornes', 160002395, 50, 30, 'http://aiondatabase.net/fr/item/160002395/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (104, 'Salade de l''empereur Dragon à cornes', 160002385, 50, 30, 'http://aiondatabase.net/fr/item/160002385/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (105, 'Pépento frais rôti au fromage', 160002479, 50, 30, 'http://aiondatabase.net/fr/item/160002479/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL), (106, 'Savoureuse viande frite de l''empereur Dragon à cornes', 160002391, 50, 30, 'http://aiondatabase.net/fr/item/160002391/', 'Conso', 1, NULL, 'Nourriture', NULL, NULL, NULL, NULL); -- -------------------------------------------------------- -- -- Structure de la table `site_user` -- CREATE TABLE IF NOT EXISTS `site_user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `username_canonical` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `email_canonical` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `enabled` tinyint(1) NOT NULL, `salt` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `last_login` datetime DEFAULT NULL, `locked` tinyint(1) NOT NULL, `expired` tinyint(1) NOT NULL, `expires_at` datetime DEFAULT NULL, `confirmation_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `password_requested_at` datetime DEFAULT NULL, `roles` longtext COLLATE utf8_unicode_ci NOT NULL COMMENT '(DC2Type:array)', `credentials_expired` tinyint(1) NOT NULL, `credentials_expire_at` datetime DEFAULT NULL, `cashShopMoney` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `UNIQ_B6096BB092FC23A8` (`username_canonical`), UNIQUE KEY `UNIQ_B6096BB0A0D96FBF` (`email_canonical`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=13 ; -- -- Contenu de la table `site_user` -- INSERT INTO `site_user` (`id`, `username`, `username_canonical`, `email`, `email_canonical`, `enabled`, `salt`, `password`, `last_login`, `locked`, `expired`, `expires_at`, `confirmation_token`, `password_requested_at`, `roles`, `credentials_expired`, `credentials_expire_at`, `cashShopMoney`) VALUES (9, 'admin', 'admin', 'email@domaine.com', 'email@domaine.com', 1, '7ger35hhuo4kok44gwcwk8skgwgkgs4', 'Sd16OaTSB9Qzs/t+8RHAcnF6TgwAS9OaGGO3t+SXyZsjTeVy3XBed+29oP6GZhtlrnno0DTWVOs8n0Yf76oI0g==', '2014-10-13 19:29:11', 0, 0, NULL, NULL, NULL, 'a:0:{}', 0, NULL, 320), (10, 'test', 'test', 'test@domaine.com', 'test@domaine.com', 1, 'pzi9p93rguss4ssc8s48wkggc8w0soc', '26ogeTvIIDCjyaOHOvj3Zhkt2QFuvPLWFsbEuz0LqJUWcYlnrYKLq5BNzwjEI7pc7OxvSnwXR486lbLhEZH03A==', NULL, 0, 0, NULL, NULL, NULL, 'a:0:{}', 0, NULL, NULL), (11, 'baudouin', 'baudouin', 'baudouin-wartel@live.fr', 'baudouin-wartel@live.fr', 1, '4645vp7al3y8csw4g4sg4ow0ogskc84', 'Cb9tL6wHtIBA8Xcsijm0MTay+tjwE0EiEHXKZ+K9mdtweX2lLIqoVQmapILDwBJMroIhJyUaIJ1GS8lwhB4kFQ==', NULL, 0, 0, NULL, NULL, NULL, 'a:0:{}', 0, NULL, NULL), (12, 'testo', 'testo', 'testo@domaine.fr', 'testo@domaine.fr', 1, '46m3sufekbggks0s0s0o4w8ogckcgsc', 'UrCYP7lSRBHy3fwsVcXCXIWOdw/KpSLg05yip9rtX0FUHXxhVCZXe2YTl+AKRG2TXWVRqUNjiTiLyc4T6BlJ/w==', NULL, 0, 0, NULL, NULL, NULL, 'a:0:{}', 0, NULL, NULL); -- -- Contraintes pour les tables exportées -- -- -- Contraintes pour la table `items` -- ALTER TABLE `items` ADD CONSTRAINT `FK_20DFC649154F9761` FOREIGN KEY (`emplacementEnchant_id`) REFERENCES `emplacementenchant` (`id`), ADD CONSTRAINT `FK_20DFC649513D3FC8` FOREIGN KEY (`emplacementAutre_id`) REFERENCES `emplacementautre` (`id`), ADD CONSTRAINT `FK_20DFC6495F4E346C` FOREIGN KEY (`emplacementBijoux_id`) REFERENCES `emplacementbijoux` (`id`), ADD CONSTRAINT `FK_20DFC649B2B5E82C` FOREIGN KEY (`categorieArme_id`) REFERENCES `categoriearme` (`id`), ADD CONSTRAINT `FK_20DFC649C4598A51` FOREIGN KEY (`emplacement_id`) REFERENCES `emplacement` (`id`); /*!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
7ad5e16531f1c89eee76343a318deff520132579
SQL
viniciusufop/Questionario
/WebContent/scriptDB/banco.sql
UTF-8
2,427
3.734375
4
[]
no_license
CREATE database questionario; use questionario; create table usuario ( idUsuario int not null auto_increment, nome varchar(100) null, email varchar(100) not null, senha varchar(32) null, permissao varchar(100) null, ativo tinyint(1) not null, primary key (idUsuario) ); create table questionario ( idQuestionario int not null auto_increment, idUsuario int not null, nome varchar(100) null, primary key (idQuestionario), constraint fk_questionario_usuario foreign key (idUsuario) references usuario (idUsuario) on delete cascade on update cascade ); create table pergunta ( idPergunta int not null auto_increment, idQuestionario int not null, codPergunta int not null, descricao VARCHAR(500) not null, objetiva TINYINT(1) not null default 0, primary key (idPergunta), constraint fk_pergunta_questionario foreign key (idQuestionario) references questionario (idQuestionario) on delete cascade on update cascade ); create table opcaoRespostaObjetiva ( idOpcaoRespostaObjetiva int not null auto_increment, idPergunta int not null, codResposta int not null, descricao varchar(100) null, primary key (idOpcaoRespostaObjetiva), constraint fk_opcaoRespostaObjectiva_pergunta foreign key (idPergunta) references pergunta (idPergunta) on delete cascade on update cascade ); create table usuarioResposta ( idUsuario int not null, idQuestionario int not null, idPergunta int not null, respostaDiscursiva varchar(100) null, respostaObjetiva int null, primary key (idUsuario,idQuestionario,idPergunta), constraint fk_usuarioResposta_usuario foreign key (idUsuario) references usuario (idUsuario) on delete cascade on update cascade, constraint fk_usuarioResposta_questionario foreign key (idQuestionario) references questionario (idQuestionario) on delete cascade on update cascade, constraint fk_usuarioResposta_pergunta foreign key (idPergunta) references pergunta (idPergunta) on delete cascade on update cascade ); select * from usuario; update usuario set ativo = 1 where idusuario = 2; insert into usuario(nome,email,senha,permissao,ativo) values ("Vinicius", "vinicius", "teste", "ROLE_MEMBRO", 1);
true
a6a95ab39d70b7bc4a14608f2319956e593f75f3
SQL
ujala-pandey/Database-Examples
/Insurance/views.sql
UTF-8
3,421
3.921875
4
[]
no_license
create or replace view q1 as -- replace this line with your first SQL query SELECT DISTINCT p.givenName || ' ' || p.familyName AS name, e.salary AS salary FROM Party p, Employee e, UnderWritingAction uwa WHERE p.id = e.id AND e.id = uwa.underwriter; COLUMN name FORMAT a20; COLUMN salary FORMAT $9999990.00; ; create or replace view q2 as -- replace this line with your second SQL query SELECT DISTINCT pa.givenName || ' ' || pa.familyName AS name, pa.street || ', ' || pa.suburb || ', ' || pa.state || ' ' || pa.postcode AS address FROM Party pa, Client c, Holds h, Policy po, Covers c, RatingAction ra WHERE pa.id = c.id AND c.id = h.client AND h.policy = c.policy AND c.coverage = ra.coverage AND ra.action = 'D'; COLUMN name FORMAT a20; COLUMN address FORMAT a40; ; create or replace view q3 as -- replace this line with your third SQL query SELECT pa.givenName || ' ' || pa.familyName AS name FROM Party pa, Employee e, Client c, Holds h, Policy po WHERE pa.id = e.id AND e.id = c.id AND c.id = h.client AND h.policy = po.id AND po.status = 'OK'; COLUMN name FORMAT a20; ; create or replace view q4 as -- replace this line with your fourth SQL query SELECT SUM(p.premium) AS MoneyCollected FROM Policy p; COLUMN MoneyCollected FORMAT $9999990.00; ; create or replace view q5 as -- replace this line with your fifth SQL query SELECT SUM(ca.amount) AS MoneyPaid FROM ClaimAction ca WHERE ca.action = 'PO'; COLUMN MoneyPaid FORMAT $9999990.00; ; create or replace view q6 as -- replace this line with your sixth SQL query SELECT DISTINCT pa.givenName || ' ' || pa.familyName AS name FROM Party pa, Holds h, Policy po, Claim claim WHERE pa.id = h.client AND h.policy = po.id AND po.id = claim.policy AND claim.claimant = pa.id; COLUMN name FORMAT a20; ; create or replace view q7 as -- replace this line with your seventh SQL query SELECT DISTINCT po.id AS policy FROM Policy po, Covers Covers, Coverage Coverage, CoveredItem ci WHERE po.id = Covers.policy AND Covers.coverage = Coverage.id AND Covers.item = ci.id AND Coverage.coverValue > ci.marketValue ORDER BY po.id; ; create or replace view q8 as -- replace this line with your eighth SQL query SELECT DISTINCT ci.make, ci.model, COUNT(ci.model) AS NumberInsured FROM CoveredItem ci GROUP BY ci.make, ci.model ORDER BY ci.make, ci.model; COLUMN make FORMAT a12; COLUMN model FORMAT a12; ; create or replace view q9 as -- replace this line with your ninth SQL query SELECT DISTINCT pa.givenName || ' ' || pa.familyName AS PolicyHolder, pa2.givenName || ' ' || pa2.familyName AS PolicyProcessor FROM Party pa, Employee e, Holds h, UnderWritingAction uwa, Covers Covers, RatingAction ra, Party pa2 WHERE pa.id = e.id AND e.id = h.client AND ((h.policy = uwa.policy AND uwa.underwriter = pa2.id) OR (h.policy = Covers.policy AND Covers.coverage = ra.coverage AND ra.rater = pa2.id)) ORDER BY PolicyHolder; COLUMN PolicyHolder FORMAT a20; COLUMN PolicyProcessor FORMAT a20; ; create or replace view q10 as -- replace this line with your tenth SQL query SELECT DISTINCT po.id AS id, ci.make AS make, ci.model AS model FROM Policy po, CoveredItem ci WHERE NOT EXISTS ((SELECT DISTINCT Coverage.description FROM Coverage Coverage ) MINUS ( SELECT Coverage2.description FROM Covers Covers, Coverage Coverage2 WHERE ci.id = Covers.item AND po.id = Covers.policy AND Coverage2.id = Covers.coverage )); ; /
true
971ef7465e367d090487d554d5ce4d4b757fe9b1
SQL
spyroks/uno-momento
/backend/src/sql/database.sql
UTF-8
10,045
4.03125
4
[ "MIT" ]
permissive
CREATE DOMAIN d_name VARCHAR(128) NOT NULL CONSTRAINT CK_d_name CHECK (TRIM(VALUE) != '' and VALUE !~ '^[[:digit:]]+$'); CREATE TABLE Account_State ( account_state_code SMALLINT NOT NULL, ee_name d_name, en_name d_name, CONSTRAINT PK_Account_State_account_state_code PRIMARY KEY (account_state_code), CONSTRAINT AK_Account_State_ee_name UNIQUE (ee_name), CONSTRAINT AK_Account_State_en_name UNIQUE (en_name) ); CREATE TABLE Degree ( degree_code SMALLINT NOT NULL, ee_name d_name, en_name d_name, CONSTRAINT PK_Degree_degree_code PRIMARY KEY (degree_code), CONSTRAINT AK_Degree_ee_name UNIQUE (ee_name), CONSTRAINT AK_Degree_en_name UNIQUE (en_name) ); COMMENT ON TABLE Degree IS '1 -- No Degree, 2 -- Bachelor, 3 -- Master, 4 -- Doctoral, 5 -- Applied Higher Education'; CREATE TABLE Account_Role ( account_role_code SMALLINT NOT NULL, role_name d_name, CONSTRAINT PK_Account_Role_account_role_code PRIMARY KEY (account_role_code), CONSTRAINT AK_Account_Role_role_name UNIQUE (role_name) ); CREATE TABLE Account ( account_id BIGSERIAL NOT NULL, username VARCHAR(32) NOT NULL, password VARCHAR(72) NOT NULL, email VARCHAR(256) NOT NULL, /* TODO: make trigger uniid || '@ttu.ee' */ account_state_code SMALLINT NOT NULL DEFAULT 1, account_role_code SMALLINT NOT NULL DEFAULT 1, reg_time TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT PK_Account_account_id PRIMARY KEY (account_id), CONSTRAINT FK_Account_account_state_code FOREIGN KEY (account_state_code) REFERENCES Account_State (account_state_code) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT FK_Account_account_role_code FOREIGN KEY (account_role_code) REFERENCES Account_Role (account_role_code) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT CK_Account_username CHECK (username ~ '^\w{3,}$'), CONSTRAINT CK_Account_password CHECK (TRIM(password) != ''), CONSTRAINT CK_Account_email CHECK (email ~ '^[a-z0-9!#$%&''*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&''*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$'), CONSTRAINT CK_Account_reg_time CHECK (reg_time <= now()) ); CREATE UNIQUE INDEX IXAK_Account_email ON Account (LOWER(email) ASC); CREATE UNIQUE INDEX IXAK_Account_username ON Account (LOWER(username) ASC); CREATE INDEX IXFK_Account_account_state_code ON Account (account_state_code ASC); CREATE INDEX IXFK_Account_account_role_code ON Account (account_role_code ASC); CREATE TABLE Person ( person_id BIGSERIAL NOT NULL, uni_id VARCHAR(6) NOT NULL, /* TODO: create by function */ degree_code SMALLINT NOT NULL, firstname VARCHAR(1000) NOT NULL, lastname VARCHAR(1000) NOT NULL, person_state_code SMALLINT NOT NULL DEFAULT 1, CONSTRAINT PK_Person_person_id PRIMARY KEY (person_id), CONSTRAINT FK_Person_degree_code FOREIGN KEY (degree_code) REFERENCES Degree (degree_code) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT CK_Person_firstname CHECK (TRIM(firstname) != '' AND firstname !~ '^[[:digit:]]+$'), CONSTRAINT CK_Person_lastname CHECK (TRIM(lastname) != '' AND lastname !~ '^[[:digit:]]+$'), CONSTRAINT CK_Person_uni_id CHECK (uni_id ~ '^[a-z]{6}$') ); CREATE INDEX IXFK_Person_degree_code ON Person (degree_code ASC); CREATE UNIQUE INDEX IXAK_Person_uni_id ON Person (LOWER(uni_id) ASC); CREATE TABLE Person_Account_Owner ( account_id BIGINT NOT NULL, person_id BIGINT NOT NULL, CONSTRAINT PK_Person_Account_Owner_account_id PRIMARY KEY (account_id), CONSTRAINT FK_Person_Account_Owner_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT FK_Person_Account_Owner_account_id FOREIGN KEY (account_id) REFERENCES Account (account_id) ON DELETE CASCADE ON UPDATE RESTRICT ); CREATE INDEX IXFK_Person_Account_Owner_person_id ON Person_Account_Owner (person_id ASC); CREATE TABLE Role ( role_code SMALLINT NOT NULL, en_name d_name, ee_name d_name, CONSTRAINT PK_Role_person_role_code PRIMARY KEY (role_code), CONSTRAINT AK_Role_ee_name UNIQUE (ee_name), CONSTRAINT AK_Role_en_name UNIQUE (en_name) ); COMMENT ON TABLE Role IS '1 -- Student, 2 -- Curator'; CREATE TABLE Faculty ( faculty_code SMALLINT NOT NULL, ee_name d_name, en_name d_name, CONSTRAINT PK_Faculty_faculty_code PRIMARY KEY (faculty_code), CONSTRAINT AK_Faculty_ee_name UNIQUE (ee_name), CONSTRAINT AK_Faculty_en_name UNIQUE (en_name) ); COMMENT ON TABLE Faculty IS '1 -- School of Business and Governance, 2 -- School of Engineering, 3 -- School of Information Technologies, 4 -- School of Science, 5 -- Estonian Maritime Academy'; CREATE TABLE Person_Role ( person_id BIGINT NOT NULL, role_code SMALLINT NOT NULL, CONSTRAINT PK_Person_Role_person_id_role_code PRIMARY KEY (person_id, role_code), CONSTRAINT FK_Person_Role_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT FK_Person_Role_role_code FOREIGN KEY (role_code) REFERENCES Role (role_code) ON DELETE RESTRICT ON UPDATE CASCADE ); CREATE INDEX IXFK_Person_Role_role_code ON Person_Role (role_code ASC); CREATE TABLE Person_Faculty ( person_id BIGINT NOT NULL, faculty_code SMALLINT NOT NULL, CONSTRAINT PK_Person_Faculty_person_id_faculty_code PRIMARY KEY (person_id, faculty_code), CONSTRAINT FK_Person_Faculty_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT FK_Person_Faculty_faculty_code FOREIGN KEY (faculty_code) REFERENCES Faculty (faculty_code) ON DELETE RESTRICT ON UPDATE CASCADE ); CREATE INDEX IXFK_Person_Faculty_faculty_code ON Person_Faculty (faculty_code ASC); CREATE TABLE Thesis_State ( thesis_state_code SMALLINT NOT NULL, ee_name d_name, en_name d_name, CONSTRAINT PK_Thesis_State_thesis_state_code PRIMARY KEY (thesis_state_code), CONSTRAINT AK_Thesis_State_en_name UNIQUE (en_name), CONSTRAINT AK_Thesis_State_ee_name UNIQUE (ee_name) ); COMMENT ON TABLE Thesis_State IS '1 -- Active, 2 - Inactive, 3 - Reserved'; CREATE TABLE Thesis ( thesis_id BIGSERIAL NOT NULL, supervisor_name VARCHAR(1000), faculty_code SMALLINT NOT NULL, thesis_state_code SMALLINT NOT NULL DEFAULT 1, degree_code SMALLINT NOT NULL, ee_title VARCHAR(128), en_title VARCHAR(128), ee_description VARCHAR(1000), en_description VARCHAR(1000), reg_time TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT PK_Thesis_thesis_id PRIMARY KEY (thesis_id), CONSTRAINT CK_Thesis_supervisor_name CHECK (supervisor_name ~ '^[[:alpha:]\s]*$'), CONSTRAINT FK_Thesis_faculty_code FOREIGN KEY (faculty_code) REFERENCES Faculty (faculty_code) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT FK_Thesis_thesis_state_code FOREIGN KEY (thesis_state_code) REFERENCES Thesis_State (thesis_state_code) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT FK_Thesis_degree_code FOREIGN KEY (degree_code) REFERENCES Degree (degree_code) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT CK_Thesis_must_contain_one_or_more_titles_and_descriptions CHECK (ee_title IS NOT NULL AND ee_description IS NOT NULL OR en_title IS NOT NULL AND en_description IS NOT NULL), CONSTRAINT CK_Thesis_reg_time CHECK (reg_time <= now()) ); CREATE INDEX IXFK_Thesis_faculty_code ON Thesis (faculty_code ASC); CREATE INDEX IXFK_Thesis_State_thesis_state_code ON Thesis_State (thesis_state_code ASC); CREATE TABLE Thesis_Candidate ( thesis_id BIGINT NOT NULL, candidate_id BIGINT NOT NULL, CONSTRAINT PK_Thesis_Candidate_thesis_id_candidate_id PRIMARY KEY (thesis_id, candidate_id), CONSTRAINT FK_Thesis_Candidate_thesis_id FOREIGN KEY (thesis_id) REFERENCES Thesis (thesis_id) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT FK_Thesis_Candidate_candidate_id FOREIGN KEY (candidate_id) REFERENCES Person (person_id) ON DELETE CASCADE ON UPDATE RESTRICT ); CREATE INDEX IXFK_Thesis_Candidate_candidate_id ON Thesis_Candidate (candidate_id ASC); CREATE TABLE Thesis_Tag ( thesis_id BIGINT NOT NULL, tag_name VARCHAR(32) NOT NULL, CONSTRAINT PK_Thesis_Tag_thesis_id_tag_name PRIMARY KEY (thesis_id, tag_name), CONSTRAINT FK_Thesis_Tag_thesis_id FOREIGN KEY (thesis_id) REFERENCES Thesis (thesis_id) ON DELETE CASCADE ON UPDATE RESTRICT ); CREATE TABLE Thesis_Owner ( thesis_id BIGINT NOT NULL, person_id BIGINT NOT NULL, role_code SMALLINT NOT NULL, CONSTRAINT PK_Thesis_Owner_thesis_id_person_id PRIMARY KEY (thesis_id, person_id), CONSTRAINT FK_Thesis_Owner_thesis_id FOREIGN KEY (thesis_id) REFERENCES Thesis (thesis_id) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT FK_Thesis_Owner_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT FK_Thesis_Owner_role_code FOREIGN KEY (role_code) REFERENCES Role (role_code) ON DELETE RESTRICT ON UPDATE CASCADE ); CREATE INDEX IXFK_Thesis_Owner_person_id ON Thesis_Owner (person_id ASC); CREATE INDEX IXFK_Thesis_Owner_role_code ON Thesis_Owner (role_code ASC); CREATE TABLE thesis_picked ( thesis_id BIGINT NOT NULL, person_id BIGINT NOT NULL, CONSTRAINT PK_thesis_picked_thesis_id_person_id PRIMARY KEY (thesis_id, person_id), CONSTRAINT FK_thesis_picked_thesis_id FOREIGN KEY (thesis_id) REFERENCES thesis (thesis_id) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT FK_thesis_picked_person_id FOREIGN KEY (person_id) REFERENCES person (person_id) ON DELETE CASCADE ON UPDATE RESTRICT ); CREATE INDEX IXFK_thesis_picked_person_id ON thesis_picked (person_id ASC); CREATE OR REPLACE VIEW curators_with_theses WITH (security_barrier) AS SELECT p.person_id, p.uni_id, p.degree_code, p.firstname, p.lastname, p.person_state_code, array_to_json(array_agg(r.*)) AS theses FROM person p INNER JOIN thesis_owner tho USING (person_id) INNER JOIN person_role pr USING (person_id) INNER JOIN ( SELECT t.*, d.en_name AS en_degree, d.ee_name AS ee_degree FROM thesis t INNER JOIN degree d ON t.degree_code = d.degree_code) r ON r.thesis_id = tho.thesis_id WHERE (pr.role_code = 2) GROUP BY p.person_id;
true
9cba4870fa342ef412da8d331ab43304b3557a8b
SQL
simplyadrian/dotfiles
/login.sql
UTF-8
926
2.75
3
[ "MIT" ]
permissive
/* print out anything when we log in */ set termout off /* DBMS_OUTPUT.PUT_LINE set on and as big as possible */ set serveroutput on size 1000000 format wrapped /* column width */ set lines 256 set trimout on set tab off set pagesize 100 set colsep " | " column FILENAME format a50 /* removing training blanks from spool */ set trimspool on # default to 80 for LONG or CLOB */ set long 5000 /* default widht at which sqlplus wraps out */ set linesize 149 # default print column heading every 14 lines set pagesize 9999 /* signature */ column global_name new_value gname set termout off define sql_prompt=idle column user_sid new_value sql_prompt select lower(user) || '@' || lower('&_CONNECT_IDENTIFIER') user_sid from dual; column cust_env new_value sql_prompt2 select lower(env_name) cust_env from idsdba.ids_config; set sqlprompt '&sql_prompt-&sql_prompt2>' /* sqlplus can now print to the screen */ set termout on
true
2df2c1d1745ddfafa8ea59302e93965ce31caf58
SQL
fiasforall/base
/db/tables/ADDROBJ_ddl.sql
UTF-8
6,056
3.0625
3
[]
no_license
create table ADDROBJ ( aoguid varchar2(36) not null, formalname varchar2(120 char) not null, regioncode varchar2(2), autocode varchar2(1), areacode varchar2(3), citycode varchar2(3), ctarcode varchar2(3), placecode varchar2(3), plancode varchar2(4), streetcode varchar2(4), extrcode varchar2(4), sextcode varchar2(3), offname varchar2(120 char), postalcode varchar2(6), ifnsfl varchar2(4), terrifnsfl varchar2(4), ifnsul varchar2(4), terrifnsul varchar2(4), okato varchar2(11), oktmo varchar2(11), updatedate date, shortname varchar2(10 char), aolevel number(10), parentguid varchar2(36), aoid varchar2(36) not null, previd varchar2(36), nextid varchar2(36), code varchar2(17), plaincode varchar2(15), actstatus number(10), centstatus number(10), operstatus number(10), currstatus number(10), startdate date, enddate date, normdoc varchar2(36), livestatus number(1), cadnum varchar2(100), divtype number(1) ) tablespace fias_tbl; alter table ADDROBJ add constraint PK_ADDROBJ primary key (aoid) using index tablespace fias_idx; create bitmap index IDXBM_ADDROBJ_REGIONCODE on ADDROBJ(regioncode) tablespace fias_idx; create index IDX_ADDROBJ_AOGUID on ADDROBJ(aoguid) tablespace fias_idx; create index IDX_ADDROBJ_PARENTGUID on ADDROBJ(parentguid, actstatus, nextid, currstatus) tablespace fias_idx; comment on table ADDROBJ is 'Реестр образующих элементов'; comment on column ADDROBJ.AOGUID is 'Глобальный уникальный идентификатор адресного объекта'; comment on column ADDROBJ.FORMALNAME is 'Формализованное наименование'; comment on column ADDROBJ.REGIONCODE is 'Код региона'; comment on column ADDROBJ.AUTOCODE is 'Код автономии'; comment on column ADDROBJ.AREACODE is 'Код района'; comment on column ADDROBJ.CITYCODE is 'Код города'; comment on column ADDROBJ.CTARCODE is 'Код внутригородского района'; comment on column ADDROBJ.PLACECODE is 'Код населенного пункта'; comment on column ADDROBJ.PLANCODE is 'Код элемента планировочной структуры'; comment on column ADDROBJ.STREETCODE is 'Код улицы'; comment on column ADDROBJ.EXTRCODE is 'Код дополнительного адресообразующего элемента'; comment on column ADDROBJ.SEXTCODE is 'Код подчиненного дополнительного адресообразующего элемента'; comment on column ADDROBJ.OFFNAME is 'Официальное наименование'; comment on column ADDROBJ.POSTALCODE is 'Почтовый индекс'; comment on column ADDROBJ.IFNSFL is 'Код ИФНС ФЛ'; comment on column ADDROBJ.TERRIFNSFL is 'Код территориального участка ИФНС ФЛ'; comment on column ADDROBJ.IFNSUL is 'Код ИФНС ЮЛ'; comment on column ADDROBJ.TERRIFNSUL is 'Код территориального участка ИФНС ЮЛ'; comment on column ADDROBJ.OKATO is 'ОКАТО'; comment on column ADDROBJ.OKTMO is 'ОКТМО'; comment on column ADDROBJ.UPDATEDATE is 'Дата внесения (обновления) записи'; comment on column ADDROBJ.SHORTNAME is 'Краткое наименование типа объекта'; comment on column ADDROBJ.AOLEVEL is 'Уровень адресного объекта '; comment on column ADDROBJ.PARENTGUID is 'Идентификатор объекта родительского объекта'; comment on column ADDROBJ.AOID is 'Уникальный идентификатор записи. Ключевое поле'; comment on column ADDROBJ.PREVID is 'Идентификатор записи связывания с предыдушей исторической записью'; comment on column ADDROBJ.NEXTID is 'Идентификатор записи связывания с последующей исторической записью'; comment on column ADDROBJ.CODE is 'Код адресного элемента одной строкой с признаком актуальности из классификационного кода'; comment on column ADDROBJ.PLAINCODE is 'Код адресного элемента одной строкой без признака актуальности (последних двух цифр)'; comment on column ADDROBJ.ACTSTATUS is 'Статус последней исторической записи в жизненном цикле адресного объекта: 0 – Не последняя; 1 - Последняя;'; comment on column ADDROBJ.LIVESTATUS is 'Статус актуальности адресного объекта ФИАС на текущую дату: 0 – Не актуальный; 1 - Актуальный;'; comment on column ADDROBJ.CENTSTATUS is 'Статус центра'; comment on column ADDROBJ.OPERSTATUS is 'Статус действия над записью – причина появления записи'; comment on column ADDROBJ.CURRSTATUS is 'Статус актуальности КЛАДР 4 (последние две цифры в коде)'; comment on column ADDROBJ.STARTDATE is 'Начало действия записи'; comment on column ADDROBJ.ENDDATE is 'Окончание действия записи'; comment on column ADDROBJ.NORMDOC is 'Внешний ключ на нормативный документ'; comment on column ADDROBJ.CADNUM is 'Кадастровый номер'; comment on column ADDROBJ.DIVTYPE is 'Тип деления: 0 – не определено; 1 – муниципальное; 2 – административное;';
true
f5ce760a1615b1132c09f16b084489149ede43cb
SQL
SatrioBudiUtomo/stash
/db_himpunan.sql
UTF-8
5,564
3
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.8.5 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1:3307 -- Waktu pembuatan: 27 Jun 2020 pada 16.59 -- Versi server: 10.1.38-MariaDB -- Versi PHP: 7.3.2 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_himpunan` -- -- -------------------------------------------------------- -- -- Struktur dari tabel `tb_alumni` -- CREATE TABLE `tb_alumni` ( `id` int(11) NOT NULL, `nama` varchar(120) NOT NULL, `angkatan` varchar(4) NOT NULL, `tgl_lahir` date NOT NULL, `pekerjaan` varchar(30) NOT NULL, `foto` varchar(500) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `tb_alumni` -- INSERT INTO `tb_alumni` (`id`, `nama`, `angkatan`, `tgl_lahir`, `pekerjaan`, `foto`) VALUES (1, 'Satrio Budi Utomo', '2017', '2019-02-21', 'PNS', 'DSC_7961_copy2.jpg'), (2, 'Adjie Moekti', '2017', '2020-01-07', 'Barista', '2222.PNG'); -- -------------------------------------------------------- -- -- Struktur dari tabel `tb_anggota` -- CREATE TABLE `tb_anggota` ( `id` int(11) NOT NULL, `nama` varchar(120) NOT NULL, `nim` varchar(30) NOT NULL, `tgl_lahir` date NOT NULL, `jurusan` varchar(50) NOT NULL, `jabatan` varchar(100) NOT NULL, `no_telp` varchar(20) NOT NULL, `foto` varchar(500) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `tb_anggota` -- INSERT INTO `tb_anggota` (`id`, `nama`, `nim`, `tgl_lahir`, `jurusan`, `jabatan`, `no_telp`, `foto`) VALUES (1, 'Taufiq Suryono', '173140914111022', '2020-04-08', 'Sistem Informasi', 'Ketua Himpunan', '0813324568911', '1111.PNG'), (4, 'Satrio Budi Utomo', '173140914111035', '1999-03-21', 'Sistem Informasi', 'Wakil Ketua Himpunan', '089660478442', 'C360_2016-02-09-11-46-22-242.jpg'), (6, 'Adjie Moekti', '173140914111026', '1997-05-05', 'Sistem Informasi', 'Ketua Departemen Minat Bakat', '089660478442', 'avatar.jpg'), (7, 'Dinda Ayu Dea ', '173140914111027', '2020-02-18', 'Sistem Informasi', 'Sekretaris 1', '0813324568911', '001.PNG'); -- -------------------------------------------------------- -- -- Struktur dari tabel `tb_jabatan` -- CREATE TABLE `tb_jabatan` ( `id` int(11) NOT NULL, `nama` varchar(150) NOT NULL, `deskripsi` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `tb_jabatan` -- INSERT INTO `tb_jabatan` (`id`, `nama`, `deskripsi`) VALUES (3, 'Departemen Minat Bakat', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'); -- -------------------------------------------------------- -- -- Struktur dari tabel `tb_pemasukan` -- CREATE TABLE `tb_pemasukan` ( `id` int(11) NOT NULL, `tanggal` date NOT NULL, `keterangan` text NOT NULL, `nominal` bigint(30) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `tb_pemasukan` -- INSERT INTO `tb_pemasukan` (`id`, `tanggal`, `keterangan`, `nominal`) VALUES (1, '2020-06-16', 'Kas Advo', 20000), (2, '2020-06-09', 'Kas Puskominfo', 30000); -- -------------------------------------------------------- -- -- Struktur dari tabel `tb_pengeluaran` -- CREATE TABLE `tb_pengeluaran` ( `id` int(11) NOT NULL, `tanggal` date NOT NULL, `keterangan` text NOT NULL, `nominal` bigint(30) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `tb_pengeluaran` -- INSERT INTO `tb_pengeluaran` (`id`, `tanggal`, `keterangan`, `nominal`) VALUES (1, '2020-06-26', 'Cetak Banner', 35000); -- -- Indexes for dumped tables -- -- -- Indeks untuk tabel `tb_alumni` -- ALTER TABLE `tb_alumni` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `tb_anggota` -- ALTER TABLE `tb_anggota` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `tb_jabatan` -- ALTER TABLE `tb_jabatan` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `tb_pemasukan` -- ALTER TABLE `tb_pemasukan` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `tb_pengeluaran` -- ALTER TABLE `tb_pengeluaran` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT untuk tabel yang dibuang -- -- -- AUTO_INCREMENT untuk tabel `tb_alumni` -- ALTER TABLE `tb_alumni` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT untuk tabel `tb_anggota` -- ALTER TABLE `tb_anggota` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT untuk tabel `tb_jabatan` -- ALTER TABLE `tb_jabatan` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT untuk tabel `tb_pemasukan` -- ALTER TABLE `tb_pemasukan` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT untuk tabel `tb_pengeluaran` -- ALTER TABLE `tb_pengeluaran` 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
2721fbb2a3983e419d1e6df1a86e00993a59ad39
SQL
VKasyap/E-comerce-site
/SQL/ecommerce.sql
UTF-8
4,265
3.171875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.9.2 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1:3308 -- Generation Time: Jun 10, 2020 at 11:42 AM -- Server version: 8.0.18 -- PHP Version: 7.3.12 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: `ecommerce` -- -- -------------------------------------------------------- -- -- Table structure for table `contact` -- DROP TABLE IF EXISTS `contact`; CREATE TABLE IF NOT EXISTS `contact` ( `name` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, `email` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, `message` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- -------------------------------------------------------- -- -- Table structure for table `items` -- DROP TABLE IF EXISTS `items`; CREATE TABLE IF NOT EXISTS `items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, `price` int(11) NOT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- -- Dumping data for table `items` -- INSERT INTO `items` (`id`, `name`, `price`) VALUES (1, 'Apple iPhone X 64 GB', 70000), (2, 'Apple iPhone XS 64 GB', 88000), (3, 'Apple iPhone XR 64 GB', 53000), (4, 'Apple iPhone 11 64 GB', 70000), (5, 'Apple iPhone 11 Pro 64 GB', 110000), (6, 'Apple iPhone 11 Pro Max 64 GB', 130000); -- -------------------------------------------------------- -- -- Table structure for table `users` -- DROP TABLE IF EXISTS `users`; CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, `email` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, `password` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, `contact` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, `city` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, `address` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `name`, `email`, `password`, `contact`, `city`, `address`) VALUES (1, 'Priyanshu Arora', 'priyanshuarora9414@gmail.com', 'Abc@123', '9784715800', 'Nohar', 'nohar'); -- -------------------------------------------------------- -- -- Table structure for table `users_items` -- DROP TABLE IF EXISTS `users_items`; CREATE TABLE IF NOT EXISTS `users_items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `item_id` int(11) NOT NULL, `status` enum('Added to cart','Confirmed') CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, PRIMARY KEY (`id`), KEY `user_id` (`user_id`), KEY `item_id` (`item_id`) ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- -- Dumping data for table `users_items` -- INSERT INTO `users_items` (`id`, `user_id`, `item_id`, `status`) VALUES (3, 1, 1, 'Confirmed'), (4, 1, 2, 'Confirmed'), (5, 1, 2, 'Confirmed'), (6, 1, 2, 'Confirmed'), (7, 1, 1, 'Confirmed'), (8, 1, 1, 'Confirmed'), (9, 1, 2, 'Confirmed'), (10, 1, 2, 'Confirmed'); -- -- Constraints for dumped tables -- -- -- Constraints for table `users_items` -- ALTER TABLE `users_items` ADD CONSTRAINT `users_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `items` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, ADD CONSTRAINT `users_items_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; 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
5534ddba4c094d6fc842e7ffdddf422463694402
SQL
maduhu/Online-Shop
/dao/src/main/resources/create_and_populate_tables.sql
UTF-8
4,176
3.796875
4
[]
no_license
DROP TABLE IF EXISTS users; DROP TABLE IF EXISTS user_roles; DROP TABLE IF EXISTS products; DROP TABLE IF EXISTS orders; DROP TABLE IF EXISTS order_products; CREATE TABLE `users` ( `user_id` bigint(20) NOT NULL AUTO_INCREMENT, `user_address` varchar(255) NOT NULL, `user_age` varchar(255) DEFAULT NULL, `user_creation_date` bigint(20) NOT NULL, `user_email` varchar(255) DEFAULT NULL, `user_first_name` varchar(255) DEFAULT NULL, `user_last_name` varchar(255) DEFAULT NULL, `user_login` varchar(255) NOT NULL UNIQUE , `user_password` varchar(255) NOT NULL, `user_post_code` varchar(255) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `user_roles` ( `role_id` bigint(20) NOT NULL AUTO_INCREMENT, `user_role` varchar(255) DEFAULT NULL, `user_name` varchar(255) DEFAULT NULL, PRIMARY KEY (`role_id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `products` ( `product_id` bigint(20) NOT NULL AUTO_INCREMENT, `product_brand` varchar(255) NOT NULL, `product_creation_time` bigint(20) NOT NULL, `product_description` varchar(255) NOT NULL, `product_name` varchar(255) NOT NULL, `product_pic` varchar(255) DEFAULT NULL, `product_price` decimal(19,2) NOT NULL, PRIMARY KEY (`product_id`), UNIQUE KEY `uk_product_name_and_brand` (`product_name`,`product_brand`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `orders` ( `order_id` bigint(20) NOT NULL AUTO_INCREMENT, `order_creation_date` bigint(20) DEFAULT NULL, `order_status` varchar(255) DEFAULT NULL, `user_id` bigint(20) NOT NULL, PRIMARY KEY (`order_id`), CONSTRAINT `fk_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `order_products` ( `order_id` bigint(20) NOT NULL, `product_id` bigint(20) NOT NULL, CONSTRAINT `fk_product_id` FOREIGN KEY (`product_id`) REFERENCES `products` (`product_id`), CONSTRAINT `fk_order_id` FOREIGN KEY (`order_id`) REFERENCES `orders` (`order_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO products (product_id, product_name, product_brand, product_description, product_price, product_pic, product_creation_time) VALUES (1, 'revolver', 'colt', 'good gun for gunslinger', 20.5, 'product.png', 1438857361895), (2, 'rifle', 'colt', 'long range rifle', 40, 'product.png', 1438857361895), (3, 'shotgun', 'colt', 'short range rifle', 30.5, 'product.png', 1438857361895), (4, 'hat', 'unknown', 'protects from sun-hit', 2.5, 'product.png', 1438857361895); INSERT INTO users (user_id, user_login, user_password, user_email, user_first_name, user_last_name, user_post_code, user_address, user_age, user_creation_date) VALUES (1, 'admin', 'admin', 'admin@gmail.com', 'adm', 'in', '123', '123', '123', 1438857361895), (2, 'manager', 'manager', 'manager@gmail.com', 'mana', 'ger', '123', '123', '123', 1438857361895), (3, 'user', 'user', 'user@gmail.com', 'us', 'er', '123', '123', '123', 1438857361895), (4, 'user1', 'user1', 'user1@gmail.com', 'us', 'er', '123', '123', '123', 1438857361895), (5, 'user12', 'user12', 'user12@gmail.com', 'us', 'er', '123', '123', '123', 1438857361895), (6, 'user123', 'user123', 'user123@gmail.com', 'us', 'er', '123', '123', '123', 1438857361895); INSERT INTO user_roles (role_id, user_name, user_role) VALUES (1, 'admin', 'ROLE_ADMIN'), (2, 'manager', 'ROLE_MANAGER'), (3, 'user', 'ROLE_USER'), (4, 'user1', 'ROLE_USER'), (5, 'user12', 'ROLE_USER'), (6, 'user123', 'ROLE_USER'); INSERT INTO orders (order_id, user_id, order_status, order_creation_date) VALUES (1, 3, 'ACCEPTED', 1438857361895), (2, 3, 'ACCEPTED', 1438857361895), (3, 3, 'ACCEPTED', 1438857361895), (4, 4, 'ACCEPTED', 1438857361895), (5, 5, 'ACCEPTED', 1438857361895), (6, 5, 'ACCEPTED', 1438857361895), (7, 5, 'ACCEPTED', 1438857361895); INSERT INTO order_products (order_id, product_id) VALUES (1, 1), (1, 2), (1, 2), (1, 3), (1, 4), (2, 1), (2, 1), (2, 1), (2, 1), (3, 1), (3, 1), (3, 1), (3, 1), (3, 1), (3, 2), (3, 2), (3, 2), (3, 2), (4, 1), (4, 1), (4, 1), (5, 1), (6, 1), (7, 1), (7, 1);
true
63e0245dc8fc70b65b1328b0dcb0da6aea20cae5
SQL
hhc97/CSC343_project
/cleaned_data/q3a.sql
UTF-8
300
3.4375
3
[]
no_license
-- average suicide rates across countries with different government types set search_path to project343; select g.govType, avg(sRate) avgrates from SuicideRates rates, Country c, Government g where rates.cID = c.cID and c.govID = g.govID group by g.govType order by avg(sRate);
true
86c34fe40b136d3cfe3da39aa8e65c0852315003
SQL
VijayMVC/Synergy
/Programmability/Functions/Table-valued Functions/EXIT YEAR REALNESS.sql
UTF-8
6,928
3.703125
4
[]
no_license
SELECT T4.* ,CASE WHEN LCE.SIS_NUMBER IS NULL AND T4.[STATUS] = 'ELL' THEN 'NOT ON REPORT' ELSE '' END AS REPORT ,HISTORY.EXIT_REASON FROM ( SELECT SIS_NUMBER, ADMIN_DATE, TEST_NAME, PERFORMANCE_LEVEL, TOTAL,EVER_ELL ,CASE WHEN TOTAL >= 3 THEN 'EXIT YEAR 3+' WHEN TOTAL = 2 THEN 'EXIT YEAR 2' WHEN TOTAL = 1 AND EVER_ELL = 'N' THEN 'Never ELL' WHEN TOTAL = 1 THEN 'EXIT YEAR 1' ELSE 'ELL' END AS [STATUS] FROM ( SELECT SIS_NUMBER, ADMIN_DATE, TEST_NAME, PERFORMANCE_LEVEL,EVER_ELL ,T16 + T15 + T14 + T13 + T12 + T11 + T10 + T09 + T08 + T07 + T06 + T05 + T04 + T03 + T02 AS TOTAL FROM( SELECT SIS_NUMBER, ADMIN_DATE, TEST_NAME, PERFORMANCE_LEVEL,EVER_ELL ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4) > 2016 THEN 0 ELSE [2016] END AS T16 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4) > 2015 THEN 0 ELSE [2015] END AS T15 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2014 THEN 0 ELSE [2014] END AS T14 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2013 THEN 0 ELSE [2013] END AS T13 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2012 THEN 0 ELSE [2012] END AS T12 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2011 THEN 0 ELSE [2011] END AS T11 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2010 THEN 0 ELSE [2010] END AS T10 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2009 THEN 0 ELSE [2009] END AS T09 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2008 THEN 0 ELSE [2008] END AS T08 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2007 THEN 0 ELSE [2007] END AS T07 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2006 THEN 0 ELSE [2006] END AS T06 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2005 THEN 0 ELSE [2005] END AS T05 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2004 THEN 0 ELSE [2004] END AS T04 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2003 THEN 0 ELSE [2003] END AS T03 ,CASE WHEN LEFT(CAST(ADMIN_DATE AS DATE),4)> 2002 THEN 0 ELSE [2002] END AS T02 FROM ( SELECT STU.SIS_NUMBER, TEST.ADMIN_DATE, TEST_NAME, PERFORMANCE_LEVEL, IS_ELL ,CASE WHEN ELL.STUDENT_GU IS NOT NULL THEN 'Y' ELSE 'N' END AS EVER_ELL ,CASE WHEN [2016].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2016] ,CASE WHEN [2015].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2015] ,CASE WHEN [2014].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2014] ,CASE WHEN [2013].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2013] ,CASE WHEN [2012].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2012] ,CASE WHEN [2011].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2011] ,CASE WHEN [2010].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2010] ,CASE WHEN [2009].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2009] ,CASE WHEN [2008].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2008] ,CASE WHEN [2007].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2007] ,CASE WHEN [2006].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2006] ,CASE WHEN [2005].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2005] ,CASE WHEN [2004].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2004] ,CASE WHEN [2003].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2003] ,CASE WHEN [2002].STUDENT_GU IS NOT NULL AND IS_ELL = 0 THEN 1 ELSE 0 END AS [2002] FROM APS.PrimaryEnrollmentsAsOf(GETDATE()) AS PRIM LEFT JOIN APS.LCEEverELLStudentAsOf(GETDATE()) AS ELL ON PRIM.STUDENT_GU = ELL.STUDENT_GU INNER JOIN APS.LCELatestEvaluationAsOf(GETDATE()) AS TEST ON TEST.STUDENT_GU = PRIM.STUDENT_GU INNER JOIN rev.EPC_STU AS STU ON PRIM.STUDENT_GU = STU.STUDENT_GU /* 2002 3D95815E-93DB-4E7A-9741-4252AB7D1DAA 2003 A1A45208-69FC-4E58-99B3-7501E9108D70 2004 F4F41066-7955-45DF-AD43-24A1462BFDAD 2005 BE3706A7-1239-4DAE-A038-F9A949DAA041 2006 CC1DCB76-576C-4414-B4BA-323A26EC8EBE 2007 48ADBFD4-1987-4E7C-9C22-6FD91E8FE424 2008 94A5BA26-69AD-4ADB-80E0-7FEDB7E686C9 2009 E5D120A6-6A1C-4C42-B1F0-4ADB36DE27EF 2010 87F1A309-F058-43E4-B55B-EF9AE4602639 2011 3732B795-5856-430E-996D-B75E6475EC32 2012 9864A8F3-6130-4F95-86D6-860A517D38D1 2013 1E61EA89-3410-49F8-909B-1B749957EDDA 2014 26F066A3-ABFC-4EDB-B397-43412EDABC8B 2015 BCFE2270-A461-4260-BA2B-0087CB8EC26A 2016 F7D112F7-354D-4630-A4BC-65F586BA42EC */ LEFT JOIN APS.LatestPrimaryEnrollmentInYear('F7D112F7-354D-4630-A4BC-65F586BA42EC') AS [2016] ON PRIM.STUDENT_GU = [2016].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('BCFE2270-A461-4260-BA2B-0087CB8EC26A') AS [2015] ON PRIM.STUDENT_GU = [2015].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('26F066A3-ABFC-4EDB-B397-43412EDABC8B') AS [2014] ON PRIM.STUDENT_GU = [2014].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('1E61EA89-3410-49F8-909B-1B749957EDDA') AS [2013] ON PRIM.STUDENT_GU = [2013].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('9864A8F3-6130-4F95-86D6-860A517D38D1') AS [2012] ON PRIM.STUDENT_GU = [2012].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('3732B795-5856-430E-996D-B75E6475EC32') AS [2011] ON PRIM.STUDENT_GU = [2011].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('87F1A309-F058-43E4-B55B-EF9AE4602639') AS [2010] ON PRIM.STUDENT_GU = [2010].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('E5D120A6-6A1C-4C42-B1F0-4ADB36DE27EF') AS [2009] ON PRIM.STUDENT_GU = [2009].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('94A5BA26-69AD-4ADB-80E0-7FEDB7E686C9') AS [2008] ON PRIM.STUDENT_GU = [2008].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('48ADBFD4-1987-4E7C-9C22-6FD91E8FE424') AS [2007] ON PRIM.STUDENT_GU = [2007].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('CC1DCB76-576C-4414-B4BA-323A26EC8EBE') AS [2006] ON PRIM.STUDENT_GU = [2006].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('BE3706A7-1239-4DAE-A038-F9A949DAA041') AS [2005] ON PRIM.STUDENT_GU = [2005].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('F4F41066-7955-45DF-AD43-24A1462BFDAD') AS [2004] ON PRIM.STUDENT_GU = [2004].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('A1A45208-69FC-4E58-99B3-7501E9108D70') AS [2003] ON PRIM.STUDENT_GU = [2003].STUDENT_GU LEFT JOIN APS.LatestPrimaryEnrollmentInYear('3D95815E-93DB-4E7A-9741-4252AB7D1DAA') AS [2002] ON PRIM.STUDENT_GU = [2002].STUDENT_GU --TEST_NAME NOT IN ('SCREENER', 'WAPT', 'PRE-LAS') --AND STU.SIS_NUMBER = 970105607 ) AS T1 )AS T2 ) AS T3 ) AS T4 LEFT JOIN APS.LCEStudentsAndProvidersAsOf(GETDATE()) AS LCE ON T4.SIS_NUMBER = LCE.SIS_NUMBER LEFT JOIN ( SELECT * FROM( SELECT stu.SIS_NUMBER ,ROW_NUMBER() OVER (PARTITION BY ell.STUDENT_GU ORDER BY ENTRY_DATE DESC) AS RN ,ELL.ENTRY_DATE ,ELL.EXIT_DATE ,ELL.EXIT_REASON FROM rev.EPC_STU_PGM_ELL_HIS as ell INNER JOIN rev.epc_stu as stu on ell.STUDENT_GU = stu.STUDENT_GU ) AS T1 WHERE RN = 1 ) AS HISTORY ON HISTORY.SIS_NUMBER = T4.SIS_NUMBER ORDER BY ADMIN_DATE
true
bb09e298f96bc0394cd2250810a71eb7a8e0c8e0
SQL
yhd2964/youmaolu-weixin-app-api
/database/tables.sql
UTF-8
4,728
3.09375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.6.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Sep 27, 2017 at 06:14 AM -- Server version: 5.7.19 -- PHP Version: 7.1.8 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 */; -- -- Database: `yirimao` -- -- -------------------------------------------------------- -- -- Table structure for table `gifs` -- CREATE TABLE `gifs` ( `id` int(11) NOT NULL, `meta_id` int(11) NOT NULL, `image_url` varchar(255) DEFAULT NULL, `qiniu_url` varchar(255) DEFAULT NULL, `path` varchar(255) DEFAULT NULL, `spider_at` datetime DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `deleted_at` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `images` -- CREATE TABLE `images` ( `id` int(11) NOT NULL, `meta_id` int(11) NOT NULL, `image_url` varchar(255) DEFAULT NULL, `qiniu_url` varchar(255) DEFAULT NULL, `path` varchar(255) DEFAULT NULL, `spider_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `deleted_at` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `metas` -- CREATE TABLE `metas` ( `id` int(10) UNSIGNED NOT NULL, `card_id` varchar(255) DEFAULT '0', `card_category_id` varchar(255) DEFAULT '0', `activity_id` varchar(255) DEFAULT '0', `title` varchar(255) DEFAULT NULL, `overview` varchar(255) DEFAULT NULL, `web_url` varchar(255) DEFAULT NULL, `author` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `updated_at` datetime DEFAULT NULL, `deleted_at` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `products` -- CREATE TABLE `products` ( `id` int(11) NOT NULL, `meta_id` int(11) NOT NULL, `product_id` varchar(32) DEFAULT NULL, `product_url` varchar(255) DEFAULT NULL, `image_url` varchar(255) DEFAULT NULL, `qiniu_url` varchar(255) DEFAULT NULL, `path` varchar(255) DEFAULT NULL, `spider_at` timestamp NULL DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `deleted_at` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `videos` -- CREATE TABLE `videos` ( `id` int(11) NOT NULL, `meta_id` int(11) NOT NULL, `video_url` varchar(255) DEFAULT NULL, `qiniu_url` varchar(255) DEFAULT NULL, `path` varchar(255) DEFAULT NULL, `spider_at` timestamp NULL DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `deleted_at` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Indexes for dumped tables -- -- -- Indexes for table `gifs` -- ALTER TABLE `gifs` ADD PRIMARY KEY (`id`); -- -- Indexes for table `images` -- ALTER TABLE `images` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `meta_id` (`meta_id`), ADD KEY `mate_id` (`meta_id`); -- -- Indexes for table `metas` -- ALTER TABLE `metas` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `card_id` (`card_id`); -- -- Indexes for table `products` -- ALTER TABLE `products` ADD PRIMARY KEY (`id`); -- -- Indexes for table `videos` -- ALTER TABLE `videos` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `gifs` -- ALTER TABLE `gifs` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=373; -- -- AUTO_INCREMENT for table `images` -- ALTER TABLE `images` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=434; -- -- AUTO_INCREMENT for table `metas` -- ALTER TABLE `metas` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1550; -- -- AUTO_INCREMENT for table `products` -- ALTER TABLE `products` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=373; -- -- AUTO_INCREMENT for table `videos` -- ALTER TABLE `videos` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=373; /*!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
3c1155a79a2c76d88033731ca80b1451884571f8
SQL
ISpectruM/Java_DB_Fundamentals
/A_Databases_Basics_MySQL/D_Data_Aggregation/Exercises/p8_min_deposit_charge.sql
UTF-8
201
2.671875
3
[]
no_license
SELECT deposit_group, magic_wand_creator, MIN(deposit_charge) AS 'min_deposit_charge' FROM wizzard_deposits GROUP BY deposit_group,magic_wand_creator ORDER BY magic_wand_creator ASC, deposit_group ASC;
true
73bd968304d80c8126f308a01c6ce6a9bc62f278
SQL
johnk2280/MySQL_Relational_Database_Basics
/Course_project/j4j_selects_and_views.sql
UTF-8
3,797
4.28125
4
[]
no_license
-- 6. скрипты характерных выборок (включающие группировки, JOIN'ы, вложенные таблицы); -- 7. представления (минимум 2); USE j4j; -- вывести количество запросов для каждого пользователя SELECT u.id, u.first_name, u.last_name, tbl.total_count FROM users u JOIN (SELECT from_user_id, COUNT(*) total_count FROM requests r GROUP BY from_user_id ) tbl ON u.id = tbl.from_user_id ORDER BY tbl.total_count DESC; -- вывести количество вакансий для каждого города по всем провайдерам SELECT tbl.location, COUNT(*) total_cnt FROM ( SELECT hd.location FROM hh_data hd UNION ALL SELECT sd.location FROM sj_data sd UNION ALL SELECT gd.location FROM gj_data gd UNION ALL SELECT hd2.location FROM hc_data hd2) tbl GROUP BY tbl.location ORDER BY total_cnt DESC; -- сколько вакансий получил каждый пользователь SELECT u.id, u.first_name, u.last_name, tbl2.requests_number, tbl.responses_number FROM users u JOIN (SELECT to_user_id, COUNT(*) responses_number FROM responses r GROUP BY to_user_id) tbl ON u.id = tbl.to_user_id JOIN (SELECT from_user_id, COUNT(*) requests_number FROM requests r2 GROUP BY from_user_id ) tbl2 ON u.id = tbl2.from_user_id ORDER BY tbl2.requests_number DESC; -- вывести количество представленных компаний по городам SELECT location, COUNT(company_name) cnt FROM ( SELECT location, company_name FROM hh_data UNION ALL SELECT location, company_name FROM hc_data UNION ALL SELECT location, company_name FROM sj_data UNION ALL SELECT location, company_name FROM gj_data ) tbl GROUP BY location ORDER BY cnt DESC; -- вывести количество вакансий по опыту работы SELECT expirience, COUNT(*) cnt FROM ( SELECT expirience FROM hh_data UNION ALL SELECT expirience FROM sj_data UNION ALL SELECT expirience FROM gj_data UNION ALL SELECT expirience FROM hc_data) tbl GROUP BY expirience ORDER BY cnt DESC; -- выбираем количество ответов на каждый запрос SELECT request_id, COUNT(*) FROM responses r GROUP BY request_id; -- представление, которое выводит все вакансии на все запросы DROP VIEW IF EXISTS vacancy_tbl; CREATE VIEW vacancy_tbl AS SELECT u.first_name, u.last_name, tbl4.company_name, tbl4.vacancy_name, tbl4.location, tbl4.expirience, tbl4.skills, tbl4.salary FROM users u JOIN ( SELECT to_user_id, company_name, vacancy_name, location, expirience, skills, salary FROM hh_data UNION SELECT to_user_id, company_name, vacancy_name, location, expirience, skills, salary FROM sj_data UNION SELECT to_user_id, company_name, vacancy_name, location, expirience, skills, salary FROM gj_data UNION SELECT to_user_id, company_name, vacancy_name, location, expirience, skills, salary FROM hc_data) tbl4 ON u.id = tbl4.to_user_id; -- вызываю представление SELECT * FROM vacancy_tbl; -- представление выводит количество городов в котором размещены вакансии комппании DROP VIEW IF EXISTS company_vacancies; CREATE VIEW company_vacancies AS SELECT company_name, COUNT(location) number_of_cities FROM ( SELECT company_name, location FROM hh_data UNION ALL SELECT company_name, location FROM sj_data UNION ALL SELECT company_name, location FROM gj_data UNION ALL SELECT company_name, location FROM hc_data) tbl5 GROUP BY company_name ORDER BY number_of_cities DESC; SELECT * FROM company_vacancies;
true
bdefe43e92f6c4a79dc6b2b2d7db3ba0994499d0
SQL
S031/MetaStack
/src/S031.MetaStack.Core.ORM.SQLite/SqlScripts/GetTableSchema.sql
UTF-8
483
4.0625
4
[]
no_license
select * from sqlite_master where tbl_name = @tableName and type = 'table'; select * from pragma_table_info(@tableName); select * from pragma_foreign_key_list(@tableName); SELECT m.name as TableName, il.name as IndexName, il.[unique], ii.seqno as Position, ii.name as ColumnName FROM sqlite_master AS m, pragma_index_list(m.name) AS il, pragma_index_info(il.name) AS ii WHERE m.type='table' and m.name = @tableName ORDER BY il.name, ii.seqno;
true
68c38f1f753cca47bd46f84f8a3f83dbf94686d9
SQL
JoseVte/Web-Grupo-Ant-n-Ajax
/SQL/crearBD_MySQL.sql
UTF-8
7,412
3.6875
4
[]
no_license
CREATE DATABASE IF NOT EXISTS base_datos_dss; use base_datos_dss; CREATE TABLE Gasto ( Identificador INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, NombreOperacion VARCHAR(20) NOT NULL , Coste DOUBLE NOT NULL , PRIMARY KEY(Identificador)); CREATE TABLE Proveedor ( NIF VARCHAR(9) NOT NULL , Nombre VARCHAR(20) NOT NULL , Apellidos VARCHAR(255) NULL , Direccion VARCHAR(255) NOT NULL , Telefono VARCHAR(9) NOT NULL , Email VARCHAR(255) NOT NULL , PRIMARY KEY(NIF)); CREATE TABLE Ingreso ( Identificador INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, NombreOperacion VARCHAR(20) NOT NULL , Coste DOUBLE NOT NULL , PRIMARY KEY(Identificador)); CREATE TABLE Servicio ( idServicio INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Nombre VARCHAR(45) NOT NULL , Descripcion VARCHAR(255) NULL , Precio DOUBLE NOT NULL, PRIMARY KEY(idServicio)); CREATE TABLE Usuario ( NIF VARCHAR(9) NOT NULL , Nombre VARCHAR(20) NOT NULL , Apellidos VARCHAR(255) BINARY NULL , NvAcceso VARCHAR(20) NOT NULL DEFAULT "Minimo" , Pass VARCHAR(128) NOT NULL , Direccion VARCHAR(255) NOT NULL , Telefono VARCHAR(9) NOT NULL , Email VARCHAR(255) NOT NULL , PRIMARY KEY(NIF)); CREATE TABLE Calendario_Eventos ( Fecha DATE NOT NULL , Evento VARCHAR(20) NOT NULL , Descripcion VARCHAR(255) NULL , PRIMARY KEY(Fecha, Evento)); CREATE TABLE Cliente ( NIF VARCHAR(9) NOT NULL , Nombre VARCHAR(20) NOT NULL , Apellidos VARCHAR(255) NULL , Direccion VARCHAR(255) NOT NULL , Telefono VARCHAR(9) NOT NULL , Email VARCHAR(255) NOT NULL , PRIMARY KEY(NIF)); CREATE TABLE Informes_gasto ( Gasto_Identificador INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, RutaFichero VARCHAR(255) NOT NULL , Descripcion VARCHAR(255) NULL , Fecha DATE NOT NULL , Tipo VARCHAR(20) NOT NULL , PRIMARY KEY(Gasto_Identificador) , INDEX Informes_FKIndex1(Gasto_Identificador), FOREIGN KEY(Gasto_Identificador) REFERENCES Gasto(Identificador) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE Informes_ingreso ( Ingreso_Identificador INTEGER UNSIGNED NOT NULL , RutaFichero VARCHAR(255) NOT NULL , Descripcion VARCHAR(255) NULL , Fecha DATE NOT NULL , Tipo VARCHAR(20) NOT NULL , PRIMARY KEY(Ingreso_Identificador) , INDEX Informes_ingreso_FKIndex1(Ingreso_Identificador), FOREIGN KEY(Ingreso_Identificador) REFERENCES Ingreso(Identificador) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE Reunion ( Usuario_NIF VARCHAR(9) NOT NULL , Calendario_Eventos_Fecha DATE NOT NULL , Calendario_Eventos_Evento VARCHAR(20) NOT NULL , PRIMARY KEY(Usuario_NIF, Calendario_Eventos_Fecha, Calendario_Eventos_Evento) , INDEX Usuario_has_Calendario_FKIndex1(Usuario_NIF) , INDEX Usuario_has_Calendario_FKIndex2(Calendario_Eventos_Fecha, Calendario_Eventos_Evento), FOREIGN KEY(Usuario_NIF) REFERENCES Usuario(NIF) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(Calendario_Eventos_Fecha, Calendario_Eventos_Evento) REFERENCES Calendario_Eventos(Fecha, Evento) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE Pedido ( Identificador INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Proveedor_NIF VARCHAR(9) NOT NULL , Cliente_NIF VARCHAR(9) NOT NULL , PRIMARY KEY(Identificador) , INDEX Pedido_FKIndex1(Cliente_NIF) , INDEX Pedido_FKIndex2(Proveedor_NIF), FOREIGN KEY(Cliente_NIF) REFERENCES Cliente(NIF) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(Proveedor_NIF) REFERENCES Proveedor(NIF) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE LineaServicio ( idLineaServicio INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Servicio_idServicio INTEGER UNSIGNED NOT NULL , Pedido_Identificador INTEGER UNSIGNED NOT NULL , PRIMARY KEY(idLineaServicio) , INDEX LineaServicio_FKIndex1(Servicio_idServicio) , INDEX LineaServicio_FKIndex2(Pedido_Identificador), FOREIGN KEY(Servicio_idServicio) REFERENCES Servicio(idServicio) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(Pedido_Identificador) REFERENCES Pedido(Identificador) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE Presupuesto ( idPresupuesto INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Pedido_Identificador INTEGER UNSIGNED NOT NULL , PRIMARY KEY(idPresupuesto) , INDEX Presupuesto_FKIndex1(Pedido_Identificador), FOREIGN KEY(Pedido_Identificador) REFERENCES Pedido(Identificador) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE Informes_pedido ( Pedido_Identificador INTEGER UNSIGNED NOT NULL , RutaFichero VARCHAR(255) NOT NULL , Descripcion VARCHAR(255) NULL , Fecha DATE NOT NULL , Tipo VARCHAR(20) NOT NULL , PRIMARY KEY(Pedido_Identificador) , INDEX Informes_pedido_FKIndex1(Pedido_Identificador), FOREIGN KEY(Pedido_Identificador) REFERENCES Pedido(Identificador) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE Albaran ( idAlbaran INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Pedido_Identificador INTEGER UNSIGNED NOT NULL , PRIMARY KEY(idAlbaran) , INDEX Albaran_FKIndex3(Pedido_Identificador), FOREIGN KEY(Pedido_Identificador) REFERENCES Pedido(Identificador) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE Factura ( idFactura INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Pedido_Identificador INTEGER UNSIGNED NOT NULL , PRIMARY KEY(idFactura) , INDEX Factura_FKIndex1(Pedido_Identificador), FOREIGN KEY(Pedido_Identificador) REFERENCES Pedido(Identificador) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE Informes_presupuesto ( Presupuesto_idPresupuesto INTEGER UNSIGNED NOT NULL , RutaFichero VARCHAR(255) NOT NULL , Descripcion VARCHAR(255) NULL , Fecha DATE NOT NULL , Tipo VARCHAR(20) NOT NULL , PRIMARY KEY(Presupuesto_idPresupuesto) , INDEX Informes_presupuesto_FKIndex1(Presupuesto_idPresupuesto), FOREIGN KEY(Presupuesto_idPresupuesto) REFERENCES Presupuesto(idPresupuesto) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE Informes_albaran ( Albaran_idAlbaran INTEGER UNSIGNED NOT NULL , RutaFichero VARCHAR(255) NOT NULL , Descripcion VARCHAR(255) NULL , Fecha DATE NOT NULL , Tipo VARCHAR(20) NOT NULL , PRIMARY KEY(Albaran_idAlbaran) , INDEX Informes_albaran_FKIndex1(Albaran_idAlbaran), FOREIGN KEY(Albaran_idAlbaran) REFERENCES Albaran(idAlbaran) ON DELETE CASCADE ON UPDATE CASCADE); CREATE TABLE Informes_factura ( Factura_idFactura INTEGER UNSIGNED NOT NULL , RutaFichero VARCHAR(255) NOT NULL , Descripcion VARCHAR(255) NULL , Fecha DATE NOT NULL , Tipo VARCHAR(20) NOT NULL , PRIMARY KEY(Factura_idFactura) , INDEX Informes_factura_FKIndex1(Factura_idFactura), FOREIGN KEY(Factura_idFactura) REFERENCES Factura(idFactura) ON DELETE CASCADE ON UPDATE CASCADE); GRANT USAGE ON *.* TO 'dss'@'localhost' IDENTIFIED BY PASSWORD '*DB5F1E56DEBB0C2C4377D1936FFC03D819AFC668'; GRANT ALL PRIVILEGES ON `base_datos_dss`.* TO 'dss'@'localhost' WITH GRANT OPTION; INSERT INTO `base_datos_dss`.`Usuario` (`NIF`, `Nombre`, `Apellidos`, `NvAcceso`, `Pass`, `Direccion`, `Telefono`, `Email`) VALUES ('00000000A', 'root', NULL, 'Maximo', SHA1('root'), 'c/root', '666999666', 'root@root.org');
true
7aec2bdade0ba954c2a809f4f15ae3948ac9c3d1
SQL
saranshgarg12b/sfmcdev
/retrieve/MPTrainingInstance/_ParentBU_/query/591cfbeb-29d8-41e8-b6e3-ad3407304db2.query-meta.sql
UTF-8
730
4.09375
4
[]
no_license
SELECT T1.SubscriberKey, T1.SubscriberID, T1.IsUnique, T1.EventDate AS EventDateClick, T2.EmailAddress, CASE WHEN T1.SubscriberKey LIKE '003%' THEN 'TRUE' ELSE 'FALSE' END 'IsContact', CASE WHEN T1.SubscriberKey LIKE '00Q%' THEN 'TRUE' ELSE 'FALSE' END 'IsLead' FROM _Click T1 INNER JOIN _Subscribers T2 ON T1.SubscriberKey = T2.SubscriberKey WHERE IsUnique = 'True' AND ( T1.SubscriberKey IN ( SELECT Id FROM [Contact_Salesforce_1] ) OR T1.SubscriberKey IN ( SELECT Id FROM [Lead_Salesforce_1] ) )
true
6ee087edcbba25e8b3cf2f8541d15c20e38cb0b7
SQL
MiryalaNarayanaReddy/Data_and_Applications
/project/phase-4/dna_project/Coding/dump.sql
UTF-8
20,782
4
4
[ "MIT" ]
permissive
-- DATABASE FOR APARTMENT MANAGEMENT SYSTEM -- AUTHOR MIRYALA NARAYANA REDDY @ 2021 OCTOBER -- SQL COMMANDS TO CREATE DATABASE TABLES AND SAMPLE DATA VALUES INSERTED INTO IT. -- database creation DROP DATABASE IF EXISTS APARTMENT_MANAGEMENT_SYSTEM; CREATE SCHEMA APARTMENT_MANAGEMENT_SYSTEM; USE APARTMENT_MANAGEMENT_SYSTEM; -- Apartment complex DROP TABLE IF EXISTS APARTMENT_COMPLEX; CREATE TABLE APARTMENT_COMPLEX ( Block_name VARCHAR(30) NOT NULL, Block_manager_id BIGINT NOT NULL, Block_manager_name VARCHAR(30) NOT NULL, Email_id VARCHAR(50) NOT NULL, PRIMARY KEY (Block_name), UNIQUE KEY (Block_manager_id), UNIQUE KEY (Email_id) ); LOCK TABLES APARTMENT_COMPLEX WRITE; INSERT INTO APARTMENT_COMPLEX VALUES ('A',2020010001,'Narayana','narayana@gmail.com'), ('B',2020010002,'Animesh','animesh@gmail.com'), ('C',2020010003,'Govind sign','govind@gmail.com'), ('D',2020010004,'charles dickens','charles@gmail.com'); UNLOCK TABLES; -- Block_color DROP TABLE IF EXISTS BLOCK_COLOR; CREATE TABLE BLOCK_COLOR ( Block_name VARCHAR(30) NOT NULL, Block_color VARCHAR(20) NOT NULL, PRIMARY KEY (Block_name), CONSTRAINT BLOCK_COLOR_fk_1 FOREIGN KEY (Block_name) REFERENCES APARTMENT_COMPLEX (Block_name) ); LOCK TABLES BLOCK_COLOR WRITE; INSERT INTO BLOCK_COLOR VALUES ('A','pinkish white'), ('B','bluish white'); UNLOCK TABLES; -- Block_manager_phno DROP TABLE IF EXISTS BLOCK_MANAGER_PHNO; CREATE TABLE BLOCK_MANAGER_PHNO ( Block_manager_id BIGINT NOT NULL, Block_manager_phno BIGINT NOT NULL, PRIMARY KEY (Block_manager_id , Block_manager_phno), CONSTRAINT BLOCK_MANAGER_PHNO_fk_1 FOREIGN KEY (Block_manager_id) REFERENCES APARTMENT_COMPLEX (Block_manager_id) ); LOCK TABLES BLOCK_MANAGER_PHNO WRITE; INSERT INTO BLOCK_MANAGER_PHNO VALUES (2020010001,1122334455), (2020010001,1234567890), (2020010004,1212343456); UNLOCK TABLES; -- Apartment DROP TABLE IF EXISTS APARTMENT; CREATE TABLE APARTMENT ( Apartment_number INT NOT NULL, Block_name VARCHAR(30) NOT NULL, Owner_id BIGINT, Apartment_size FLOAT NOT NULL, Monthly_maintenance_charges FLOAT NOT NULL, PRIMARY KEY (Block_name , Apartment_number), KEY (Owner_id), CONSTRAINT APARTMENT_fk_1 FOREIGN KEY (Block_name) REFERENCES APARTMENT_COMPLEX (Block_name) ); LOCK TABLES APARTMENT WRITE; INSERT INTO APARTMENT VALUES ('101','A',202010101,1200,1500), ('102','A',202010202,1200,1500), ('103','A',202010301,1200,1500), ('104','A',202010401,1500,2000), ('105','A',202010501,1500,2000), ('201','A',202020101,1200,1500), ('202','A',202020201,1200,1500), ('203','A',202020301,1200,1500), ('204','A',202020401,1500,2000), ('205','A',202020501,1500,2000), -- 17000 MMC ('101','B',202010101,1200,1500), ('102','B',202010201,1200,1500), ('103','B',202010301,1200,1500), ('104','B',202010402,1500,2000), ('105','B',202010501,1500,2000), ('201','B',202020101,1200,1500), ('202','B',202020201,1200,1500), ('203','B',202020301,1200,1500), ('204','B',202020401,1500,2000), ('205','B',202020501,1500,2000), -- 17000 MMC ('101','C',202010101,1200,1500), ('102','C',202010201,1200,1500), ('103','C',202010301,1200,1500), ('104','C',202010401,1500,2000), ('105','C',202010501,1500,2000), ('201','C',202020101,1200,1500), ('202','C',202020201,1200,1500), ('203','C',202020301,1200,1500), ('204','C',202020401,1500,2000), ('205','C',202020501,1500,2000); -- 1700 MMC UNLOCK TABLES; -- Owners DROP TABLE IF EXISTS OWNERS; CREATE TABLE OWNERS ( Owner_name VARCHAR(30) NOT NULL, Owner_id BIGINT NOT NULL, Block_name VARCHAR(30) NOT NULL, Email_id VARCHAR(50) NOT NULL, Owner_since DATETIME NOT NULL, PRIMARY KEY (Owner_id , Block_name), KEY (Email_id), CONSTRAINT OWNERS_fk_1 FOREIGN KEY (Owner_id) REFERENCES APARTMENT (Owner_id), CONSTRAINT OWNERS_fk_2 FOREIGN KEY (Block_name) REFERENCES APARTMENT_COMPLEX (Block_name) ); LOCK TABLES OWNERS WRITE; INSERT INTO OWNERS VALUES -- A ('john',202010101,'A','johnny@gmail.com','2020-10-8 18:5:39'), ('Arun',202010202,'A','arun@gmail.com','2020-10-09 20:27:35' ), ('Sruthi',202010301,'A','sruthi@gmail.com','2020-09-21 12:03:32'), ('sai tej',202010401,'A','saitej@gmail.com','2020-10-12 10:03:3'), ('Mahesh Reddy',202010501,'A','mahesh123@gmail.com','2020-10-11 12:33:32'), ('walter',202020101,'A','walter@gmail.com','2020-09-19 15:43:57'), ('Harish chandra',202020201,'A','harishchandra@gmail.com','2020-10-5 9:25:2'), ('Rama Reddy',202020301,'A','Rama_reddy@gmail.com','2020-09-30 13:13:29'), ('Tanish lad',202020401,'A','Tanishlad@gmail.com','2020-10-5 15:5:52'), ('Krishna Reddy',202020501,'A','krishnareddy@gmail.com','2020-10-2 10:17:19'), -- B ('Ravi kiran',202010101,'B','ravika@gmail.com','2020-10-2 18:5:39'), ('Rajan',202010201,'B','rajan@gmail.com','2020-10-02 20:27:35' ), ('Laxman Roa',202010301,'B','laxmanrao@gmail.com','2020-09-21 12:03:32'), ('Krish',202010402,'B','krish@gmail.com','2020-10-10 10:00:05'), ('Uday',202010501,'B','uday@gmail.com','2020-10-4 11:00:05'), ('Gopal verma',202020101,'B','gopalverma@gmail.com','2020-10-3 18:55:39'), ('Rajan',202020201,'B','rajan@gmail.com','2020-10-03 20:47:35' ), ('B.Ganesh',202020301,'B','ganesh.b@gmail.com','2020-10-10 15:40:45'), ('Tarun',202020401,'B','Tarun@gmail.com','2020-10-4 10:36:39'), ('Chandu',202020501,'B','Chandu@gmail.com','2020-10-4 10:47:35' ), -- C ('Sravani',202010101,'C','sravani@gmail.com','2020-10-8 18:5:39'), ('Eshwar',202010201,'C','Eswar@gmail.com','2020-10-6 20:27:35' ), ('Kamal',202010301,'C','kamal@gmail.com','2020-09-21 13:03:32'), ('Narayana Reddy',202010401,'C','narayanareddy@gmail.com','2020-10-5 10:20:05'), ('channa Reddy',202010501,'C','channareddy@gmail.com','2020-10-4 11:40:05'), ('Balaramkrishna',202020101,'C','balaramkrishna@gmail.com','2020-10-5 18:45:39'), ('Akil',202020201,'C','akil@gmail.com','2020-10-05 19:47:35' ), ('Alpan raj',202020301,'C','alpanraj@gmail.com','2020-10-11 10:40:45'), ('Gopal',202020401,'C','gopal3@gmail.com','2020-10-9 10:07:05'), ('Arjun',202020501,'C','arjun@gmail.com','2020-10-5 11:47:35' ); UNLOCK TABLES; -- Owner_phno DROP TABLE IF EXISTS OWNER_PHNO; CREATE TABLE OWNER_PHNO ( Block_name VARCHAR(30) NOT NULL, Owner_id BIGINT NOT NULL, Owner_phno BIGINT NOT NULL, PRIMARY KEY (Owner_id , Block_name , Owner_phno), CONSTRAINT OWNER_PHNO_fk_1 FOREIGN KEY (Block_name) REFERENCES APARTMENT_COMPLEX (Block_name), CONSTRAINT OWNER_PHNO_fk_2 FOREIGN KEY (Owner_id) REFERENCES OWNERS (Owner_id) ); LOCK TABLES OWNER_PHNO WRITE; INSERT INTO OWNER_PHNO VALUES ('A',202010202,1122334455), ('A',202010202,1234567890), ('B',202010402,1212343456); UNLOCK TABLES; -- Tenant DROP TABLE IF EXISTS TENANT; CREATE TABLE TENANT ( Tenant_name VARCHAR(30) NOT NULL, Block_name VARCHAR(30) NOT NULL, Owner_id BIGINT NOT NULL, Apartment_number INT NOT NULL, Email_id VARCHAR(50) NOT NULL, Tenant_since DATETIME NOT NULL, PRIMARY KEY (Block_name , Owner_id), KEY (Email_id), CONSTRAINT TENANT_fk_1 FOREIGN KEY (Owner_id) REFERENCES OWNERS (Owner_id), CONSTRAINT TENANT_fk_2 FOREIGN KEY (Block_name) REFERENCES APARTMENT_COMPLEX (Block_name) ); LOCK TABLES TENANT WRITE; INSERT INTO TENANT VALUES ('Ravi','A',202010202,102,'ravi@outlook.com','2020-10-20 7:22:05' ), ('Banu','B',202010402,104,'Banu@yahoo.com','2020-10-20 7:23:39'); UNLOCK TABLES; -- Tenant_phno DROP TABLE IF EXISTS TENANT_PHNO; CREATE TABLE TENANT_PHNO ( Block_name VARCHAR(30) NOT NULL, Owner_id BIGINT NOT NULL, Tenant_phno BIGINT NOT NULL, PRIMARY KEY (Owner_id , Block_name , Tenant_phno), CONSTRAINT TENANT_PHNO_fk_1 FOREIGN KEY (Block_name) REFERENCES APARTMENT_COMPLEX (Block_name), CONSTRAINT TENANT_PHNO_fk_2 FOREIGN KEY (Owner_id) REFERENCES OWNERS (Owner_id) ); LOCK TABLES TENANT_PHNO WRITE; INSERT INTO TENANT_PHNO VALUES ('A',202010202,1111222233), ('B',202010402,2223336660), ('B',202010402,1234123498); UNLOCK TABLES; -- MMC DROP TABLE IF EXISTS MMC; CREATE TABLE MMC ( Block_name VARCHAR(30) NOT NULL, Apartment_number INT NOT NULL, paid_upto DATE NOT NULL, PRIMARY KEY (Block_name , Apartment_number), CONSTRAINT MMC_fk_1 FOREIGN KEY (Block_name , Apartment_number) REFERENCES APARTMENT (Block_name , Apartment_number) ); LOCK TABLES MMC WRITE; INSERT INTO MMC VALUES ('A',101,'2021-11-1'), ('A',102,'2021-12-1'), ('A',103,'2021-12-1'), ('A',104,'2021-10-1'), ('A',105,'2021-12-1'), ('A',201,'2021-12-1'), ('A',202,'2021-10-1'), ('A',203,'2021-12-1'), ('A',204,'2021-10-1'), ('A',205,'2021-12-1'), ('B',101,'2021-10-1'), ('B',102,'2021-12-1'), ('B',103,'2021-12-1'), ('B',104,'2021-10-1'), ('B',105,'2021-12-1'), ('B',201,'2021-12-1'), ('B',202,'2021-11-1'), ('B',203,'2021-12-1'), ('B',204,'2021-11-1'), ('B',205,'2021-12-1'), ('C',101,'2021-10-1'), ('C',102,'2021-11-1'), ('C',103,'2021-11-1'), ('C',104,'2021-10-1'), ('C',105,'2022-1-1'), ('C',201,'2021-12-1'), ('C',202,'2021-10-1'), ('C',203,'2021-12-1'), ('C',204,'2021-10-1'), ('C',205,'2022-4-1'); UNLOCK TABLES; -- committee tenure DROP TABLE IF EXISTS COMMITTEE_TENURE; CREATE TABLE COMMITTEE_TENURE ( Committee_id BIGINT NOT NULL, Perid_start DATE NOT NULL, Period_end DATE, PRIMARY KEY (Committee_id) ); LOCK TABLES COMMITTEE_TENURE WRITE; INSERT INTO COMMITTEE_TENURE VALUES (1,'2020-10-01',NULL); UNLOCK TABLES; -- committee DROP TABLE IF EXISTS COMMITEE; CREATE TABLE COMMITTEE ( Committee_id BIGINT NOT NULL, Member_name VARCHAR(30) NOT NULL, Email_id VARCHAR(50) NOT NULL, Member_id BIGINT NOT NULL, PRIMARY KEY (Committee_id , Member_id), KEY (Email_id) ); LOCK TABLES COMMITTEE WRITE; INSERT INTO COMMITTEE VALUES (1,'Vigneshwar','vigneshwar1@yahoo.com',2020101), -- member id = committee_id member_number (1,'Aryan','Aryan12@gmail.com',2020102); UNLOCK TABLES; -- committee phno DROP TABLE IF EXISTS COMMITTEE_PHNO; CREATE TABLE COMMITTEE_PHNO ( Committee_id BIGINT NOT NULL, Member_id BIGINT NOT NULL, Member_phno BIGINT NOT NULL, PRIMARY KEY (Committee_id , Member_id , Member_phno) ); LOCK TABLES COMMITTEE_PHNO WRITE; INSERT INTO COMMITTEE_PHNO VALUES (1,2020101,1234512345), (1,2020102,0987098712); UNLOCK TABLES; -- accounts DROP TABLE IF EXISTS ACCOUNTS; CREATE TABLE ACCOUNTS ( Committee_id BIGINT NOT NULL, Period DATE NOT NULL, Income FLOAT NOT NULL, Total_expenditure FLOAT NOT NULL, PRIMARY KEY (Committee_id,Period) ); LOCK TABLES ACCOUNTS WRITE; INSERT INTO ACCOUNTS VALUES (1,'2020-10-31',51000,51000), (1,'2020-11-30',51000,30000), (1,'2020-12-31',51000,52000), (1,'2021-01-31',51000,46000), (1,'2021-02-28',51000,30000), (1,'2021-03-31',51000,30000), (1,'2021-04-30',51000,30000), (1,'2021-05-31',51000,30000), (1,'2021-06-30',51000,30000), (1,'2021-07-31',51000,30000), (1,'2021-08-31',51000,42000), (1,'2021-09-30',51000,30000); UNLOCK TABLES; -- visitor DROP TABLE IF EXISTS VISITOR; CREATE TABLE VISITOR ( Visitor_number BIGINT NOT NULL AUTO_INCREMENT, Visitor_name VARCHAR(30), Visit_time DATETIME NOT NULL, Vistor_phno BIGINT NOT NULL, Purpose VARCHAR(255), PRIMARY KEY (Visitor_number) ); LOCK TABLES VISITOR WRITE; INSERT INTO VISITOR (Visitor_name, Visit_time, Vistor_phno, Purpose) VALUES ('vijay','2020-10-20 9:00:32',1111262233,'I am a relative of person in block A apartment number 102'), ('Akash','2020-10-20 9:15:12',1111222233,'Wanted to know if you have any employment for me.'); UNLOCK TABLES; -- complaint DROP TABLE IF EXISTS COMPLAINT; CREATE TABLE COMPLAINT ( Block_name VARCHAR(30) NOT NULL, Apartment_number INT NOT NULL, Complaint_number BIGINT NOT NULL, Complainant VARCHAR(30) NOT NULL, Complaint VARCHAR(100) NOT NULL, Lodge_time DATETIME NOT NULL, Complaint_status VARCHAR(20) NOT NULL, Complaint_type VARCHAR(20) NOT NULL, PRIMARY KEY (Complaint_number) ); LOCK TABLES COMPLAINT WRITE; INSERT INTO COMPLAINT VALUES ('A',102,1,'Arun','No electricity in hall','2020-10-20 9:39:46','pending','electrician'), ('B',104,2,'Arun','Tap leakage in kitchen','2020-10-20 9:43:07','pending','plumbing'); UNLOCK TABLES; -- complaint history DROP TABLE IF EXISTS COMPLAINT_HISTORY; CREATE TABLE COMPLAINT_HISTORY ( Block_name VARCHAR(30) NOT NULL, Apartment_number INT NOT NULL, Complaint_number BIGINT NOT NULL, Complainant VARCHAR(30) NOT NULL, Complaint VARCHAR(100) NOT NULL, Lodge_time DATETIME NOT NULL, Complaint_type VARCHAR(20) NOT NULL, Resolver_name VARCHAR(30) NOT NULL, Resolver_phno BIGINT NOT NULL, Resolver_email_id VARCHAR(50), PRIMARY KEY (Complaint_number) ); DELETE FROM COMPLAINT WHERE Complaint_number = 2; LOCK TABLES COMPLAINT_HISTORY WRITE; INSERT INTO COMPLAINT_HISTORY VALUES ('B',104,2,'Arun','Tap leakage in kitchen','2020-10-20 9:43:07','plumbing','Ganesh',9977883322,'ganesh_pumbing@gmail.com'); UNLOCK TABLES; -- employee DROP TABLE IF EXISTS EMPLOYEE; CREATE TABLE EMPLOYEE ( Employee_id BIGINT NOT NULL, Employee_name VARCHAR(30) NOT NULL, Email_id VARCHAR(50) NOT NULL, Salary FLOAT NOT NULL, Manager_id BIGINT, Work_type VARCHAR(20) NOT NULL, Start_date DATE, PRIMARY KEY (Employee_id) ); LOCK TABLES EMPLOYEE WRITE; INSERT INTO EMPLOYEE VALUES (1,'Charan','charan@yahoo.com',5000,NULL,'watch man','2020-10-1'), (2,'vanu','venu@gmail.com',5000,NULL,'watch man','2020-10-3'), (3,'ganapati','ganapati@gmail.com',10000,NULL,'cleaning','2020-10-9'), (4,'Bolu','bolu@gmail.com',10000,NULL,'cleaning','2020-10-8'); UNLOCK TABLES; -- employee phno DROP TABLE IF EXISTS EMPLOYEE_PHNO; CREATE TABLE EMPLOYEE_PHNO ( Employee_id BIGINT NOT NULL, Phone_number BIGINT NOT NULL, PRIMARY KEY (Employee_id , Phone_number) ); LOCK TABLES EMPLOYEE_PHNO WRITE; INSERT INTO EMPLOYEE_PHNO VALUES (1,9998885551), (1,9998883330), (2,2323245456), (3,1231234563), (4,5588779320); UNLOCK TABLES; -- employee history DROP TABLE IF EXISTS EMPLOYEE_HISTORY; CREATE TABLE EMPLOYEE_HISTORY ( Employee_id BIGINT NOT NULL, Employee_name VARCHAR(30) NOT NULL, Email_id VARCHAR(50) NOT NULL, Salary FLOAT NOT NULL, Manager_id BIGINT, Work_type VARCHAR(50) NOT NULL, Start_date DATE, end_date Date, PRIMARY KEY (Employee_id) ); LOCK TABLES EMPLOYEE_HISTORY WRITE; INSERT INTO EMPLOYEE_HISTORY VALUES (2,'john','john@outlook.com',2000,NULL,'managing festive events','2020-10-01','2020-10-20'); UNLOCK TABLES; -- employee phno DROP TABLE IF EXISTS EMPLOYEE_PHNO_HISTORY; CREATE TABLE EMPLOYEE_PHNO_HISTORY ( Employee_id BIGINT NOT NULL, Phone_number BIGINT NOT NULL, PRIMARY KEY (Employee_id , Phone_number) ); LOCK TABLES EMPLOYEE_PHNO_HISTORY WRITE; INSERT INTO EMPLOYEE_PHNO_HISTORY VALUES (2,9998885541), (2,9998883230); UNLOCK TABLES; -- Owner_phno history DROP TABLE IF EXISTS OWNER_PHNO_HISTORY; CREATE TABLE OWNER_PHNO_HISTORY ( Block_name VARCHAR(30) NOT NULL, Owner_id BIGINT NOT NULL, Owner_phno BIGINT NOT NULL, PRIMARY KEY (Owner_id , Block_name , Owner_phno), CONSTRAINT OWNER_PHNO_HISTORY_fk_1 FOREIGN KEY (Block_name) REFERENCES APARTMENT_COMPLEX (Block_name) ); LOCK TABLES OWNER_PHNO_HISTORY WRITE; INSERT INTO OWNER_PHNO_HISTORY VALUES ('A',202010201,1122334455), ('A',202010201,1234567890), ('B',202010401,1212343456); UNLOCK TABLES; -- Ownership history DROP TABLE IF EXISTS OWNERSHIP_HISTORY; CREATE TABLE OWNERSHIP_HISTORY ( Owner_name VARCHAR(30) NOT NULL, Owner_id BIGINT NOT NULL, Block_name VARCHAR(30) NOT NULL, Email_id VARCHAR(50) NOT NULL, Owner_since DATETIME NOT NULL, Owner_upto DATETIME NOT NULL, PRIMARY KEY (Owner_id , Block_name), KEY (Email_id), CONSTRAINT OWNERSHIP_HISTORY_fk_1 FOREIGN KEY (Block_name) REFERENCES APARTMENT_COMPLEX (Block_name) ); LOCK TABLES OWNERSHIP_HISTORY WRITE; INSERT INTO OWNERSHIP_HISTORY VALUES ('Arjun',202010201,'A','arjun@gmail.com','2020-09-17 11:04:22','2020-10-19 20:27:35' ), ('Krishnan',202010401,'B','krishnan@gmail.com','2020-09-14 11:04:22','2020-10-10 10:00:05'); UNLOCK TABLES; -- Tenant_phno DROP TABLE IF EXISTS TENANT_PHNO_HISTORY; CREATE TABLE TENANT_PHNO_HISTORY ( Block_name VARCHAR(30) NOT NULL, Owner_id BIGINT NOT NULL, Tenant_phno BIGINT NOT NULL, PRIMARY KEY (Owner_id , Block_name , Tenant_phno), CONSTRAINT TENANT_PHNO_HISTORY_fk_1 FOREIGN KEY (Block_name) REFERENCES APARTMENT_COMPLEX (Block_name) ); LOCK TABLES TENANT_PHNO_HISTORY WRITE; INSERT INTO TENANT_PHNO_HISTORY VALUES ('A',202010201,1111277233), ('B',202010401,2283336660), ('B',202010401,1210123498); UNLOCK TABLES; -- Tenant DROP TABLE IF EXISTS TENANT_HISTORY; CREATE TABLE TENANT_HISTORY ( Tenant_name VARCHAR(30) NOT NULL, Block_name VARCHAR(30) NOT NULL, Owner_id BIGINT NOT NULL, Apartment_number INT NOT NULL, Email_id VARCHAR(50) NOT NULL, Tenant_since DATETIME NOT NULL, Tenant_upto DATETIME NOT NULL, PRIMARY KEY (Block_name , Owner_id), KEY (Email_id), CONSTRAINT TENANT_HISTORY_fk_1 FOREIGN KEY (Block_name) REFERENCES APARTMENT_COMPLEX (Block_name) ); LOCK TABLES TENANT_HISTORY WRITE; INSERT INTO TENANT_HISTORY VALUES ('Ramu','A',202010201,102,'ramu@outlook.com','2020-9-20 7:25:45', '2020-10-20 7:22:05' ), ('Balu','B',202010401,104,'balu@gmail.com','2020-9-26 17:2:05','2020-10-1 14:53:39'); UNLOCK TABLES; -- Expediture DROP TABLE IF EXISTS EXPENDITURE; CREATE TABLE EXPENDITURE ( Transaction_id BIGINT NOT NULL, -- yyyymmddn Amount_spent FLOAT NOT NULL, Transaction_time DATETIME NOT NULL, PRIMARY KEY (Transaction_id) ); LOCK TABLES EXPENDITURE WRITE; INSERT INTO EXPENDITURE VALUES (202010080,10000,'2020-10-8 18:28:27'), (202010190,5000,'2020-10-19 12:4:5'), (202010200,30000,'2020-10-20 17:00:38'), (202010280,6000,'2020-10-28 16:34:43'), (202011200,30000,'2020-11-20 17:00:40'), (202012240,30000,'2020-12-24 17:00:20'), (202012241,10000,'2020-12-24 10:00:20'), (202012300,12000,'2020-12-30 10:30:20'), (202101100,5000,'2021-01-10 12:34:20'), (202101200,30000,'2021-01-20 17:00:50'), (202101250,11000,'2021-01-25 13:50:20'), (202102200,30000,'2021-02-20 17:00:30'), (202103210,30000,'2021-03-21 17:00:49'), (202104200,30000,'2021-04-20 17:01:04'), (202105200,30000,'2021-05-20 17:01:04'), (202106220,30000,'2021-06-22 17:01:04'), (202107220,30000,'2021-07-22 17:01:04'), (202108200,30000,'2021-08-20 17:01:04'), (202108140,12000,'2021-08-14 14:34:03'), (202109250,30000,'2021-09-25 17:01:04'), (202110090,8000,'2021-10-09 16:01:04'), (202110250,30000,'2021-10-25 14:07:03'); UNLOCK TABLES; DROP TABLE IF EXISTS RENOVATIONS_AND_REPAIR; CREATE TABLE RENOVATIONS_AND_REPAIR ( Transaction_id BIGINT NOT NULL, Type_of_renovation VARCHAR(255), PRIMARY KEY (Transaction_id), CONSTRAINT RENOVATIONS_AND_REPAIR_fk_1 FOREIGN KEY (Transaction_id) REFERENCES EXPENDITURE (Transaction_id) ); LOCK TABLES RENOVATIONS_AND_REPAIR WRITE; INSERT INTO RENOVATIONS_AND_REPAIR VALUES (202010190,'Lift repair in Block A'); UNLOCK TABLES; DROP TABLE IF EXISTS PURCHASE_OF_NEW_EQUIPMENT; CREATE TABLE PURCHASE_OF_NEW_EQUIPMENT ( Transaction_id BIGINT NOT NULL, Type_of_new_equipment VARCHAR(255), PRIMARY KEY (Transaction_id), CONSTRAINT PURCHASE_OF_NEW_EQUIPMENT_fk_1 FOREIGN KEY (Transaction_id) REFERENCES EXPENDITURE (Transaction_id) ); LOCK TABLES PURCHASE_OF_NEW_EQUIPMENT WRITE; INSERT INTO PURCHASE_OF_NEW_EQUIPMENT VALUES (202010280,'chairs and table parchased for the committe office room in block A'); UNLOCK TABLES; DROP TABLE IF EXISTS FESTIVE_OR_SPECIAL_EVENTS; CREATE TABLE FESTIVE_OR_SPECIAL_EVENTS ( Transaction_id BIGINT NOT NULL, Type_of_events VARCHAR(255), PRIMARY KEY (Transaction_id), CONSTRAINT FESTIVE_OR_SPECIAL_EVENTS_fk_1 FOREIGN KEY (Transaction_id) REFERENCES EXPENDITURE (Transaction_id) ); LOCK TABLES FESTIVE_OR_SPECIAL_EVENTS WRITE; INSERT INTO FESTIVE_OR_SPECIAL_EVENTS VALUES (202010080,'Dasara festival celebrations'), (202012241,'Christmas celebrations'), (202012300,'New year celebrations'), (202101100,'Sankranti'), (202101250,'Republic day celebrations'), (202108140,'Independence day celebrations'), (202110090,'Dasara celebrations'); UNLOCK TABLES; DROP TABLE IF EXISTS SALARIES; CREATE TABLE SALARIES ( Transaction_id BIGINT NOT NULL, Monthly_salaries VARCHAR(255), PRIMARY KEY (Transaction_id), CONSTRAINT SALARIES_fk_1 FOREIGN KEY (Transaction_id) REFERENCES EXPENDITURE (Transaction_id) ); LOCK TABLES SALARIES WRITE; INSERT INTO SALARIES VALUES (202010200,'Salaries for employees'), (202011200,'Salaries for employees'), (202012240,'Salaries for employees'), (202101200,'Salaries for employees'), (202102200,'Salaries for employees'), (202103210,'Salaries for employees'), (202104200,'Salaries for employees'), (202105200,'Salaries for employees'), (202106220,'Salaries for employees'), (202107220,'Salaries for employees'), (202108200,'Salaries for employees'), (202109250,'Salaries for employees'), (202110250,'Salaries for employees'); UNLOCK TABLES;
true
f0f4796db1d294a21e605f241cc3f0ea173c5d04
SQL
rufaidaju/hyf-db
/week2_part1.sql
UTF-8
711
3.4375
3
[]
no_license
# 1-Add a task with these attributes: title, description, created, updated, due_date, status_id, user_id #-Insert into task table: INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES('Do db homeworks','Doing all the parts','2017-02-09 09:07:24','2017-02-19 04:27:02','2017-02-25 06:09:32' ,2); # 2-Change the title of a task: UPDATE task SET title = 'DB homeworks' WHERE id = 36; # 3-Change a task due date: UPDATE task SET due_date ='2017-10-19 00:40:54' WHERE id = 36; # 4-Change a task status: UPDATE task SET status_id = 2 WHERE id =22 ; # 5-Mark a task as complete: UPDATE task SET status_id = 3 WHERE id =22 ; # 6-Delete a task: DELETE FROM task WHERE id =26 ;
true
ea6ecdee8d5eae0608b2e116b8bcd2ab9f4fe7c0
SQL
subharoy/workout-manager-app
/workout-manager-service/src/main/resources/schema-mysql.sql
UTF-8
1,357
3.875
4
[]
no_license
CREATE SCHEMA IF NOT EXISTS `fse`; COMMIT; CREATE USER IF NOT EXISTS `fse` IDENTIFIED BY 'fse123' REQUIRE NONE PASSWORD EXPIRE NEVER; COMMIT; GRANT ALTER, CREATE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EXECUTE, GRANT OPTION, INDEX, INSERT, SELECT, TRIGGER, UPDATE, REFERENCES ON fse.* TO fse; COMMIT; CREATE TABLE `fse`.`category` ( `id` int(9) NOT NULL AUTO_INCREMENT, `category` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; COMMIT; CREATE TABLE `fse`.`workout` ( `id` int(12) NOT NULL AUTO_INCREMENT, `categoryid` int(9) NOT NULL, `title` varchar(128) NOT NULL, `notes` varchar(256) DEFAULT NULL, `burnrate` double DEFAULT '2', PRIMARY KEY (`id`), KEY `workout_fk1` (`categoryid`), CONSTRAINT `workout_fk1` FOREIGN KEY (`categoryid`) REFERENCES `category` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8; COMMIT; CREATE TABLE `fse`.`workoutactivity` ( `id` int(12) NOT NULL, `startdate` date DEFAULT NULL, `starttime` time DEFAULT NULL, `enddate` date DEFAULT NULL, `endtime` time DEFAULT NULL, `comment` varchar(64) DEFAULT NULL, `status` boolean NOT NULL DEFAULT 0, KEY `workoutactivity_fk1` (`id`), CONSTRAINT `workoutactivity_fk1` FOREIGN KEY (`id`) REFERENCES `workout` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; COMMIT;
true
373416a1806439472ca343adf7c16e1b612b1700
SQL
archiv-edigonzales/agi_veranstaltung_20191022
/awjf_forstreviere_pub.sql
UTF-8
35,872
2.84375
3
[ "MIT" ]
permissive
CREATE SCHEMA IF NOT EXISTS awjf_forstreviere_pub; CREATE SEQUENCE awjf_forstreviere_pub.t_ili2db_seq;; -- GeometryCHLV95_V1.SurfaceStructure CREATE TABLE awjf_forstreviere_pub.surfacestructure ( T_Id bigint PRIMARY KEY DEFAULT nextval('awjf_forstreviere_pub.t_ili2db_seq') ,T_Seq bigint NULL ,surface geometry(POLYGON,2056) NULL ,multisurface_surfaces bigint NULL ) ; CREATE INDEX surfacestructure_surface_idx ON awjf_forstreviere_pub.surfacestructure USING GIST ( surface ); CREATE INDEX surfacestructure_multisurface_surfaces_idx ON awjf_forstreviere_pub.surfacestructure ( multisurface_surfaces ); -- GeometryCHLV95_V1.MultiSurface CREATE TABLE awjf_forstreviere_pub.multisurface ( T_Id bigint PRIMARY KEY DEFAULT nextval('awjf_forstreviere_pub.t_ili2db_seq') ,T_Seq bigint NULL ) ; -- SO_Forstreviere_Publikation_20170428.Forstreviere.Forstkreis CREATE TABLE awjf_forstreviere_pub.forstreviere_forstkreis ( T_Id bigint PRIMARY KEY DEFAULT nextval('awjf_forstreviere_pub.t_ili2db_seq') ,geometrie geometry(MULTIPOLYGON,2056) NOT NULL ,forstkreis varchar(50) NOT NULL ) ; CREATE INDEX forstreviere_forstkreis_geometrie_idx ON awjf_forstreviere_pub.forstreviere_forstkreis USING GIST ( geometrie ); COMMENT ON COLUMN awjf_forstreviere_pub.forstreviere_forstkreis.geometrie IS 'Geometrie des Forstkreises'; COMMENT ON COLUMN awjf_forstreviere_pub.forstreviere_forstkreis.forstkreis IS 'Name des Forstkreises'; -- SO_Forstreviere_Publikation_20170428.Forstreviere.Forstrevier CREATE TABLE awjf_forstreviere_pub.forstreviere_forstrevier ( T_Id bigint PRIMARY KEY DEFAULT nextval('awjf_forstreviere_pub.t_ili2db_seq') ,geometrie geometry(MULTIPOLYGON,2056) NOT NULL ,forstrevier varchar(50) NOT NULL ,forstkreis varchar(50) NOT NULL ) ; CREATE INDEX forstreviere_forstrevier_geometrie_idx ON awjf_forstreviere_pub.forstreviere_forstrevier USING GIST ( geometrie ); COMMENT ON COLUMN awjf_forstreviere_pub.forstreviere_forstrevier.geometrie IS 'Geometrie des Forstreviers'; COMMENT ON COLUMN awjf_forstreviere_pub.forstreviere_forstrevier.forstrevier IS 'Name des Forstreviers'; COMMENT ON COLUMN awjf_forstreviere_pub.forstreviere_forstrevier.forstkreis IS 'Name des Forstkreises'; CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_BASKET ( T_Id bigint PRIMARY KEY ,dataset bigint NULL ,topic varchar(200) NOT NULL ,T_Ili_Tid varchar(200) NULL ,attachmentKey varchar(200) NOT NULL ,domains varchar(1024) NULL ) ; CREATE INDEX T_ILI2DB_BASKET_dataset_idx ON awjf_forstreviere_pub.t_ili2db_basket ( dataset ); CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_DATASET ( T_Id bigint PRIMARY KEY ,datasetName varchar(200) NULL ) ; CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_INHERITANCE ( thisClass varchar(1024) PRIMARY KEY ,baseClass varchar(1024) NULL ) ; CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_SETTINGS ( tag varchar(60) PRIMARY KEY ,setting varchar(1024) NULL ) ; CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_TRAFO ( iliname varchar(1024) NOT NULL ,tag varchar(1024) NOT NULL ,setting varchar(1024) NOT NULL ) ; CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_MODEL ( filename varchar(250) NOT NULL ,iliversion varchar(3) NOT NULL ,modelName text NOT NULL ,content text NOT NULL ,importDate timestamp NOT NULL ,PRIMARY KEY (modelName,iliversion) ) ; CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_CLASSNAME ( IliName varchar(1024) PRIMARY KEY ,SqlName varchar(1024) NOT NULL ) ; CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_ATTRNAME ( IliName varchar(1024) NOT NULL ,SqlName varchar(1024) NOT NULL ,ColOwner varchar(1024) NOT NULL ,Target varchar(1024) NULL ,PRIMARY KEY (SqlName,ColOwner) ) ; CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP ( tablename varchar(255) NOT NULL ,subtype varchar(255) NULL ,columnname varchar(255) NOT NULL ,tag varchar(1024) NOT NULL ,setting varchar(1024) NOT NULL ) ; CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_TABLE_PROP ( tablename varchar(255) NOT NULL ,tag varchar(1024) NOT NULL ,setting varchar(1024) NOT NULL ) ; CREATE TABLE awjf_forstreviere_pub.T_ILI2DB_META_ATTRS ( ilielement varchar(255) NOT NULL ,attr_name varchar(1024) NOT NULL ,attr_value varchar(1024) NOT NULL ) ; ALTER TABLE awjf_forstreviere_pub.surfacestructure ADD CONSTRAINT surfacestructure_multisurface_surfaces_fkey FOREIGN KEY ( multisurface_surfaces ) REFERENCES awjf_forstreviere_pub.multisurface DEFERRABLE INITIALLY DEFERRED; ALTER TABLE awjf_forstreviere_pub.T_ILI2DB_BASKET ADD CONSTRAINT T_ILI2DB_BASKET_dataset_fkey FOREIGN KEY ( dataset ) REFERENCES awjf_forstreviere_pub.T_ILI2DB_DATASET DEFERRABLE INITIALLY DEFERRED; CREATE UNIQUE INDEX T_ILI2DB_DATASET_datasetName_key ON awjf_forstreviere_pub.T_ILI2DB_DATASET (datasetName) ; CREATE UNIQUE INDEX T_ILI2DB_MODEL_modelName_iliversion_key ON awjf_forstreviere_pub.T_ILI2DB_MODEL (modelName,iliversion) ; CREATE UNIQUE INDEX T_ILI2DB_ATTRNAME_SqlName_ColOwner_key ON awjf_forstreviere_pub.T_ILI2DB_ATTRNAME (SqlName,ColOwner) ; INSERT INTO awjf_forstreviere_pub.T_ILI2DB_CLASSNAME (IliName,SqlName) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstkreis','forstreviere_forstkreis'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_CLASSNAME (IliName,SqlName) VALUES ('GeometryCHLV95_V1.MultiSurface','multisurface'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_CLASSNAME (IliName,SqlName) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstrevier','forstreviere_forstrevier'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_CLASSNAME (IliName,SqlName) VALUES ('GeometryCHLV95_V1.SurfaceStructure','surfacestructure'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_ATTRNAME (IliName,SqlName,ColOwner,Target) VALUES ('GeometryCHLV95_V1.MultiSurface.Surfaces','multisurface_surfaces','surfacestructure','multisurface'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_ATTRNAME (IliName,SqlName,ColOwner,Target) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstrevier.Forstrevier','forstrevier','forstreviere_forstrevier',NULL); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_ATTRNAME (IliName,SqlName,ColOwner,Target) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstrevier.Forstkreis','forstkreis','forstreviere_forstrevier',NULL); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_ATTRNAME (IliName,SqlName,ColOwner,Target) VALUES ('GeometryCHLV95_V1.SurfaceStructure.Surface','surface','surfacestructure',NULL); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_ATTRNAME (IliName,SqlName,ColOwner,Target) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstkreis.Geometrie','geometrie','forstreviere_forstkreis',NULL); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_ATTRNAME (IliName,SqlName,ColOwner,Target) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstrevier.Geometrie','geometrie','forstreviere_forstrevier',NULL); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_ATTRNAME (IliName,SqlName,ColOwner,Target) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstkreis.Forstkreis','forstkreis','forstreviere_forstkreis',NULL); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_TRAFO (iliname,tag,setting) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstkreis','ch.ehi.ili2db.inheritance','newClass'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_TRAFO (iliname,tag,setting) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstrevier.Geometrie','ch.ehi.ili2db.multiSurfaceTrafo','coalesce'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_TRAFO (iliname,tag,setting) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstkreis.Geometrie','ch.ehi.ili2db.multiSurfaceTrafo','coalesce'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_TRAFO (iliname,tag,setting) VALUES ('GeometryCHLV95_V1.MultiSurface','ch.ehi.ili2db.inheritance','newClass'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_TRAFO (iliname,tag,setting) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstrevier','ch.ehi.ili2db.inheritance','newClass'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_TRAFO (iliname,tag,setting) VALUES ('GeometryCHLV95_V1.SurfaceStructure','ch.ehi.ili2db.inheritance','newClass'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_INHERITANCE (thisClass,baseClass) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstkreis',NULL); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_INHERITANCE (thisClass,baseClass) VALUES ('SO_Forstreviere_Publikation_20170428.Forstreviere.Forstrevier',NULL); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_INHERITANCE (thisClass,baseClass) VALUES ('GeometryCHLV95_V1.MultiSurface',NULL); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_INHERITANCE (thisClass,baseClass) VALUES ('GeometryCHLV95_V1.SurfaceStructure',NULL); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('surfacestructure',NULL,'surface','ch.ehi.ili2db.c2Min','1045000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstkreis',NULL,'geometrie','ch.ehi.ili2db.geomType','MULTIPOLYGON'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('surfacestructure',NULL,'surface','ch.ehi.ili2db.c1Min','2460000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstrevier',NULL,'geometrie','ch.ehi.ili2db.c1Min','2460000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstkreis',NULL,'geometrie','ch.ehi.ili2db.srid','2056'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstrevier',NULL,'geometrie','ch.ehi.ili2db.c2Min','1045000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('surfacestructure',NULL,'surface','ch.ehi.ili2db.srid','2056'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('surfacestructure',NULL,'multisurface_surfaces','ch.ehi.ili2db.foreignKey','multisurface'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstrevier',NULL,'geometrie','ch.ehi.ili2db.geomType','MULTIPOLYGON'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstkreis',NULL,'geometrie','ch.ehi.ili2db.c1Min','2460000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstrevier',NULL,'geometrie','ch.ehi.ili2db.srid','2056'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('surfacestructure',NULL,'surface','ch.ehi.ili2db.coordDimension','2'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('surfacestructure',NULL,'surface','ch.ehi.ili2db.geomType','POLYGON'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstrevier',NULL,'geometrie','ch.ehi.ili2db.c2Max','1310000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('surfacestructure',NULL,'surface','ch.ehi.ili2db.c2Max','1310000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstkreis',NULL,'geometrie','ch.ehi.ili2db.c1Max','2870000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstkreis',NULL,'geometrie','ch.ehi.ili2db.c2Min','1045000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstrevier',NULL,'geometrie','ch.ehi.ili2db.coordDimension','2'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstrevier',NULL,'geometrie','ch.ehi.ili2db.c1Max','2870000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstkreis',NULL,'geometrie','ch.ehi.ili2db.c2Max','1310000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('forstreviere_forstkreis',NULL,'geometrie','ch.ehi.ili2db.coordDimension','2'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_COLUMN_PROP (tablename,subtype,columnname,tag,setting) VALUES ('surfacestructure',NULL,'surface','ch.ehi.ili2db.c1Max','2870000.000'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_TABLE_PROP (tablename,tag,setting) VALUES ('forstreviere_forstkreis','ch.ehi.ili2db.tableKind','CLASS'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_TABLE_PROP (tablename,tag,setting) VALUES ('forstreviere_forstrevier','ch.ehi.ili2db.tableKind','CLASS'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_TABLE_PROP (tablename,tag,setting) VALUES ('surfacestructure','ch.ehi.ili2db.tableKind','STRUCTURE'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_TABLE_PROP (tablename,tag,setting) VALUES ('multisurface','ch.ehi.ili2db.tableKind','STRUCTURE'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_MODEL (filename,iliversion,modelName,content,importDate) VALUES ('Units-20120220.ili','2.3','Units','!! File Units.ili Release 2012-02-20 INTERLIS 2.3; !! 2012-02-20 definition of "Bar [bar]" corrected !!@precursorVersion = 2005-06-06 CONTRACTED TYPE MODEL Units (en) AT "http://www.interlis.ch/models" VERSION "2012-02-20" = UNIT !! abstract Units Area (ABSTRACT) = (INTERLIS.LENGTH*INTERLIS.LENGTH); Volume (ABSTRACT) = (INTERLIS.LENGTH*INTERLIS.LENGTH*INTERLIS.LENGTH); Velocity (ABSTRACT) = (INTERLIS.LENGTH/INTERLIS.TIME); Acceleration (ABSTRACT) = (Velocity/INTERLIS.TIME); Force (ABSTRACT) = (INTERLIS.MASS*INTERLIS.LENGTH/INTERLIS.TIME/INTERLIS.TIME); Pressure (ABSTRACT) = (Force/Area); Energy (ABSTRACT) = (Force*INTERLIS.LENGTH); Power (ABSTRACT) = (Energy/INTERLIS.TIME); Electric_Potential (ABSTRACT) = (Power/INTERLIS.ELECTRIC_CURRENT); Frequency (ABSTRACT) = (INTERLIS.DIMENSIONLESS/INTERLIS.TIME); Millimeter [mm] = 0.001 [INTERLIS.m]; Centimeter [cm] = 0.01 [INTERLIS.m]; Decimeter [dm] = 0.1 [INTERLIS.m]; Kilometer [km] = 1000 [INTERLIS.m]; Square_Meter [m2] EXTENDS Area = (INTERLIS.m*INTERLIS.m); Cubic_Meter [m3] EXTENDS Volume = (INTERLIS.m*INTERLIS.m*INTERLIS.m); Minute [min] = 60 [INTERLIS.s]; Hour [h] = 60 [min]; Day [d] = 24 [h]; Kilometer_per_Hour [kmh] EXTENDS Velocity = (km/h); Meter_per_Second [ms] = 3.6 [kmh]; Newton [N] EXTENDS Force = (INTERLIS.kg*INTERLIS.m/INTERLIS.s/INTERLIS.s); Pascal [Pa] EXTENDS Pressure = (N/m2); Joule [J] EXTENDS Energy = (N*INTERLIS.m); Watt [W] EXTENDS Power = (J/INTERLIS.s); Volt [V] EXTENDS Electric_Potential = (W/INTERLIS.A); Inch [in] = 2.54 [cm]; Foot [ft] = 0.3048 [INTERLIS.m]; Mile [mi] = 1.609344 [km]; Are [a] = 100 [m2]; Hectare [ha] = 100 [a]; Square_Kilometer [km2] = 100 [ha]; Acre [acre] = 4046.873 [m2]; Liter [L] = 1 / 1000 [m3]; US_Gallon [USgal] = 3.785412 [L]; Angle_Degree = 180 / PI [INTERLIS.rad]; Angle_Minute = 1 / 60 [Angle_Degree]; Angle_Second = 1 / 60 [Angle_Minute]; Gon = 200 / PI [INTERLIS.rad]; Gram [g] = 1 / 1000 [INTERLIS.kg]; Ton [t] = 1000 [INTERLIS.kg]; Pound [lb] = 0.4535924 [INTERLIS.kg]; Calorie [cal] = 4.1868 [J]; Kilowatt_Hour [kWh] = 0.36E7 [J]; Horsepower = 746 [W]; Techn_Atmosphere [at] = 98066.5 [Pa]; Atmosphere [atm] = 101325 [Pa]; Bar [bar] = 100000 [Pa]; Millimeter_Mercury [mmHg] = 133.3224 [Pa]; Torr = 133.3224 [Pa]; !! Torr = [mmHg] Decibel [dB] = FUNCTION // 10**(dB/20) * 0.00002 // [Pa]; Degree_Celsius [oC] = FUNCTION // oC+273.15 // [INTERLIS.K]; Degree_Fahrenheit [oF] = FUNCTION // (oF+459.67)/1.8 // [INTERLIS.K]; CountedObjects EXTENDS INTERLIS.DIMENSIONLESS; Hertz [Hz] EXTENDS Frequency = (CountedObjects/INTERLIS.s); KiloHertz [KHz] = 1000 [Hz]; MegaHertz [MHz] = 1000 [KHz]; Percent = 0.01 [CountedObjects]; Permille = 0.001 [CountedObjects]; !! ISO 4217 Currency Abbreviation USDollar [USD] EXTENDS INTERLIS.MONEY; Euro [EUR] EXTENDS INTERLIS.MONEY; SwissFrancs [CHF] EXTENDS INTERLIS.MONEY; END Units. ','2019-10-10 15:50:26.169'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_MODEL (filename,iliversion,modelName,content,importDate) VALUES ('SO_Forstreviere_Publikation_20170428.ili','2.3','SO_Forstreviere_Publikation_20170428{ GeometryCHLV95_V1}','INTERLIS 2.3; !!============================================================================== !!@ File = "SO_Forstreviere_Publikation_20170428.ili"; !!@ Title = "Forstreviere und Forstkreise"; !!@ shortDescription = "Forstreviere und Forstkreise des Kanton Solothurn"; !!@ Issuer = "http://www.agi.so.ch"; !!@ technicalContact = "mailto:agi@so.ch"; !!@ furtherInformation = ""; !!@ kGeoiV_ID = ""; !! Publikationsmodellsmodell; !! Compiler-Version = "4.6.1-20170109"; !!------------------------------------------------------------------------------ !! Version | wer | Änderung !!------------------------------------------------------------------------------ !! 2017-04-28 | Noëmi Sturm | Erstfassung !!============================================================================= MODEL SO_Forstreviere_Publikation_20170428 (de) AT "http://www.geo.so.ch/models/AWJF" VERSION "2017-04-28" = IMPORTS GeometryCHLV95_V1; TOPIC Forstreviere = CLASS Forstkreis = /** Geometrie des Forstkreises */ Geometrie : MANDATORY GeometryCHLV95_V1.MultiSurface; /** Name des Forstkreises */ Forstkreis : MANDATORY TEXT*50; END Forstkreis; CLASS Forstrevier = /** Geometrie des Forstreviers */ Geometrie : MANDATORY GeometryCHLV95_V1.MultiSurface; /** Name des Forstreviers */ Forstrevier : MANDATORY TEXT*50; /** Name des Forstkreises */ Forstkreis : MANDATORY TEXT*50; END Forstrevier; END Forstreviere; END SO_Forstreviere_Publikation_20170428. ','2019-10-10 15:50:26.169'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_MODEL (filename,iliversion,modelName,content,importDate) VALUES ('CoordSys-20151124.ili','2.3','CoordSys','!! File CoordSys.ili Release 2015-11-24 INTERLIS 2.3; !! 2015-11-24 Cardinalities adapted (line 122, 123, 124, 132, 133, 134, 142, 143, !! 148, 149, 163, 164, 168, 169, 206 and 207) !!@precursorVersion = 2005-06-16 REFSYSTEM MODEL CoordSys (en) AT "http://www.interlis.ch/models" VERSION "2015-11-24" = UNIT Angle_Degree = 180 / PI [INTERLIS.rad]; Angle_Minute = 1 / 60 [Angle_Degree]; Angle_Second = 1 / 60 [Angle_Minute]; STRUCTURE Angle_DMS_S = Degrees: -180 .. 180 CIRCULAR [Angle_Degree]; CONTINUOUS SUBDIVISION Minutes: 0 .. 59 CIRCULAR [Angle_Minute]; CONTINUOUS SUBDIVISION Seconds: 0.000 .. 59.999 CIRCULAR [Angle_Second]; END Angle_DMS_S; DOMAIN Angle_DMS = FORMAT BASED ON Angle_DMS_S (Degrees ":" Minutes ":" Seconds); Angle_DMS_90 EXTENDS Angle_DMS = "-90:00:00.000" .. "90:00:00.000"; TOPIC CoordsysTopic = !! Special space aspects to be referenced !! ************************************** CLASS Ellipsoid EXTENDS INTERLIS.REFSYSTEM = EllipsoidAlias: TEXT*70; SemiMajorAxis: MANDATORY 6360000.0000 .. 6390000.0000 [INTERLIS.m]; InverseFlattening: MANDATORY 0.00000000 .. 350.00000000; !! The inverse flattening 0 characterizes the 2-dim sphere Remarks: TEXT*70; END Ellipsoid; CLASS GravityModel EXTENDS INTERLIS.REFSYSTEM = GravityModAlias: TEXT*70; Definition: TEXT*70; END GravityModel; CLASS GeoidModel EXTENDS INTERLIS.REFSYSTEM = GeoidModAlias: TEXT*70; Definition: TEXT*70; END GeoidModel; !! Coordinate systems for geodetic purposes !! **************************************** STRUCTURE LengthAXIS EXTENDS INTERLIS.AXIS = ShortName: TEXT*12; Description: TEXT*255; PARAMETER Unit (EXTENDED): NUMERIC [INTERLIS.LENGTH]; END LengthAXIS; STRUCTURE AngleAXIS EXTENDS INTERLIS.AXIS = ShortName: TEXT*12; Description: TEXT*255; PARAMETER Unit (EXTENDED): NUMERIC [INTERLIS.ANGLE]; END AngleAXIS; CLASS GeoCartesian1D EXTENDS INTERLIS.COORDSYSTEM = Axis (EXTENDED): LIST {1} OF LengthAXIS; END GeoCartesian1D; CLASS GeoHeight EXTENDS GeoCartesian1D = System: MANDATORY ( normal, orthometric, ellipsoidal, other); ReferenceHeight: MANDATORY -10000.000 .. +10000.000 [INTERLIS.m]; ReferenceHeightDescr: TEXT*70; END GeoHeight; ASSOCIATION HeightEllips = GeoHeightRef -- {*} GeoHeight; EllipsoidRef -- {1} Ellipsoid; END HeightEllips; ASSOCIATION HeightGravit = GeoHeightRef -- {*} GeoHeight; GravityRef -- {1} GravityModel; END HeightGravit; ASSOCIATION HeightGeoid = GeoHeightRef -- {*} GeoHeight; GeoidRef -- {1} GeoidModel; END HeightGeoid; CLASS GeoCartesian2D EXTENDS INTERLIS.COORDSYSTEM = Definition: TEXT*70; Axis (EXTENDED): LIST {2} OF LengthAXIS; END GeoCartesian2D; CLASS GeoCartesian3D EXTENDS INTERLIS.COORDSYSTEM = Definition: TEXT*70; Axis (EXTENDED): LIST {3} OF LengthAXIS; END GeoCartesian3D; CLASS GeoEllipsoidal EXTENDS INTERLIS.COORDSYSTEM = Definition: TEXT*70; Axis (EXTENDED): LIST {2} OF AngleAXIS; END GeoEllipsoidal; ASSOCIATION EllCSEllips = GeoEllipsoidalRef -- {*} GeoEllipsoidal; EllipsoidRef -- {1} Ellipsoid; END EllCSEllips; !! Mappings between coordinate systems !! *********************************** ASSOCIATION ToGeoEllipsoidal = From -- {0..*} GeoCartesian3D; To -- {0..*} GeoEllipsoidal; ToHeight -- {0..*} GeoHeight; MANDATORY CONSTRAINT ToHeight -> System == #ellipsoidal; MANDATORY CONSTRAINT To -> EllipsoidRef -> Name == ToHeight -> EllipsoidRef -> Name; END ToGeoEllipsoidal; ASSOCIATION ToGeoCartesian3D = From2 -- {0..*} GeoEllipsoidal; FromHeight-- {0..*} GeoHeight; To3 -- {0..*} GeoCartesian3D; MANDATORY CONSTRAINT FromHeight -> System == #ellipsoidal; MANDATORY CONSTRAINT From2 -> EllipsoidRef -> Name == FromHeight -> EllipsoidRef -> Name; END ToGeoCartesian3D; ASSOCIATION BidirectGeoCartesian2D = From -- {0..*} GeoCartesian2D; To -- {0..*} GeoCartesian2D; END BidirectGeoCartesian2D; ASSOCIATION BidirectGeoCartesian3D = From -- {0..*} GeoCartesian3D; To2 -- {0..*} GeoCartesian3D; Precision: MANDATORY ( exact, measure_based); ShiftAxis1: MANDATORY -10000.000 .. 10000.000 [INTERLIS.m]; ShiftAxis2: MANDATORY -10000.000 .. 10000.000 [INTERLIS.m]; ShiftAxis3: MANDATORY -10000.000 .. 10000.000 [INTERLIS.m]; RotationAxis1: Angle_DMS_90; RotationAxis2: Angle_DMS_90; RotationAxis3: Angle_DMS_90; NewScale: 0.000001 .. 1000000.000000; END BidirectGeoCartesian3D; ASSOCIATION BidirectGeoEllipsoidal = From4 -- {0..*} GeoEllipsoidal; To4 -- {0..*} GeoEllipsoidal; END BidirectGeoEllipsoidal; ASSOCIATION MapProjection (ABSTRACT) = From5 -- {0..*} GeoEllipsoidal; To5 -- {0..*} GeoCartesian2D; FromCo1_FundPt: MANDATORY Angle_DMS_90; FromCo2_FundPt: MANDATORY Angle_DMS_90; ToCoord1_FundPt: MANDATORY -10000000 .. +10000000 [INTERLIS.m]; ToCoord2_FundPt: MANDATORY -10000000 .. +10000000 [INTERLIS.m]; END MapProjection; ASSOCIATION TransverseMercator EXTENDS MapProjection = END TransverseMercator; ASSOCIATION SwissProjection EXTENDS MapProjection = IntermFundP1: MANDATORY Angle_DMS_90; IntermFundP2: MANDATORY Angle_DMS_90; END SwissProjection; ASSOCIATION Mercator EXTENDS MapProjection = END Mercator; ASSOCIATION ObliqueMercator EXTENDS MapProjection = END ObliqueMercator; ASSOCIATION Lambert EXTENDS MapProjection = END Lambert; ASSOCIATION Polyconic EXTENDS MapProjection = END Polyconic; ASSOCIATION Albus EXTENDS MapProjection = END Albus; ASSOCIATION Azimutal EXTENDS MapProjection = END Azimutal; ASSOCIATION Stereographic EXTENDS MapProjection = END Stereographic; ASSOCIATION HeightConversion = FromHeight -- {0..*} GeoHeight; ToHeight -- {0..*} GeoHeight; Definition: TEXT*70; END HeightConversion; END CoordsysTopic; END CoordSys. ','2019-10-10 15:50:26.169'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_MODEL (filename,iliversion,modelName,content,importDate) VALUES ('CHBase_Part1_GEOMETRY_20110830.ili','2.3','GeometryCHLV03_V1{ CoordSys Units INTERLIS} GeometryCHLV95_V1{ CoordSys Units INTERLIS}','/* ######################################################################## CHBASE - BASE MODULES OF THE SWISS FEDERATION FOR MINIMAL GEODATA MODELS ====== BASISMODULE DES BUNDES MODULES DE BASE DE LA CONFEDERATION FÜR MINIMALE GEODATENMODELLE POUR LES MODELES DE GEODONNEES MINIMAUX PROVIDER: GKG/KOGIS - GCS/COSIG CONTACT: models@geo.admin.ch PUBLISHED: 2011-0830 ######################################################################## */ INTERLIS 2.3; /* ######################################################################## ######################################################################## PART I -- GEOMETRY - Package GeometryCHLV03 - Package GeometryCHLV95 */ !! ######################################################################## !! Version | Who | Modification !!------------------------------------------------------------------------------ !! 2015-02-20 | KOGIS | WITHOUT OVERLAPS added (line 57, 58, 65 and 66) !! 2015-11-12 | KOGIS | WITHOUT OVERLAPS corrected (line 57 and 58) !! 2017-11-27 | KOGIS | Meta-Attributes @furtherInformation adapted and @CRS added (line 31, 44 and 50) !! 2017-12-04 | KOGIS | Meta-Attribute @CRS corrected !!@technicalContact=models@geo.admin.ch !!@furtherInformation=https://www.geo.admin.ch/de/geoinformation-schweiz/geobasisdaten/geodata-models.html TYPE MODEL GeometryCHLV03_V1 (en) AT "http://www.geo.admin.ch" VERSION "2017-12-04" = IMPORTS UNQUALIFIED INTERLIS; IMPORTS Units; IMPORTS CoordSys; REFSYSTEM BASKET BCoordSys ~ CoordSys.CoordsysTopic OBJECTS OF GeoCartesian2D: CHLV03 OBJECTS OF GeoHeight: SwissOrthometricAlt; DOMAIN !!@CRS=EPSG:21781 Coord2 = COORD 460000.000 .. 870000.000 [m] {CHLV03[1]}, 45000.000 .. 310000.000 [m] {CHLV03[2]}, ROTATION 2 -> 1; !!@CRS=EPSG:21781 Coord3 = COORD 460000.000 .. 870000.000 [m] {CHLV03[1]}, 45000.000 .. 310000.000 [m] {CHLV03[2]}, -200.000 .. 5000.000 [m] {SwissOrthometricAlt[1]}, ROTATION 2 -> 1; Surface = SURFACE WITH (STRAIGHTS, ARCS) VERTEX Coord2 WITHOUT OVERLAPS > 0.001; Area = AREA WITH (STRAIGHTS, ARCS) VERTEX Coord2 WITHOUT OVERLAPS > 0.001; Line = POLYLINE WITH (STRAIGHTS, ARCS) VERTEX Coord2; DirectedLine EXTENDS Line = DIRECTED POLYLINE; LineWithAltitude = POLYLINE WITH (STRAIGHTS, ARCS) VERTEX Coord3; DirectedLineWithAltitude = DIRECTED POLYLINE WITH (STRAIGHTS, ARCS) VERTEX Coord3; /* minimal overlaps only (2mm) */ SurfaceWithOverlaps2mm = SURFACE WITH (STRAIGHTS, ARCS) VERTEX Coord2 WITHOUT OVERLAPS > 0.002; AreaWithOverlaps2mm = AREA WITH (STRAIGHTS, ARCS) VERTEX Coord2 WITHOUT OVERLAPS > 0.002; Orientation = 0.00000 .. 359.99999 CIRCULAR [Units.Angle_Degree] <Coord2>; Accuracy = (cm, cm50, m, m10, m50, vague); Method = (measured, sketched, calculated); STRUCTURE LineStructure = Line: Line; END LineStructure; STRUCTURE DirectedLineStructure = Line: DirectedLine; END DirectedLineStructure; STRUCTURE MultiLine = Lines: BAG {1..*} OF LineStructure; END MultiLine; STRUCTURE MultiDirectedLine = Lines: BAG {1..*} OF DirectedLineStructure; END MultiDirectedLine; STRUCTURE SurfaceStructure = Surface: Surface; END SurfaceStructure; STRUCTURE MultiSurface = Surfaces: BAG {1..*} OF SurfaceStructure; END MultiSurface; END GeometryCHLV03_V1. !! ######################################################################## !! Version | Who | Modification !!------------------------------------------------------------------------------ !! 2015-02-20 | KOGIS | WITHOUT OVERLAPS added (line 135, 136, 143 and 144) !! 2015-11-12 | KOGIS | WITHOUT OVERLAPS corrected (line 135 and 136) !! 2017-11-27 | KOGIS | Meta-Attributes @furtherInformation adapted and @CRS added (line 109, 122 and 128) !! 2017-12-04 | KOGIS | Meta-Attribute @CRS corrected !!@technicalContact=models@geo.admin.ch !!@furtherInformation=https://www.geo.admin.ch/de/geoinformation-schweiz/geobasisdaten/geodata-models.html TYPE MODEL GeometryCHLV95_V1 (en) AT "http://www.geo.admin.ch" VERSION "2017-12-04" = IMPORTS UNQUALIFIED INTERLIS; IMPORTS Units; IMPORTS CoordSys; REFSYSTEM BASKET BCoordSys ~ CoordSys.CoordsysTopic OBJECTS OF GeoCartesian2D: CHLV95 OBJECTS OF GeoHeight: SwissOrthometricAlt; DOMAIN !!@CRS=EPSG:2056 Coord2 = COORD 2460000.000 .. 2870000.000 [m] {CHLV95[1]}, 1045000.000 .. 1310000.000 [m] {CHLV95[2]}, ROTATION 2 -> 1; !!@CRS=EPSG:2056 Coord3 = COORD 2460000.000 .. 2870000.000 [m] {CHLV95[1]}, 1045000.000 .. 1310000.000 [m] {CHLV95[2]}, -200.000 .. 5000.000 [m] {SwissOrthometricAlt[1]}, ROTATION 2 -> 1; Surface = SURFACE WITH (STRAIGHTS, ARCS) VERTEX Coord2 WITHOUT OVERLAPS > 0.001; Area = AREA WITH (STRAIGHTS, ARCS) VERTEX Coord2 WITHOUT OVERLAPS > 0.001; Line = POLYLINE WITH (STRAIGHTS, ARCS) VERTEX Coord2; DirectedLine EXTENDS Line = DIRECTED POLYLINE; LineWithAltitude = POLYLINE WITH (STRAIGHTS, ARCS) VERTEX Coord3; DirectedLineWithAltitude = DIRECTED POLYLINE WITH (STRAIGHTS, ARCS) VERTEX Coord3; /* minimal overlaps only (2mm) */ SurfaceWithOverlaps2mm = SURFACE WITH (STRAIGHTS, ARCS) VERTEX Coord2 WITHOUT OVERLAPS > 0.002; AreaWithOverlaps2mm = AREA WITH (STRAIGHTS, ARCS) VERTEX Coord2 WITHOUT OVERLAPS > 0.002; Orientation = 0.00000 .. 359.99999 CIRCULAR [Units.Angle_Degree] <Coord2>; Accuracy = (cm, cm50, m, m10, m50, vague); Method = (measured, sketched, calculated); STRUCTURE LineStructure = Line: Line; END LineStructure; STRUCTURE DirectedLineStructure = Line: DirectedLine; END DirectedLineStructure; STRUCTURE MultiLine = Lines: BAG {1..*} OF LineStructure; END MultiLine; STRUCTURE MultiDirectedLine = Lines: BAG {1..*} OF DirectedLineStructure; END MultiDirectedLine; STRUCTURE SurfaceStructure = Surface: Surface; END SurfaceStructure; STRUCTURE MultiSurface = Surfaces: BAG {1..*} OF SurfaceStructure; END MultiSurface; END GeometryCHLV95_V1. !! ######################################################################## ','2019-10-10 15:50:26.169'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.createMetaInfo','True'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.beautifyEnumDispName','underscore'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.interlis.ili2c.ilidirs','.;http://models.geo.admin.ch'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.arrayTrafo','coalesce'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.createForeignKeyIndex','yes'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.nameOptimization','topic'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.localisedTrafo','expand'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.jsonTrafo','coalesce'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.numericCheckConstraints','create'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.sender','ili2pg-4.3.0-21cbac10c7e35a41346af1c5fc5d6980bb99609d'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.createForeignKey','yes'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.sqlgen.createGeomIndex','True'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.defaultSrsAuthority','EPSG'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.defaultSrsCode','2056'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.createEnumDefs','multiTable'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.maxSqlNameLength','60'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.uuidDefaultValue','uuid_generate_v4()'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.inheritanceTrafo','smart1'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.catalogueRefTrafo','coalesce'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.multiPointTrafo','coalesce'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.StrokeArcs','enable'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.multiLineTrafo','coalesce'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.multiSurfaceTrafo','coalesce'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_SETTINGS (tag,setting) VALUES ('ch.ehi.ili2db.multilingualTrafo','expand'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_META_ATTRS (ilielement,attr_name,attr_value) VALUES ('SO_Forstreviere_Publikation_20170428','Issuer','http://www.agi.so.ch'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_META_ATTRS (ilielement,attr_name,attr_value) VALUES ('SO_Forstreviere_Publikation_20170428','Title','Forstreviere und Forstkreise'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_META_ATTRS (ilielement,attr_name,attr_value) VALUES ('SO_Forstreviere_Publikation_20170428','shortDescription','Forstreviere und Forstkreise des Kanton Solothurn'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_META_ATTRS (ilielement,attr_name,attr_value) VALUES ('SO_Forstreviere_Publikation_20170428','File','SO_Forstreviere_Publikation_20170428.ili'); INSERT INTO awjf_forstreviere_pub.T_ILI2DB_META_ATTRS (ilielement,attr_name,attr_value) VALUES ('SO_Forstreviere_Publikation_20170428','technicalContact','mailto:agi@so.ch');
true
98257ec4e08a60a1baa7498a2523f114a467bbbd
SQL
code4grady/oldChess
/chess/database/chessDDL.sql
UTF-8
810
3.359375
3
[]
no_license
use chess; drop table MOVE_SUMMARY; drop table GAME_Move; drop table GAME; drop table TEST_ME; create table MOVE_SUMMARY ( move char(255) NOT NULL PRIMARY KEY, wins INT, losses INT, stalemates INT, sum_move_number INT, sum_move_total INT ); create table GAME ( game_id VARCHAR(20) NOT NULL PRIMARY KEY, color VARCHAR(5), direction VARCHAR(5), time TIMESTAMP, result VARCHAR(10) ); create table GAME_Move ( move_desc char(255) NOT NULL, game_id VARCHAR(20) NOT NULL, piece_name VARCHAR(15), piece_direction VARCHAR(15), opponent_piece VARCHAR(15), move_number INT, move_point VARCHAR(5), FOREIGN KEY (game_id) REFERENCES game(game_id) ); create table TEST_ME ( name char(1) not null PRIMARY KEY ); insert into TEST_ME values (1);
true
58aa6d818c0f7e9fc1465adf1e00efba7b86ae09
SQL
UAMS-DBMI/PosdaTools
/posda/posdatools/queries/sql/DistinctVrByScan.sql
UTF-8
357
3.125
3
[ "Apache-2.0" ]
permissive
-- Name: DistinctVrByScan -- Schema: posda_phi_simple -- Columns: ['vr', 'num_series'] -- Args: ['scan_id'] -- Tags: ['tag_usage', 'simple_phi'] -- Description: Status of PHI scans -- select distinct vr, count(*) as num_series from element_value_occurance natural join element_seen natural join value_seen where phi_scan_instance_id = ? group by vr
true
6fb04f8783ad3f32212a126185755897438284a7
SQL
SophiaL1024/BootcampX
/4_queries/12_teachers_assistances.sql
UTF-8
365
3.9375
4
[]
no_license
SELECT teachers.name as teacher,cohorts.name as cohort,count(assistance_requests.*) as total_assistances FROM teachers JOIN assistance_requests ON teachers.id=assistance_requests.teacher_id JOIN students ON assistance_requests.student_id=students.id JOIN cohorts ON students.cohort_id=cohorts.id WHERE cohorts.name='JUL02' GROUP BY teacher,cohort ORDER BY teacher;
true
52b27add50e6d65ac1804b0968a8b5b4f449661c
SQL
supercyberal/SQL-Scripts
/CPU Scripts/Performance - Signal Wait Time.sql
UTF-8
471
3.125
3
[]
no_license
/* Name: Signal Wait Time Source: Pinal Dave URL: http://blog.sqlauthority.com/2011/02/02/sql-server-signal-wait-time-introduction-with-simple-example-day-2-of-28/ */ -- Signal Waits for instance SELECT CAST(100.0 * SUM(signal_wait_time_ms) / SUM(wait_time_ms) AS NUMERIC(20,2)) AS [%signal (cpu) waits] , CAST(100.0 * SUM(wait_time_ms - signal_wait_time_ms) / SUM(wait_time_ms) AS NUMERIC(20, 2)) AS [%resource waits] FROM sys.dm_os_wait_stats OPTION ( RECOMPILE );
true
08d61ff448f4b2bdb0310c2fede763272fada57e
SQL
MinhNhat1133/Rocket_12
/SQL/Assignment3/Testing_System_Assignment_3.sql
UTF-8
2,385
4.125
4
[]
no_license
-- ==============Exercise 1: Tiếp tục với Database Testing System -- Question 1: Tạo view có chứa danh sách nhân viên thuộc phòng ban sale DROP VIEW IF EXISTS testingsystem.DanhSachNV_Sale; CREATE VIEW testingsystem.DanhSachNV_sale AS SELECT A.*,D.DepartmentName FROM testingsystem.`account` A JOIN testingsystem.department D ON A.DepartmentID = D.DepartmentID WHERE D.DepartmentName = 'sale'; SELECT * FROM testingsystem.DanhSachNV_Sale; -- Question 2: Tạo view có chứa thông tin các account tham gia vào nhiều group nhất DROP VIEW IF EXISTS testingsystem.Ac_ThamGiaNHieuGroupNhat; CREATE VIEW testingsystem.Ac_ThamGiaNHieuGroupNhat AS SELECT A.*,count(GA.AccountID) as Tong_Group_Tham_gia FROM testingsystem.`account` A JOIN testingsystem.groupaccount GA ON A.AccountID = GA.AccountID GROUP BY GA.AccountID HAVING count(GA.AccountID ) = (SELECT max(total) as 'max' FROM (SELECT count(AccountID) as total FROM testingsystem.groupaccount GROUP BY AccountID ) AS AB); SELECT * FROM testingsystem.Ac_ThamGiaNHieuGroupNhat; -- Question 3: Tạo view có chứa câu hỏi có những content quá dài DROP VIEW IF EXISTS testingsystem.Questions_co_Content_qua_dai; CREATE VIEW testingsystem.Questions_co_Content_qua_dai AS SELECT * FROM testingsystem.question WHERE char_length(content) >= 30 ; SELECT * FROM testingsystem.Questions_co_Content_qua_dai; -- Question 4: Tạo view có chứa danh sách các phòng ban có nhiều nhân viên nhất DROP VIEW IF EXISTS testingsystem.PhongBanCoNhieu_Nv_Nhat; CREATE VIEW testingsystem.PhongBanCoNhieu_Nv_Nhat AS SELECT D.*,count(A.DepartmentID) as 'TongNV' FROM testingsystem.department D JOIN testingsystem.`account` A ON D.DepartmentID = A.DepartmentID GROUP BY A.DepartmentID HAVING count(A.DepartmentID) = (SELECT max(Total) as "max" from (SELECT count(DepartmentID) as total FROM `Account` GROUP BY DepartmentID ) as ST ); SELECT * FROM testingsystem.PhongBanCoNhieu_Nv_Nhat; -- Question 5: Tạo view có chứa tất các các câu hỏi do user họ Nguyễn tạo DROP VIEW IF EXISTS testingsystem.CH_cua_user_ho_Nguyen; CREATE VIEW testingsystem.CH_cua_user_ho_Nguyen as SELECT Q.*, A.FullName FROM testingsystem.question Q JOIN testingsystem.`account` A ON Q.CreatorID = A.AccountID WHERE A.FullName like 'Nguyen%'; SELECT * FROM testingsystem.CH_cua_user_ho_Nguyen;
true
ffcefc9538f370219e5b9573d389cfd52b0371f1
SQL
izelyekrek/lab-sql-5
/Lab 5.sql
UTF-8
2,210
4.25
4
[]
no_license
use sakila; -- 1. Drop column `picture` from `staff`. alter table staff drop column picture; -- 2. A new person is hired to help Jon. Her name is TAMMY SANDERS, and she is a customer. Update the database accordingly. select * from staff; insert into staff values (3, 'Tammy', 'Sanders', 5 , 'Tammy.Sanders@sakilastaff.com', 2, 1, 'Tammy', ' ', now()); -- 3. Add rental for movie "Academy Dinosaur" by Charlotte Hunter from Mike Hillyer at Store 1. You can use current date for the `rental_date` column in the `rental` table. -- **Hint**: Check the columns in the table rental and see what information you would need to add there. -- You can query those pieces of information. -- For eg., you would notice that you need `customer_id` information as well. -- To get that you can use the following query: select * from rental; select inventory_id from inventory; -- select customer_id from sakila.customer -- where first_name = 'CHARLOTTE' and last_name = 'HUNTER'; -- Use similar method to get `inventory_id`, `film_id`, and `staff_id`. insert into rental values (16050, now(), 4581, 130, (CURDATE()+1), 2, now()); -- 4. Delete non-active users, but first, create a _backup table_ `deleted_users` to store `customer_id`, `email`, and the `date` for the users that would be deleted. Follow these steps: -- 4.1 Check if there are any non-active users select * from customer where active = 0; -- 4.2 Create a table _backup table_ as suggested drop table if exists deleted_users; create table deleted_users ( customer_id int(22) unique not null, email varchar(50) default null, datee date not null, constraint primary key (customer_id) ); -- 4.3 Insert the non active users in the table _backup table_ INSERT INTO deleted_users (customer_id, email, datee) SELECT customer_id, email, last_update FROM customer WHERE active = 0; update deleted_users set datee = now() where datee = '2006-02-15'; select * from deleted_users; -- 4.4 Delete the non active users from the table _customer_ select * from customer; DELETE FROM customer WHERE EXISTS (SELECT customer_id, email, datee FROM deleted_users); -- I couldn't find the solution for the last question because I have a problem with a foreign key
true
df12d382151f1b4e515ae8920ef780614ccc6c43
SQL
marcopettorali/Smart-Fitness
/SQL/AggiornaTotEsecuzioni.sql
UTF-8
1,118
3.484375
3
[]
no_license
DELIMITER $$ DROP TRIGGER IF EXISTS Aggiorna_TotEsecuzioni$$ CREATE TRIGGER Aggiorna_TotEsecuzioni AFTER UPDATE ON PrestazioneEsercizio FOR EACH ROW BEGIN IF (NEW.TimestampFine IS NOT NULL AND OLD.TimestampFine IS NULL) THEN UPDATE Esercizio SET TotEsecuzioni=TotEsecuzioni + 1 WHERE CodEsercizio=NEW.Esercizio; UPDATE Esercizio SET TotVoto=TotVoto + NEW.ValutazionePrestazione WHERE CodEsercizio=NEW.Esercizio; UPDATE Esercizio SET TotDurata=TotDurata + TIME_TO_SEC(TIMEDIFF(NEW.TimestampFine, NEW.TimestampInizio)) WHERE CodEsercizio=NEW.Esercizio; END IF; END$$ DELIMITER ; SELECT * FROM esercizio WHERE CodEsercizio=4; INSERT INTO `PrestazioneEsercizio` (`ValutazionePrestazione`,`TimestampInizio`,`TimestampFine`,`Cliente`,`Esercizio`,`Durata`,`TempoRecupero`,`NumeroRipetizioni`) VALUES (NULL,"2017-07-02 15:00:00",NULL,"TNAJWU76Z04W587D",4,NULL,NULL,NULL); UPDATE PrestazioneEsercizio SET ValutazionePrestazione=7, TimestampFine = "2017-07-02 15:00:30", Durata=30 WHERE CodPrestazione = 201; SELECT * FROM esercizio WHERE CodEsercizio=4;
true
8ed8561f916a87fe77eb397f40f02a8ebbfedab9
SQL
CodeurLibreOuPresque/Back-end
/mysql/ANY.sql
UTF-8
528
3.96875
4
[]
no_license
// Les opérateurs ANY et ALL sont utilisés avec une clause WHERE ou HAVING. // L'opérateur ANY renvoie true si l'une des valeurs de la sous-requête répond à la condition. // L'opérateur ALL renvoie true si toutes les valeurs de sous-requêtes répondent à la condition. SELECT column_name(s) FROM table_name WHERE column_name operator ANY (SELECT column_name FROM table_name WHERE condition); SELECT column_name(s) FROM table_name WHERE column_name operator ALL (SELECT column_name FROM table_name WHERE condition);
true
ec4402c35b649d743444cbed5e4dd5fe79796bdf
SQL
EvgeniyKorukov/OracleDBA
/_dbakevlar_com_scripts/AWR Warehouse Scripts, (NEW!!)/awrw_ana_sqlid.sql
UTF-8
570
3.5625
4
[]
no_license
select s.snap_id, to_char(s.begin_interval_time,'HH24:MI') "Begin Time", sql.executions_delta "Exec Delta", sql.buffer_gets_delta "Buffer Gets", sql.disk_reads_delta "Disk Reads", sql.iowait_delta "IO Waits", sql.cpu_time_delta "CPU Time", sql.elapsed_time_delta "Elapsed" from dba_hist_sqlstat sql, dba_hist_snapshot s, dbsnmp.caw_dbid_mapping m where lower(m.target_name) = '&dbname' and m.new_dbid = s.dbid and s.dbid = sql.dbid and s.snap_id = sql.snap_id and s.begin_interval_time > sysdate -&days_bk and sql.sql_id='&sqlid' order by "Elapsed" /
true
14a37e70feee934172ff09d0f5f0e513d906b07e
SQL
LuizJarduli/Projetos_Web_Tecnico
/projetos_php_mySql/Banco de dados em php/biblioteca.sql
UTF-8
1,534
3.234375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 3.5.1 -- http://www.phpmyadmin.net -- -- Servidor: localhost -- Tempo de Geração: -- Versão do Servidor: 5.5.24-log -- Versão do PHP: 5.3.13 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 */; -- -- Banco de Dados: `biblioteca` -- CREATE DATABASE `biblioteca` DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci; USE `biblioteca`; -- -------------------------------------------------------- -- -- Estrutura da tabela `livros` -- CREATE TABLE IF NOT EXISTS `livros` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nome` varchar(255) COLLATE utf8_swedish_ci NOT NULL, `autor` varchar(255) COLLATE utf8_swedish_ci NOT NULL, `genero` varchar(255) COLLATE utf8_swedish_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci AUTO_INCREMENT=138 ; -- -- Extraindo dados da tabela `livros` -- INSERT INTO `livros` (`id`, `nome`, `autor`, `genero`) VALUES (1, 'Livro 1', 'escré velivro', 'genero'), (137, 'livro 4', 'larissa assiral', 'comédia'), (136, 'livro 3', 'luiz ziul', 'genero'), (135, 'Livro 2', 'manoel leonam', 'genero'); /*!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
b5c3f555451299b14647c29c921ee5241469362a
SQL
coffman21/dwh
/tpc-h/anchor-modelling.sql
UTF-8
11,268
2.953125
3
[]
no_license
create schema dwh_anchor_modelling; SET SEARCH_PATH = 'dwh_anchor_modelling'; create table A_PART ( A_PART_SK bigint not null primary key, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table A_REGION ( A_REGION_SK bigint not null primary key, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table A_NATION ( A_NATION_SK bigint not null primary key, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table A_SUPPLIER ( A_SUPPLIER_SK bigint not null primary key, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table A_CUSTOMER ( A_CUSTOMER_SK bigint not null primary key, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table A_PARTSUPP ( A_PARTSUPP_SK bigint not null primary key, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table A_ORDERS ( A_ORDERS_SK bigint not null primary key, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table A_LINEITEM ( A_LINEITEM_SK bigint not null primary key, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table ATTR_PART_NAME ( A_PART_SK bigint not null primary key references A_PART, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, NAME varchar(55) ); create table ATTR_PART_MFGR ( A_PART_SK bigint not null primary key references A_PART, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, MFGR char(25) ); create table ATTR_PART_BRAND ( A_PART_SK bigint not null primary key references A_PART, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, BRAND char(10) ); create table ATTR_PART_TYPE ( A_PART_SK bigint not null primary key references A_PART, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, TYPE varchar(25) ); create table ATTR_PART_SIZE ( A_PART_SK bigint not null primary key references A_PART, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, SIZE integer ); create table ATTR_PART_CONTAINER ( A_PART_SK bigint not null primary key references A_PART, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, CONTAINER char(10) ); create table ATTR_PART_RETAILPRICE ( A_PART_SK bigint not null primary key references A_PART, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, RETAILPRICE decimal ); create table ATTR_PART_COMMENT ( A_PART_SK bigint not null primary key references A_PART, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, COMMENT varchar(23) ); create table ATTR_REGION_NAME ( A_REGION_SK bigint not null primary key references A_REGION, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, NAME char(25) ); create table ATTR_REGION_COMMENT ( A_REGION_SK bigint not null primary key references A_REGION, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, COMMENT varchar(152) ); create table ATTR_NATION_NAME ( A_NATION_SK bigint not null primary key references A_NATION, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, NAME char(25) ); create table ATTR_NATION_COMMENT ( A_NATION_SK bigint not null primary key references A_NATION, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, COMMENT varchar(152) ); create table ATTR_SUPPLIER_NAME ( A_SUPPLIER_SK bigint not null primary key references A_SUPPLIER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, NAME char(25) ); create table ATTR_SUPPLIER_ADDRESS ( A_SUPPLIER_SK bigint not null primary key references A_SUPPLIER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, ADDRESS varchar(40) ); create table ATTR_SUPPLIER_PHONE ( A_SUPPLIER_SK bigint not null primary key references A_SUPPLIER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, PHONE char(15) ); create table ATTR_SUPPLIER_ACCTBAL ( A_SUPPLIER_SK bigint not null primary key references A_SUPPLIER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, ACCTBAL decimal ); create table ATTR_SUPPLIER_COMMENT ( A_SUPPLIER_SK bigint not null primary key references A_SUPPLIER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, COMMENT varchar(101) ); create table ATTR_CUSTOMER_NAME ( A_CUSTOMER_SK bigint not null primary key references A_CUSTOMER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, NAME varchar(25) ); create table ATTR_CUSTOMER_ADDRESS ( A_CUSTOMER_SK bigint not null primary key references A_CUSTOMER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, ADDRESS varchar(40) ); create table ATTR_CUSTOMER_PHONE ( A_CUSTOMER_SK bigint not null primary key references A_CUSTOMER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, PHONE char(15) ); create table ATTR_CUSTOMER_ACCTBAL ( A_CUSTOMER_SK bigint not null primary key references A_CUSTOMER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, ACCTBAL decimal ); create table ATTR_CUSTOMER_MKTSEGMENT ( A_CUSTOMER_SK bigint not null primary key references A_CUSTOMER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, MKTSEGMENT char(10) ); create table ATTR_CUSTOMER_COMMENT ( A_CUSTOMER_SK bigint not null primary key references A_CUSTOMER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, COMMENT varchar(117) ); create table ATTR_PARTSUPP_AVAILQUY ( A_PARTSUPP_SK bigint not null primary key references A_PARTSUPP, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, AVAILQUY int ); create table ATTR_PARTSUPP_SYPPLYCOST ( A_PARTSUPP_SK bigint not null primary key references A_PARTSUPP, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, SYPPLYCOST decimal ); create table ATTR_PARTSUPP_COMMENT ( A_PARTSUPP_SK bigint not null primary key references A_PARTSUPP, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, COMMENT varchar(199) ); create table ATTR_ORDERS_ORDERSTATUS ( A_ORDERS_SK bigint not null primary key references A_ORDERS, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, ORDERSTATUS varchar(1) ); create table ATTR_ORDERS_ORDERDATE ( A_ORDERS_SK bigint not null primary key references A_ORDERS, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, ORDERDATE date ); create table ATTR_ORDERS_ORDERPRIORITY ( A_ORDERS_SK bigint not null primary key references A_ORDERS, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, ORDERPRIORITY char(15) ); create table ATTR_ORDERS_CLERK ( A_ORDERS_SK bigint not null primary key references A_ORDERS, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, CLERK char(15) ); create table ATTR_ORDERS_SHIPPRIORITY ( A_ORDERS_SK bigint not null primary key references A_ORDERS, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, SHIPPRIORITY int ); create table ATTR_ORDERS_COMMENT ( A_ORDERS_SK bigint not null primary key references A_ORDERS, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, COMMENT varchar(79) ); create table ATTR_LINEITEM_QUANTITY ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, QUANTITY decimal ); create table ATTR_LINEITEM_EXTENDEDPRICE ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, EXTENDEDPRICE decimal ); create table ATTR_LINEITEM_DISCOUNT ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, DISCOUNT decimal ); create table ATTR_LINEITEM_TAX ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, TAX decimal ); create table ATTR_LINEITEM_RETURNFLAG ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, RETURNFLAG char(1) ); create table ATTR_LINEITEM_LINESTATUS ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, LINESTATUS char(1) ); create table ATTR_LINEITEM_SHIPDATE ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, SHIPDATE date ); create table ATTR_LINEITEM_COMMITDATE ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, COMMITDATE date ); create table ATTR_LINEITEM_RECEIPTDATE ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, RECEIPTDATE date ); create table ATTR_LINEITEM_SHIPINSTRICT ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, SHIPINSTRICT char(25) ); create table ATTR_LINEITEM_SHIPMODE ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, SHIPMODE char(10) ); create table ATTR_LINEITEM_COMMENT ( A_LINEITEM_SK bigint not null primary key references A_LINEITEM, TIMESTAMP timestamp, SOURCE_SYSTEM varchar, COMMENT varchar(44) ); create table T_REGION_NATION ( T_REGION_NATION_SK bigint not null primary key, A_REGION_SK bigint unique references A_REGION, A_NATION_SK bigint unique references A_NATION, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table T_NATION_SUPP ( T_NATION_SUPP_SK bigint not null primary key, A_NATION_SK bigint unique references A_NATION, A_SUPP_SK bigint unique references A_SUPPLIER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table T_NATION_CUST ( T_NATION_CUST_SK bigint not null primary key, A_NATION_SK bigint unique references A_NATION, A_CUST_SK bigint unique references A_CUSTOMER, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table T_CUSTOMER_ORDER ( T_CUSTOMER_ORDER_SK bigint not null primary key, A_CUST_SK bigint unique references A_CUSTOMER, A_ORDER_SK bigint unique references A_ORDERS, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table T_LINEITEM_ORDER ( T_LINEITEM_ORDER_SK bigint not null primary key, A_LINEITEM_SK bigint unique references A_LINEITEM, A_ORDER_SK bigint unique references A_ORDERS, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table T_PART_PARTSUPP ( T_PART_PARTSUPP_SK bigint not null primary key, A_PART_SK bigint unique references A_PART, A_PARTSUPP_SK bigint unique references A_PARTSUPP, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table T_SUPP_PARTSUPP ( T_SUPP_PARTSUPP_SK bigint not null primary key, A_SUPP_SK bigint unique references A_SUPPLIER, A_PARTSUPP_SK bigint unique references A_PARTSUPP, TIMESTAMP timestamp, SOURCE_SYSTEM varchar ); create table T_PARTSUPP_ORDER ( T_PARTSUPP_ORDER_SK bigint not null primary key, A_PARTSUPP_SK bigint unique references A_PARTSUPP, A_ORDER_SK bigint unique references A_ORDERS, TIMESTAMP timestamp, SOURCE_SYSTEM varchar );
true
d0ac6cc173eb9070f618889a7052e46df7942ed1
SQL
401256352/yoshop_pros
/doc/database/upgrade/v1.1.8.sql
UTF-8
395
2.96875
3
[]
no_license
# 商品规格表:规格图片 ALTER TABLE `yoshop_goods_sku` ADD COLUMN `image_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '规格图片id' AFTER `spec_sku_id`; # 用户收货地址表:新市辖区 ALTER TABLE `yoshop_user_address` ADD COLUMN `district` varchar(255) NULL DEFAULT '' COMMENT '新市辖区(该字段用于记录region表中没有的市辖区)' AFTER `region_id`;
true
f9e626ba3b32c12ee4fdd785f8378e8c190da132
SQL
adamKonyari/Simple-SQL
/simple.sql
UTF-8
1,849
3.703125
4
[]
no_license
DROP TABLE IF EXISTS customer CASCADE; DROP TABLE IF EXISTS orders CASCADE; DROP TABLE IF EXISTS order_detail; DROP TABLE IF EXISTS product; CREATE TABLE customer ( CustomerID SERIAL NOT null , CompanyName character varying(40) NOT NULL, ContactName character varying(30), ContactTitle character varying(30), Address character varying(60), City character varying(15), Region character varying(15), PostalCode character varying(10), Country character varying(15), Phone character varying(24), Fax character varying(24) ); CREATE TABLE orders ( OrderID SERIAL NOT NULL, CustomerID bpchar, EmployeeID smallint, OrderDate date, RequiredDate date, ShippedDate date, ShipVia smallint, Freight real, ShipName character varying(40), ShipAddress character varying(60), ShipCity character varying(15), ShipRegion character varying(15), ShipPostalCode character varying(10), ShipCountry character varying(15) ); CREATE TABLE order_detail ( OrderID SERIAL NOT NULL, ProductID smallint NOT NULL, UnitPrice real NOT NULL, Quantity smallint NOT NULL, Discount real NOT NULL ); CREATE TABLE product ( ProductID SERIAL NOT NULL, ProductName character varying(40) NOT NULL, SupplierID smallint, CategoryID smallint, QuantityPerUnit character varying(20), UnitPrice real, UnitsInStock smallint, UnitsOnOrder smallint, ReorderLevel smallint, Discontinued integer ); ALTER TABLE ONLY customer ADD CONSTRAINT pk_customer PRIMARY KEY (CustomerID); ALTER TABLE ONLY orders ADD CONSTRAINT pk_order PRIMARY KEY (OrderID); ALTER TABLE ONLY order_detail ADD CONSTRAINT pk_order_detail PRIMARY KEY (OrderID,ProductID); ALTER TABLE ONLY product ADD CONSTRAINT pk_product PRIMARY KEY (ProductID);
true
0a9d3432129048d058ade71b1273c779cf9615a1
SQL
ckh0618/StandardBMT
/crt.sql
UTF-8
277
2.5625
3
[ "Apache-2.0" ]
permissive
DROP TABLE IF EXISTS TEST_01; CREATE TABLE TEST_01 ( C1 INTEGER PRIMARY KEY, C2 VARCHAR(100) , C3 VARCHAR(100) , C4 VARCHAR(100) , C5 VARCHAR(100) , C6 VARCHAR(100) , C7 VARCHAR(100) , C8 VARCHAR(100) , C9 INT, C10 DATE ) ; COMMIT;
true
5a24ca11b41f383a411f76f661bd83c2fe8403b9
SQL
vijaydairyf/TimelyFish
/CFDataStore/stage/Views/stage.vw_CFT_ANIMALEVENT_pregnancyExam.sql
UTF-8
1,550
3.5
4
[]
no_license
CREATE VIEW [stage].[vw_CFT_ANIMALEVENT_pregnancyExam] AS SELECT ID = preg.SourceGUID , DELETED_BY = ISNULL( preg.DeletedBy, -1 ) , ANIMALID = a.SourceGUID , PARITYNUMBER = pe.ParityNumber , EVENTTYPEID = testResult.EventID , EVENTDATE = eDate.FullDate , QTY = CAST( -1 AS INT ) , EVENTTHDATE = eDate.PICCycleAndDay , SOURCEFARMID = farms.SourceGUID , REMOVALREASONID = CAST( -1 AS int ) , SYNCSTATUS = N'Valid' , MFSYNC = N'Y' , ANIMALSTATUS = testResult.animalStatus , PIGCHAMP_ID = preg.SourceID FROM fact.PregnancyExamEvent AS preg INNER JOIN fact.ParityEvent AS pe ON pe.ParityEventKey = preg.ParityEventKey INNER JOIN dimension.Animal AS a ON a.AnimalKey = pe.AnimalKey INNER JOIN stage.ParityEvent AS peStage ON peStage.ParityEventKey = pe.ParityEventKey INNER JOIN( SELECT CAST( 1 AS bit), ID, CAST( 2 AS int ) FROM stage.CFT_EVENTTYPE WHERE EVENTTYPE = N'Breed' AND EVENTNAME = N'Preg Test Positive' UNION SELECT CAST( 0 AS bit), ID, CAST( 1 AS int ) FROM stage.CFT_EVENTTYPE WHERE EVENTTYPE = N'Breed' AND EVENTNAME = N'Preg Test Negative' ) AS testResult( result, EventID, animalStatus ) ON testResult.result = preg.IsPositive INNER JOIN dimension.Date AS eDate ON eDate.DateKey = preg.EventDateKey LEFT JOIN stage.BH_EVENTS_ALL as allEvents ON allEvents.event_id = preg.SourceID LEFT JOIN dimension.Farm as farms ON farms.SourceID = allEvents.site_id;
true
31e408d8a43d989b0dbd1790351b273b9b2e4561
SQL
carbon8/Sportscar-Standings
/App_Data/Install/SQL Folder/Objects/Proc_Chat_SafeDeleteRoom.sql
UTF-8
282
3.109375
3
[]
no_license
CREATE PROCEDURE [Proc_Chat_SafeDeleteRoom] @ChatRoomID INT, @AfterHours INT AS BEGIN EXEC Proc_Chat_DisableRoom @ChatRoomID = @ChatRoomID UPDATE Chat_Room SET ChatRoomScheduledToDelete = DATEADD(hh, @AfterHours, GETDATE()) WHERE ChatRoomID = @ChatRoomID END
true
2f0bfa58ea60f90d1c2e06f4b1250f37498b91e0
SQL
NguyenHaiHa1992/sangovietphat
/tbl_system_address_2017-07-04T11_28_282017-07-04 11-29-18.sql
UTF-8
965
2.671875
3
[]
no_license
SELECT * FROM sangovietphat.tbl_system_address INSERT INTO `sangovietphat`.`tbl_system_address`(`id`,`parent_id`,`name`,`content`,`status`,`order_view`,`created_time`,`created_by`) VALUES (1,1,'Tại Hà Nội','Địa chỉ 1: Số 31 Ngọc Đại , Phường Đại Mỗ , Quận Nam Từ Liêm , Hà Nội Điện thoại : 043.200.2097 - 0982 088 969',1,0,null,null); INSERT INTO `sangovietphat`.`tbl_system_address`(`id`,`parent_id`,`name`,`content`,`status`,`order_view`,`created_time`,`created_by`) VALUES (2,2,'Hải phòng','Đia chỉ 1: 80 Nguyễn Bỉnh Khiêm - Quận Ngô Quyền, Hải phòng Điện thoại : 0313.734.270 - 0904.334.667',1,1,null,null); INSERT INTO `sangovietphat`.`tbl_system_address`(`id`,`parent_id`,`name`,`content`,`status`,`order_view`,`created_time`,`created_by`) VALUES (3,2,'Hải phòng','Địa chỉ 2: Số 10 Nguyễn Văn Linh - Quận Lê Chân - Hải Phòng Điện thoại : 0313.622.928 - 0934.316.230',1,2,null,null);
true
7d9b59cd989a2e9ea13748d63b3dccdc870e5236
SQL
jaegomez/burger
/db/schema.sql
UTF-8
233
2.6875
3
[]
no_license
create schema `burgers_db`; use `burgers_db`; create table `burgers`( `id` int not null auto_increment, `burger_name` varchar(50) not null, `devoured` boolean default false, `date` datetime default null, primary key (`id`) );
true
20e75833786f62a0db9ea398c7919942b2b91d12
SQL
bastianluk/MFFUK
/Web Applications Programming/ShoppingList/temp/db_sample.sql
UTF-8
3,023
3.5
4
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.4.10 -- http://www.phpmyadmin.net -- -- Host: localhost:3306 -- Generation Time: Dec 02, 2018 at 12:37 AM -- Server version: 5.7.21-log -- PHP Version: 7.1.7 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 */; -- -- Database: `shopping_list_webapp_assignment` -- -- -------------------------------------------------------- DROP TABLE IF EXISTS `list`; DROP TABLE IF EXISTS `items`; -- -- Table structure for table `items` -- CREATE TABLE IF NOT EXISTS `items` ( `id` int(10) unsigned NOT NULL COMMENT 'ID of the item that can appear on the list.', `name` varchar(100) COLLATE utf8mb4_bin NOT NULL COMMENT 'Name of the item.' ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='A lookup table of all items that an be added to a shopping list.'; -- -- Dumping data for table `items` -- INSERT INTO `items` (`id`, `name`) VALUES (4, 'beer'), (1, 'bread'), (2, 'butter'), (5, 'chocolate'), (9, 'instant soup'), (3, 'milk'), (6, 'pork chops'), (8, 'potatoes'), (7, 'tomatoes'); -- -------------------------------------------------------- -- -- Table structure for table `list` -- CREATE TABLE IF NOT EXISTS `list` ( `id` int(10) unsigned NOT NULL COMMENT 'ID of the list item.', `item_id` int(10) unsigned NOT NULL COMMENT 'FK to the items table.', `amount` int(11) NOT NULL COMMENT 'Required amount (how much we need of this particular item).', `position` int(11) NOT NULL COMMENT 'Shopping list order.' ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; -- -- Dumping data for table `list` -- INSERT INTO `list` (`id`, `item_id`, `amount`, `position`) VALUES (1, 1, 3, 1), (2, 2, 4, 2), (3, 3, 1, 3), (4, 4, 5, 4); -- -- Indexes for dumped tables -- -- -- Indexes for table `items` -- ALTER TABLE `items` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `name` (`name`); -- -- Indexes for table `list` -- ALTER TABLE `list` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `item_id` (`item_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `items` -- ALTER TABLE `items` MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID of the item that can appear on the list.',AUTO_INCREMENT=10; -- -- AUTO_INCREMENT for table `list` -- ALTER TABLE `list` MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID of the list item.',AUTO_INCREMENT=5; -- -- Constraints for dumped tables -- -- -- Constraints for table `list` -- ALTER TABLE `list` ADD CONSTRAINT `items_fk` FOREIGN KEY (`item_id`) REFERENCES `items` (`id`); /*!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
9123fdce5fe4b89247c6e31f2dd2e8a5b2a0b0ff
SQL
rogeliomolina1/CMPS-180
/Lab1/create.sql
UTF-8
770
3.453125
3
[]
no_license
-- Create Tables CREATE TABLE Exchanges ( exchangeID CHAR(6) PRIMARY KEY, exchangeName VARCHAR(30), address VARCHAR(30) ); CREATE TABLE Stocks ( exchangeID CHAR(6), symbol CHAR(4), stockName VARCHAR(30), address VARCHAR(30), PRIMARY KEY (exchangeID, symbol) ); CREATE TABLE Customers ( customerID INT PRIMARY KEY, custName VARCHAR(30), address VARCHAR(30), category CHAR(1), isValidCustomer BOOLEAN ); CREATE TABLE Trades ( exchangeID CHAR(6), symbol CHAR(4), tradeTS TIMESTAMP, buyerID INT, sellerID INT, price DECIMAL(7,2), volume INT, PRIMARY KEY (exchangeID, symbol, tradeTS) ); CREATE TABLE Quotes ( exchangeID CHAR(6), symbol CHAR(4), quoteTS TIMESTAMP, price DECIMAL(7,2), PRIMARY KEY (exchangeID, symbol, quoteTS) );
true