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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9de4bae54cfa352f0d883716cb9c43516147e630 | SQL | zhouquanq/phpNotes | /message/message.sql | UTF-8 | 918 | 2.640625 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : wamp3
Source Server Version : 50709
Source Host : 127.0.0.1:3306
Source Database : bbs
Target Server Type : MYSQL
Target Server Version : 50709
File Encoding : 65001
Date: 2018-08-30 10:03:29
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `message`
-- ----------------------------
DROP TABLE IF EXISTS `message`;
CREATE TABLE `message` (
`id` tinyint(1) NOT NULL AUTO_INCREMENT,
`user` varchar(25) NOT NULL DEFAULT '',
`content` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of message
-- ----------------------------
INSERT INTO `message` VALUES ('1', '测试1', '123');
INSERT INTO `message` VALUES ('2', '测试2', '234');
INSERT INTO `message` VALUES ('3', '测试3', '345');
| true |
dda8fe81cb18065cdeca4dcb7bfaedc7af1c767e | SQL | mihkell/aproject | /src/main/sql/etsydbbackup.sql | UTF-8 | 5,778 | 2.8125 | 3 | [] | no_license | --
-- PostgreSQL database dump
--
-- Dumped from database version 9.3.0
-- Dumped by pg_dump version 9.3.0
-- Started on 2014-04-24 15:31:08
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- TOC entry 174 (class 3079 OID 11750)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- TOC entry 1959 (class 0 OID 0)
-- Dependencies: 174
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 170 (class 1259 OID 37248)
-- Name: channel; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE channel (
id integer NOT NULL,
description character varying(255),
name character varying(255)
);
ALTER TABLE public.channel OWNER TO postgres;
--
-- TOC entry 171 (class 1259 OID 37254)
-- Name: hibernate_sequence; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE hibernate_sequence
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.hibernate_sequence OWNER TO postgres;
--
-- TOC entry 172 (class 1259 OID 37256)
-- Name: program; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE program (
id integer NOT NULL,
name character varying(255),
program_type character varying(255)
);
ALTER TABLE public.program OWNER TO postgres;
--
-- TOC entry 173 (class 1259 OID 37262)
-- Name: schedule; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE schedule (
id integer NOT NULL,
length bigint NOT NULL,
starttime bigint NOT NULL,
channel_id integer,
program_id integer
);
ALTER TABLE public.schedule OWNER TO postgres;
--
-- TOC entry 1948 (class 0 OID 37248)
-- Dependencies: 170
-- Data for Name: channel; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO channel VALUES (8, 'fox', 'Fox news');
INSERT INTO channel VALUES (9, '', 'CNBC');
--
-- TOC entry 1960 (class 0 OID 0)
-- Dependencies: 171
-- Name: hibernate_sequence; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('hibernate_sequence', 39, true);
--
-- TOC entry 1950 (class 0 OID 37256)
-- Dependencies: 172
-- Data for Name: program; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO program VALUES (1, 'Charlie Rose', 'News');
INSERT INTO program VALUES (2, 'Matrix', 'Movie');
INSERT INTO program VALUES (3, 'Lione king', 'Kids');
INSERT INTO program VALUES (4, 'Seven News', 'News');
INSERT INTO program VALUES (5, 'Tom and Jerry', 'Kids');
INSERT INTO program VALUES (6, 'StarWars', 'Movie');
INSERT INTO program VALUES (7, 'House of cards', 'Movie');
--
-- TOC entry 1951 (class 0 OID 37262)
-- Dependencies: 173
-- Data for Name: schedule; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO schedule VALUES (21, 900000, 1388531748382, 8, 1);
INSERT INTO schedule VALUES (22, 900000, 1388532650963, 8, 1);
INSERT INTO schedule VALUES (24, 900000, 1388535344524, 8, 1);
INSERT INTO schedule VALUES (25, 900000, 1388536256387, 8, 1);
INSERT INTO schedule VALUES (26, 900000, 1388618151584, 8, 2);
INSERT INTO schedule VALUES (27, 900000, 1388704555319, 8, 3);
INSERT INTO schedule VALUES (28, 900000, 1388790958971, 8, 4);
INSERT INTO schedule VALUES (29, 900000, 1388877303523, 8, 5);
INSERT INTO schedule VALUES (30, 900000, 1389050107411, 8, 6);
INSERT INTO schedule VALUES (31, 900000, 1388531715558, 9, 1);
INSERT INTO schedule VALUES (32, 900000, 1388618119183, 9, 2);
INSERT INTO schedule VALUES (33, 900000, 1388704522591, 9, 3);
INSERT INTO schedule VALUES (34, 900000, 1388790927003, 9, 4);
INSERT INTO schedule VALUES (35, 900000, 1388877330375, 9, 5);
INSERT INTO schedule VALUES (36, 900000, 1388963734315, 9, 6);
INSERT INTO schedule VALUES (37, 900000, 1389050137839, 9, 7);
INSERT INTO schedule VALUES (38, 900000, 1388533541749, 9, 1);
INSERT INTO schedule VALUES (39, 900000, 1388705456845, 9, 1);
--
-- TOC entry 1834 (class 2606 OID 37266)
-- Name: channel_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY channel
ADD CONSTRAINT channel_pkey PRIMARY KEY (id);
--
-- TOC entry 1836 (class 2606 OID 37268)
-- Name: program_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY program
ADD CONSTRAINT program_pkey PRIMARY KEY (id);
--
-- TOC entry 1838 (class 2606 OID 37270)
-- Name: schedule_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY schedule
ADD CONSTRAINT schedule_pkey PRIMARY KEY (id);
--
-- TOC entry 1839 (class 2606 OID 37271)
-- Name: fk_3hivp9yuw5lj2tw94flb5ok6f; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY schedule
ADD CONSTRAINT fk_3hivp9yuw5lj2tw94flb5ok6f FOREIGN KEY (channel_id) REFERENCES channel(id);
--
-- TOC entry 1840 (class 2606 OID 37276)
-- Name: fk_ofbe9nh7r6f1twui1pb7y5fh4; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY schedule
ADD CONSTRAINT fk_ofbe9nh7r6f1twui1pb7y5fh4 FOREIGN KEY (program_id) REFERENCES program(id);
--
-- TOC entry 1958 (class 0 OID 0)
-- Dependencies: 6
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
-- Completed on 2014-04-24 15:31:09
--
-- PostgreSQL database dump complete
--
| true |
3be1dbf45d5f0a7bf850612cc96d89c26bc2f731 | SQL | marin-zaimov/4475project | /db/first-4-15-13.sql | UTF-8 | 2,559 | 3.859375 | 4 | [] | no_license | 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';
-- -----------------------------------------------------
-- Table `4475project`.`projects`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `4475project`.`projects` ;
CREATE TABLE IF NOT EXISTS `4475project`.`projects` (
`id` INT NOT NULL ,
`name` VARCHAR(255) NULL ,
`date` DATETIME NOT NULL ,
`description` MEDIUMTEXT NULL ,
`uploadedBy` VARCHAR(255) NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `4475project`.`images`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `4475project`.`images` ;
CREATE TABLE IF NOT EXISTS `4475project`.`images` (
`id` INT NOT NULL ,
`projectId` INT NOT NULL ,
`order` INT NULL ,
`type` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_images_1` (`projectId` ASC) ,
CONSTRAINT `fk_images_1`
FOREIGN KEY (`projectId` )
REFERENCES `4475project`.`projects` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `4475project`.`algorithms`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `4475project`.`algorithms` ;
CREATE TABLE IF NOT EXISTS `4475project`.`algorithms` (
`id` INT NOT NULL ,
`name` VARCHAR(255) NOT NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `4475project`.`algorithm2project`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `4475project`.`algorithm2project` ;
CREATE TABLE IF NOT EXISTS `4475project`.`algorithm2project` (
`algorithmId` INT NOT NULL ,
`projectId` INT NOT NULL ,
`date` DATETIME NOT NULL ,
PRIMARY KEY (`projectId`, `algorithmId`) ,
INDEX `fk_algorithm2project_1` (`algorithmId` ASC) ,
INDEX `fk_algorithm2project_2` (`projectId` ASC) ,
CONSTRAINT `fk_algorithm2project_1`
FOREIGN KEY (`algorithmId` )
REFERENCES `4475project`.`algorithms` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_algorithm2project_2`
FOREIGN KEY (`projectId` )
REFERENCES `4475project`.`projects` (`id` )
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 |
4d73bda3878bb8aacf19a4307953dd89e45741cc | SQL | hyejin000112/portfolio | /src/main/java/com/zerostress/controller/QnA.sql | UTF-8 | 555 | 3.328125 | 3 | [] | no_license | create table QnA(
bno number(10,0),
writer varchar2(50),
title varchar2(100),
content varchar2(1000),
regDate date default sysdate,
updateDate date default sysdate
);
create sequence QnA_seq INCREMENT by 1 start with 1 NOCACHE;
alter table QnA add CONSTRAINT QnA_pk PRIMARY KEY(bno);
select * from QnA;
create table qna(
bno int(10) not null auto_increment primary key,
writer varchar(50),
title varchar(100),
content varchar(1000),
regDate TIMESTAMP DEFAULT NOW(),
updateDate TIMESTAMP DEFAULT NOW()
); | true |
a2839d879176b6fb6a153312ae2ef083f3a1dba5 | SQL | Bastienmmc/AppPunissements | /BDD/sql.sql | UTF-8 | 2,582 | 3.5 | 4 | [] | no_license | #------------------------------------------------------------
# Script MySQL.
#------------------------------------------------------------
#------------------------------------------------------------
# Table: stagiaire
#------------------------------------------------------------
CREATE TABLE stagiaire(
id_stagiaire int (11) Auto_increment NOT NULL ,
name_stagiaire Varchar (50) NOT NULL ,
firstname_stagiaire Varchar (50) NOT NULL ,
path_photo_stagiaire Varchar (100) ,
id_groupe_groupe Int NOT NULL ,
PRIMARY KEY (id_stagiaire )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: groupe
#------------------------------------------------------------
CREATE TABLE groupe(
id_groupe int (11) Auto_increment NOT NULL ,
libelle_groupe Varchar (50) NOT NULL ,
path_photo_groupe Varchar (100) ,
PRIMARY KEY (id_groupe )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: punitions
#------------------------------------------------------------
CREATE TABLE punitions(
id_punitions int (11) Auto_increment NOT NULL ,
title_punitions Varchar (50) ,
description_punitions Varchar (500) ,
id_type_punitions_type_punitions Int NOT NULL ,
id_stagiaire_stagiaire Int NOT NULL ,
id_groupe_groupe Int NOT NULL ,
PRIMARY KEY (id_punitions )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: type_punitions
#------------------------------------------------------------
CREATE TABLE type_punitions(
id_type_punitions int (11) Auto_increment NOT NULL ,
title_type_punitions Varchar (50) NOT NULL ,
description_type_punitions Varchar (500) NOT NULL ,
PRIMARY KEY (id_type_punitions )
)ENGINE=InnoDB;
ALTER TABLE stagiaire ADD CONSTRAINT FK_stagiaire_id_groupe_groupe FOREIGN KEY (id_groupe_groupe) REFERENCES groupe(id_groupe);
ALTER TABLE punitions ADD CONSTRAINT FK_punitions_id_type_punitions_type_punitions FOREIGN KEY (id_type_punitions_type_punitions) REFERENCES type_punitions(id_type_punitions);
ALTER TABLE punitions ADD CONSTRAINT FK_punitions_id_stagiaire_stagiaire FOREIGN KEY (id_stagiaire_stagiaire) REFERENCES stagiaire(id_stagiaire);
ALTER TABLE punitions ADD CONSTRAINT FK_punitions_id_groupe_groupe FOREIGN KEY (id_groupe_groupe) REFERENCES groupe(id_groupe);
| true |
a7cac8919b1cfbe7058db720070c3cbb5473d277 | SQL | Duncan-Britt/LS180-Database-Foundations | /lesson_2/films.sql | UTF-8 | 1,137 | 3.96875 | 4 | [] | no_license | DROP TABLE IF EXISTS public.films;
CREATE TABLE films (title varchar(255), "year" integer, genre varchar(100));
INSERT INTO films(title, "year", genre) VALUES ('Die Hard', 1988, 'action');
INSERT INTO films(title, "year", genre) VALUES ('Casablanca', 1942, 'drama');
INSERT INTO films(title, "year", genre) VALUES ('The Conversation', 1974, 'thriller');
ALTER TABLE films
ADD COLUMN director text,
ADD COLUMN duration integer;
UPDATE films
SET (director, duration) = ('John McTiernan', 132)
WHERE title = 'Die Hard';
UPDATE films
SET (director, duration) = ('Michael Curtiz', 102)
WHERE title = 'Casablanca';
UPDATE films
SET (director, duration) = ('Francis Ford Coppola', 113)
WHERE title = 'The Conversation';
INSERT INTO films
VALUES('1984', 1956, 'scifi', 'Michael Anderson', 90),
('Tinker Tailor Soldier Spy', 2011, 'espionage', 'Tomas Alfredson', 127),
('The Birdcage', 1996, 'comedy', 'Mike Nichols', 118);
SELECT title, extract("year" from CURRENT_DATE) - year AS age FROM films
ORDER BY age;
SELECT title, duration FROM films WHERE duration > 120
ORDER BY duration DESC;
SELECT title FROM films
ORDER BY duration DESC
LIMIT 1;
| true |
7b7e284a459434a368ef9c0e00786dad155ae49b | SQL | yeto1991/test1 | /tags/rel_20140331/tags/rel_20130920/jmesse/schema/jm_fair_detail_cnt.sql | UTF-8 | 456 | 2.578125 | 3 | [] | no_license | create table jmesse.jm_fair_detail_cnt(
i_kbn_2 varchar (3) not null
, i_kbn_3 varchar (3) not null
, i_kbn_4 varchar (3) not null
, v_kbn_2 varchar (3) not null
, v_kbn_3 varchar (3) not null
, v_kbn_4 varchar (3) not null
, site_kbn char (1) not null
, fair_cnt int not null
, primary key (
i_kbn_2
, i_kbn_3
, i_kbn_4
, v_kbn_2
, v_kbn_3
, v_kbn_4
, site_kbn
)
) engine = innodb
| true |
3fa713f805ffe1681b6b5993b35156375a4e0da3 | SQL | albertkrdoyan/reg_log | /SQL/sql3.sql | UTF-8 | 296 | 2.625 | 3 | [] | no_license | use `mydb`;
-- UPDATE users SET uid = 'd257bf3219d6355ec1b3a9300a23f1ae' WHERE ID = 1;
-- DELETE FROM users WHERE id = 1;
-- ALTER TABLE users AUTO_INCREMENT=1;
-- DROP TABLE IF EXISTS `a0b53923da36b35102584347297bd656c`;
select * from users
-- select * from a0b53923da36b35102584347297bd656c | true |
ab466575b4642e9c7c387cf4fca5b1d02ec6a07b | SQL | OlafMd/MedCon1.0 | /mm-libs/dbaccess/Level 3/CL3_Projects/Atomic/Retrieval/SQL/cls_Get_RightPackages_for_ProjectMemberID.sql | UTF-8 | 943 | 3.359375 | 3 | [] | no_license |
Select
tms_pro_members_2_rightpackage.AssignmentID,
tms_pro_acc_rightspackages.Name_DictID,
tms_pro_acc_rightspackages.TMS_PRO_ACC_RightsPackageID,
usr_accounts.USR_AccountID
From
usr_accounts Inner Join
tms_pro_projectmembers On tms_pro_projectmembers.USR_Account_RefID =
usr_accounts.USR_AccountID Inner Join
tms_pro_members_2_rightpackage
On tms_pro_projectmembers.TMS_PRO_ProjectMemberID =
tms_pro_members_2_rightpackage.ProjectMember_RefID Inner Join
tms_pro_acc_rightspackages
On tms_pro_acc_rightspackages.TMS_PRO_ACC_RightsPackageID =
tms_pro_members_2_rightpackage.ACC_RightsPackage_RefID
Where
tms_pro_projectmembers.TMS_PRO_ProjectMemberID = @ProjectMemberID And
usr_accounts.IsDeleted = 0 And
tms_pro_projectmembers.IsDeleted = 0 And
tms_pro_members_2_rightpackage.IsDeleted = 0 And
tms_pro_acc_rightspackages.IsDeleted = 0 And
tms_pro_projectmembers.Tenant_RefID = @TenantID
| true |
457854f09b2fc122c343c79c58904efa917fe895 | SQL | 6thom6/Centre_d_entrainement_projet_tic_netcore_2020 | /SQLQuery_Cheval_vaccin.sql | UTF-8 | 214 | 2.953125 | 3 | [] | no_license | SELECT *
FROm Vaccination v
JOIN mym_Vaccination_Cheval m
ON m.VaccinationId_Vaccination = v.Id_vaccination
WHERE m.ChevalId_Cheval = (SELECT Id_Cheval FROM Cheval WHERE Nom_cheval = 'khani')
Select *
From
| true |
046111d2fdb56f6655aa74498db3ce2c97a50904 | SQL | Tenb8/projectG | /users.sql | UTF-8 | 5,397 | 2.75 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Client : 127.0.0.1
-- Généré le : Mer 18 Septembre 2019 à 19:15
-- Version du serveur : 5.6.17
-- Version de PHP : 5.5.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 */;
--
-- Base de données : `useraccounts`
--
-- --------------------------------------------------------
--
-- Structure de la table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nom` varchar(100) NOT NULL,
`prenom` varchar(100) NOT NULL,
`societe` varchar(100) NOT NULL,
`addresse` varchar(100) NOT NULL,
`ville` varchar(100) NOT NULL,
`pays` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`telephone` varchar(50) NOT NULL,
`message` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`),
KEY `id_2` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=62 ;
--
-- Contenu de la table `users`
--
INSERT INTO `users` (`id`, `nom`, `prenom`, `societe`, `addresse`, `ville`, `pays`, `email`, `telephone`, `message`) VALUES
(8, 'sakina', 'samira', 'Negtrans', 'vidri', 'abidjan', 'senegal', 'sakina@gmail.com', '748596123', ''),
(9, 'sakina', 'samira', 'Negtrans', 'vidri', 'abidjan', 'senegal', 'sakina@gmail.com', '748596123', ''),
(10, 'issouf', 'ouattara', 'OLAM', 'gonzak', 'toumodi', 'benin', 'issouf@gmail.com', '41526398', ''),
(11, 'flore', 'blanca', 'PIL', 'sipim', 'agboville', 'maroc', 'blanca@gmail.com', '741547414', ''),
(12, 'flore', 'blanca', 'PIL', 'sipim', 'agboville', 'maroc', 'blanca@gmail.com', '741547414', ''),
(13, 'yeo', 'tenena', 'PETROCI', 'treichville', 'Bondoukou', 'Ghana', 'yeo@gmail.com', '64785310', ''),
(21, 'Diakite', 'sekou', 'BICICI', 'treichville', 'Bondoukou', 'senegal', 'Fatim@gmail.com', '64785310', ''),
(22, 'ouattara', 'madou', 'PETROCI', 'treichville', 'Bondoukou', 'benin', 'sakina@gmail.com', '58653225863', ''),
(23, 'ouattara', 'madou', 'PETROCI', 'treichville', 'Bondoukou', 'benin', 'sakina@gmail.com', '58653225863', ''),
(24, 'ouattara Sekou', 'madou', 'OLAMO', '18rue', 'ouaga', 'burkina', 'madou@gmail.com', '01020300504', ''),
(33, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(34, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(35, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(36, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(37, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(38, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(39, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(40, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(41, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(42, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(43, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(44, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(45, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(46, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(47, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(48, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(49, 'Serge', 'emama', 'ecotrans', '205rue bizarre', 'bamako', 'Mali', 'serge@gmail.com', '01020300504', ''),
(50, 'Serge', 'sekou', 'OLAMO', 'couocu', 'maman', 'Cote divoire', 'sakina@gmail.com', '4125365241', ''),
(51, 'Serge', 'sekou', 'OLAMO', 'couocu', 'maman', 'Cote divoire', 'sakina@gmail.com', '4125365241', ''),
(52, 'Serge', 'sekou', 'OLAMO', 'couocu', 'maman', 'Cote divoire', 'sakina@gmail.com', '4125365241', ''),
(53, 'BACONGO', 'MOUSSA', 'MALEME', '205rue marseille', 'korogho', 'ethiopie', 'los@gmail.com', '4125365241', ''),
(54, 'iwi', 'i', 'i', 'kkefoj1', 'jdidid', 'Noiger', 'tenena190@gmail.com', '6892715392', ''),
(55, 'ouattara', 'lassina', 'Greenways-ci', 'virdi-cite', 'Man', 'Kenya', 'lasssina@gmail.fr', '4152636958', ''),
(56, 'ouattara', 'lassina', 'Greenways-ci', 'virdi-cite', 'Man', 'Kenya', 'lasssina@gmail.fr', '4152636958', ''),
(57, 'ouattara', 'lassina', 'Greenways-ci', 'virdi-cite', 'Man', 'Kenya', 'lasssina@gmail.fr', '4152636958', ''),
(58, 'Diakite', 'sekou', 'Negtrans', 'couocu', 'abidjan', 'benin', 'Fatim@gmail.com', '78591064', ''),
(59, 'Diakite', 'sekou', 'Negtrans', 'couocu', 'abidjan', 'benin', 'Fatim@gmail.com', '78591064', ''),
(60, 'Diakite', 'sekou', 'Negtrans', 'couocu', 'abidjan', 'Kenya', 'Fatim@gmail.com', '78591064', ''),
(61, 'Konan', 'ibrahim', 'Greenways-ci', 'vridi', 'abidjan', 'liberia', 'konan@gmail.com', '5555555555', '');
/*!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 |
0017ac4997dbfc6aa10de551106296b0310dfbdb | SQL | whdtx111/Java_softeem | /DataBase/作业答案.sql | UTF-8 | 6,572 | 4.5 | 4 | [] | no_license | #列出至少有一个员工的所有部门。
SELECT
*
FROM
dept
WHERE
deptno IN ( SELECT deptno FROM emp GROUP BY deptno );#IN === = any
SELECT
*
FROM
emp
WHERE
empno IN ( 7369, 7499, 7566 );#列出薪金比"刘一"多的所有员工。
SELECT
*
FROM
emp
WHERE
sal > ( SELECT sal FROM emp WHERE ename = '刘一' );# 列出所有员工的姓名及其直接上级的姓名。
SELECT
ename,
( SELECT ename FROM emp WHERE empno = s.mgr )
FROM
emp s;#列出受雇日期早于其直接上级的所有员工。
SELECT
e.*
FROM
emp e
WHERE
e.hiredate < ( SELECT hiredate FROM emp b WHERE b.empno = e.mgr ) #列出部门名称和这些部门的员工信息,同时列出那些没有员工的部门。
SELECT
dname,
emp.*
FROM
dept
LEFT JOIN emp ON dept.deptno = emp.deptno;#列出所有job为“职员”的姓名及其部门名称。
SELECT
dname,
emp.*
FROM
dept
LEFT JOIN emp ON dept.deptno = emp.deptno
WHERE
job = '职员';#列出最低薪金大于1500的各种工作。
SELECT
job
FROM
emp
GROUP BY
job
HAVING
min( sal ) > 1500;#列出在部门 "销售部" 工作的员工的姓名,假定不知道销售部的部门编号。
SELECT
ename
FROM
emp
WHERE
deptno = ( SELECT deptno FROM dept WHERE dname = '销售部' );#列出薪金高于公司平均薪金的所有员工。
SELECT
*
FROM
emp
WHERE
emp.sal > ( SELECT AVG( sal ) FROM emp );#列出与"周八"从事相同工作的所有员工。
SELECT
*
FROM
emp
WHERE
job = ( SELECT job FROM emp WHERE ename = '周八' );#列出薪金等于部门30中员工的薪金的 所有员工的姓名和薪金。
SELECT
ename,
deptno,
sal + IFNULL( comm, 0 )
FROM
emp
WHERE
sal + IFNULL( comm, 0 ) = ANY ( SELECT sal + IFNULL( comm, 0 ) FROM emp WHERE deptno = 30 );#列出在每个部门工作的员工数量、平均工资。
SELECT
dname,
( SELECT count( * ) FROM emp WHERE deptno = d.deptno ),
( SELECT avg( sal ) FROM emp WHERE deptno = d.deptno )
FROM
dept d;#列出所有员工的姓名、部门名称和工资。
SELECT
dname,
count( ename ),
avg( sal )
FROM
dept
LEFT JOIN emp ON dept.deptno = emp.deptno
GROUP BY
dept.deptno;#列出所有员工的姓名、部门名称和工资。
SELECT
ename,
dname,
sal
FROM
dept
RIGHT JOIN emp ON dept.deptno = emp.deptno;#列出所有部门的详细信息和部门人数。
SELECT
dept.*,
( SELECT count( * ) FROM emp WHERE deptno = dept.deptno ) count
FROM
dept;
SELECT
d.*,
count( ename )
FROM
dept d
LEFT JOIN emp e ON d.deptno = e.deptno
GROUP BY
d.deptno;
# 列出各种工作的最低工资。
SELECT job,min(sal) FROM emp GROUP BY job;
#列出各个部门的 经理 的最低薪金。
SELECT job,min(sal) FROM emp GROUP BY job HAVING job = '经理';
#列出所有员工的年工资,按年薪从低到高排序。
SELECT sal*12 y_sal FROM emp ORDER BY y_sal;
#查出emp表中薪水在3000以上(包括3000)的所有员工的员工号、姓名、薪水
SELECT empno, ename, sal FROM emp WHERE sal >= 3000;
#查询出所有薪水在'陈二'之上的所有人员信息。
SELECT * FROM emp WHERE sal > (SELECT sal FROM emp WHERE ename = '陈二');
#查询出emp表中部门编号为20,薪水在2000以上(不包括2000)的所有员工,显示他们的员工号,姓名以及薪水,以如下列名显示:员工编号 员工名字 薪水
SELECT empno '员工编号', ename '员工姓名', sal '薪水' FROM emp WHERE deptno = 20 AND sal > 2000;
#查询出emp表中所有的工作种类(无重复)
SELECT job FROM emp GROUP BY job;
#查询出所有奖金(comm)字段不为空的人员的所有信息。
SELECT * FROM emp WHERE comm IS NOT NULL;
#查询出薪水在800到2500之间(闭区间)所有员工的信息。(注:使用两种方式实现and以及between and)
SELECT * FROM emp WHERE sal >= 800 AND sal <= 2500;
SELECT * FROM emp WHERE sal BETWEEN 800 AND 2500;
#查询出员工号为7521,7900,7782的所有员工的信息。(注:使用两种方式实现,or以及in)
SELECT * FROM emp WHERE empno = 7521 or empno = 7900 or empno = 7782;
SELECT * FROM emp WHERE empno in (7521,7900,7782);
#查询出名字中有“张”字符,并且薪水在1000以上(不包括1000)的所有员工信息。
SELECT * FROM emp WHERE sal > 1000 AND ename LIKE '%张%';
#查询出名字第三个汉字是“多”的所有员工信息。
SELECT * FROM emp WHERE ename LIKE '__多%';
#将所有员工按薪水升序排序,薪水相同的按照入职时间降序排序。
SELECT * FROM emp ORDER BY sal ASC,hiredate DESC;
#将所有员工按照名字首字母升序排序,首字母相同的按照薪水降序排序。 order by convert(name using gbk) asc;
SELECT * FROM emp ORDER BY CONVERT(substr(ename,1,1) using gbk) ASC, sal DESC;
#查询出最早工作的那个人的名字、入职时间和薪水。
SELECT ename,hiredate,sal FROM emp WHERE hiredate = (SELECT min(hiredate) FROM emp);
#显示所有员工的名字、薪水、奖金,如果没有奖金,暂时显示100.
SELECT ename,sal,IFNULL(comm,100) comm FROM emp;
#显示出薪水最高人的职位。
SELECT job FROM emp WHERE sal = (SELECT max(sal) FROM emp);
#查出emp表中所有部门的最高薪水和最低薪水,部门编号为10的部门不显示。
SELECT d.*,min(sal) min_sal,max(sal) max_sal FROM dept d LEFT JOIN emp e ON d.deptno = e.deptno WHERE d.deptno != 10 GROUP BY d.deptno;
SELECT d.* , (SELECT min(sal) FROM emp WHERE deptno = d.deptno) min_sal,(SELECT max(sal) FROM emp WHERE deptno = d.deptno) max_sal FROM dept d WHERE d.deptno != 10;
#删除10号部门薪水最高的员工。
SELECT * FROM emp WHERE deptno = 10;
DELETE FROM emp WHERE deptno = 10 AND sal = (SELECT max(sal) FROM (SELECT deptno,sal FROM emp) t WHERE deptno = 10);
#将薪水最高的员工的薪水降30%。
UPDATE emp SET sal = sal * 0.7 WHERE empno = ANY (SELECT empno FROM (SELECT empno FROM emp WHERE sal >= ALL(SELECT sal FROM emp)) t);
UPDATE emp SET sal = sal*1.2 WHERE sal = (SELECT max(sal) FROM (SELECT * FROM emp) t);
#查询员工姓名,工资和 工资级别(工资>=3000 为3级,工资>2000 为2级,工资<=2000 为1级) 语法:case when ... then ... when ... then ... else ... end
SELECT
ename,
sal,
CASE
WHEN sal >= 3000 THEN
'三级'
WHEN sal > 2000 THEN
'二级'
WHEN sal <= 2000 THEN
'一级'
END grade
FROM
emp;
| true |
b93531c8d9e182e20d128c40d2469dd757381ab4 | SQL | vladimirpetukhov/Soft_Uni_Studies | /C#_Data_Base_MS_SQL/Database Basics – MS SQL – май 2018/Table Realations/Table Realations/02. One-To-Many Relationship.sql | UTF-8 | 655 | 3.59375 | 4 | [
"MIT"
] | permissive | CREATE TABLE Manufacturers
(
ManufacturerID INT CONSTRAINT PK_ManufacturerID
PRIMARY KEY,
[Name] NVARCHAR(50) NOT NULL,
EstablishedOn DATE NOT NULL
)
CREATE TABLE Models
(
ModelID INT CONSTRAINT PK_ModelID
PRIMARY KEY,
[Name] NVARCHAR(30) NOT NULL,
ManufacturerID INT NOT NULL
)
INSERT INTO Models
VALUES
(101,'X1',1),
(102,'i6',1),
(103,'Model S',2),
(104,'Model X',2),
(105,'Model 3',2),
(106,'Nova',3)
INSERT INTO Manufacturers
VALUES
(1,'BMW','07/03/1916'),
(2,'Tesla','1/01/2003'),
(3,'Lada','01/05/1966')
ALTER TABLE Models
ADD CONSTRAINT FK_Model_ManufacturerID
FOREIGN KEY (ManufacturerID)
REFERENCES Manufacturers(ManufacturerID)
| true |
8f3229d194adb54aad1bd2ab5eff007836e5da48 | SQL | Izazul-Haque/Izazul-Haque-BloodLink | /bloodlink/sql/bloodlink.sql | UTF-8 | 4,413 | 3.078125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 11, 2021 at 09:47 PM
-- Server version: 10.4.18-MariaDB
-- PHP Version: 8.0.3
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: `bloodlink`
--
-- --------------------------------------------------------
--
-- Table structure for table `bloodinfo`
--
CREATE TABLE `bloodinfo` (
`bid` int(11) NOT NULL,
`hid` int(11) NOT NULL,
`bg` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `bloodinfo`
--
INSERT INTO `bloodinfo` (`bid`, `hid`, `bg`) VALUES
(2, 2, 'A+'),
(4, 1, 'O+'),
(5, 1, 'AB+'),
(6, 1, 'B+'),
(7, 1, 'O-'),
(8, 1, 'A-');
-- --------------------------------------------------------
--
-- Table structure for table `bloodrequest`
--
CREATE TABLE `bloodrequest` (
`reqid` int(11) NOT NULL,
`hid` int(11) NOT NULL,
`rid` int(11) NOT NULL,
`bg` varchar(11) NOT NULL,
`status` varchar(100) NOT NULL DEFAULT 'Pending'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `bloodrequest`
--
INSERT INTO `bloodrequest` (`reqid`, `hid`, `rid`, `bg`, `status`) VALUES
(11, 2, 4, 'A+', 'Pending');
-- --------------------------------------------------------
--
-- Table structure for table `hospitals`
--
CREATE TABLE `hospitals` (
`id` int(11) NOT NULL,
`hname` varchar(100) NOT NULL,
`hemail` varchar(100) NOT NULL,
`hpassword` varchar(100) NOT NULL,
`hphone` varchar(100) NOT NULL,
`hcity` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `hospitals`
--
INSERT INTO `hospitals` (`id`, `hname`, `hemail`, `hpassword`, `hphone`, `hcity`) VALUES
(1, 'CMH', 'cmh@gmail.com', 'cmh', '01123456789', 'Dhaka,Cantonment'),
(2, 'DMC', 'dmc@gmail.com', 'dmc', '01811111111', 'Dhaka');
-- --------------------------------------------------------
--
-- Table structure for table `receivers`
--
CREATE TABLE `receivers` (
`id` int(11) NOT NULL,
`rname` varchar(100) NOT NULL,
`remail` varchar(100) NOT NULL,
`rpassword` varchar(100) NOT NULL,
`rphone` varchar(100) NOT NULL,
`rbg` varchar(10) NOT NULL,
`rcity` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `receivers`
--
INSERT INTO `receivers` (`id`, `rname`, `remail`, `rpassword`, `rphone`, `rbg`, `rcity`) VALUES
(3, 'Isa Khan Himel', 'himel15-10948@diu.edu.bd', 'isakhanhimel', '+8801778262283', 'O+', 'Dhaka.'),
(4, 'Mazharul', 'mazharul@gmail.com', 'abcd1234', '01611111111', 'B+', 'Cumilla'),
(5, 'Izazul Haque Saad', 'izazul15-10621@gmail.com', 'saad123', '01726781794', 'O+', 'Tongi, Gazipur');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `bloodinfo`
--
ALTER TABLE `bloodinfo`
ADD PRIMARY KEY (`bid`),
ADD KEY `hid` (`hid`);
--
-- Indexes for table `bloodrequest`
--
ALTER TABLE `bloodrequest`
ADD PRIMARY KEY (`reqid`),
ADD KEY `hid` (`hid`);
--
-- Indexes for table `hospitals`
--
ALTER TABLE `hospitals`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `hemail` (`hemail`);
--
-- Indexes for table `receivers`
--
ALTER TABLE `receivers`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `remail` (`remail`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `bloodinfo`
--
ALTER TABLE `bloodinfo`
MODIFY `bid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `bloodrequest`
--
ALTER TABLE `bloodrequest`
MODIFY `reqid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `hospitals`
--
ALTER TABLE `hospitals`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `receivers`
--
ALTER TABLE `receivers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `bloodinfo`
--
ALTER TABLE `bloodinfo`
ADD CONSTRAINT `bloodinfo_ibfk_1` FOREIGN KEY (`hid`) REFERENCES `hospitals` (`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 |
af2bf4fe2e165a82c311517fb4fb50d42f49bcf6 | SQL | normrothwell/TechElevator | /Golf Tracker/mvc_java/database/user.sql | UTF-8 | 623 | 2.875 | 3 | [] | no_license | -- ********************************************************************************
-- This script creates the database users and grants them the necessary permissions
-- ********************************************************************************
CREATE USER capstone_owner WITH PASSWORD 'capstone_owner1';
GRANT ALL
ON ALL TABLES IN SCHEMA public
TO capstone_owner;
GRANT ALL
ON ALL SEQUENCES IN SCHEMA public
TO capstone_owner;
CREATE USER capstone_appuser WITH PASSWORD 'capstone_appuser1';
GRANT ALL
ON ALL TABLES IN SCHEMA public
TO capstone_appuser;
GRANT ALL
ON ALL SEQUENCES IN SCHEMA public
TO capstone_appuser; | true |
cb7add22b48dd7a76660b961399f788b8828997a | SQL | andreixhz/ProjetoFC-Squad7 | /bancodeDados/inserts_ProjetoFcamara.sql | UTF-8 | 7,623 | 2.84375 | 3 | [] | no_license | -- Inserts da tabela Categorias
INSERT INTO Categorias (CategoriaImg, CategoriaNome) values ('/static/media/alimentacao.052b2c80.svg', 'Alimentação');
INSERT INTO Categorias (CategoriaImg, CategoriaNome) values ('/static/media/artesanato.8e5a59e2.svg', 'Artesanato');
INSERT INTO Categorias (CategoriaImg, CategoriaNome) values ('/static/media/casa.1e4b5706.svg', 'Serviços Domésticos');
INSERT INTO Categorias (CategoriaImg, CategoriaNome) values ('/static/media/vestuaria.2176f64e.svg', 'Moda e Beleza');
INSERT INTO Categorias (CategoriaImg, CategoriaNome) values ('/static/media/cursos.19c0d3da.svg', 'Aulas e Consultoria');
INSERT INTO Categorias (CategoriaImg, CategoriaNome) values ('/static/media/eletronicos.a4cc5ca0.svg', 'Serviços Eletrônicos');
-- SELECT * FROM Categorias;
-- Inserts da tabela Estados
INSERT INTO Estados (EstadoNome, Uf) values ('São Paulo', 'SP');
INSERT INTO Estados (EstadoNome, Uf) values ('Rio de Janeiro', 'RJ');
INSERT INTO Estados (EstadoNome, Uf) values ('Minas Gerais', 'MG');
INSERT INTO Estados (EstadoNome, Uf) values ('Santa Catarina', 'SC');
-- SELECT * FROM Estados;
-- Inserts da tabela Cidades
INSERT INTO Cidades (IdEstado, CidadeNome) values (1, 'São Paulo');
INSERT INTO Cidades (IdEstado, CidadeNome) values (1, 'Santos');
INSERT INTO Cidades (IdEstado, CidadeNome) values (2, 'Niterói');
INSERT INTO Cidades (IdEstado, CidadeNome) values (2, 'São Gonçalo');
INSERT INTO Cidades (IdEstado, CidadeNome) values (3, 'Uberlândia');
INSERT INTO Cidades (IdEstado, CidadeNome) values (3, 'Uberaba');
INSERT INTO Cidades (IdEstado, CidadeNome) values (4, 'Criciúma');
INSERT INTO Cidades (IdEstado, CidadeNome) values (4, 'Balneário Camboriú');
-- SELECT * FROM Cidades;
-- SELECT * FROM Cidades where IdEstado = 1;
-- Inserts da tabela Endereco
INSERT INTO Endereco (Cep, Bairro, Rua, Numero, Complemento, IdCidade) values ('04236-094', 'Cidade Nova Heliópolis', 'Rua 2 de Fevereiro', 379, 'APTO 82', 1);
INSERT INTO Endereco (Cep, Bairro, Rua, Numero, Complemento, IdCidade) values ('03047-000', 'Brás', 'Rua 21 de Abril', 99, 'Cs 4', 1);
INSERT INTO Endereco (Cep, Bairro, Rua, Numero, Complemento, IdCidade) values ('11010-091', 'Centro', 'Rua Frei Gaspar', 15, 'APTO 18', 2);
INSERT INTO Endereco (Cep, Bairro, Rua, Numero, Complemento, IdCidade) values ('11075-671', 'Campo Grande', 'Rua Carlos Gomes', 164, 'Cs 2', 2);
INSERT INTO Endereco (Cep, Bairro, Rua, Numero, Complemento, IdCidade) values ('24020-065', 'Centro', 'Rua Coronel Gomes Machado', 178, 'APTO 23', 3);
INSERT INTO Endereco (Cep, Bairro, Rua, Numero, Complemento, IdCidade) values ('38400-058', 'Lídice', 'Avenida Rio Branco', 80, 'Cs 1', 5);
INSERT INTO Endereco (Cep, Bairro, Rua, Numero, Complemento, IdCidade) values ('88330-033', 'Centro', 'Avenida Atlântica', 5022, 'APTO 8', 8);
-- SELECT * FROM Endereco;
-- Inserts da tabela TipoUsuario
INSERT INTO TipoUsuario (IdTipoUsuario, NomeTipoUsuario) values (1, 'Consumidor');
INSERT INTO TipoUsuario (IdTipoUsuario, NomeTipoUsuario) values (2, 'Fornecedor');
INSERT INTO TipoUsuario (IdTipoUsuario, NomeTipoUsuario) values (3, 'Administrador');
-- SELECT * FROM TipoUsuario;
-- Inserts da tabela Usuario
INSERT INTO Usuario (Nome, Senha, Email, DataNascimento, Genero, ImagemUsuario, IdTipoUsuario, IdEndereco) values ('Ana Laura', 'Ana123', 'AnaLaura@gmail.com', '2000-10-07', 'F', 'PFP1.jpg', 2, 1);
INSERT INTO Usuario (Nome, Senha, Email, DataNascimento, Genero, ImagemUsuario, IdTipoUsuario, IdEndereco) values ('Carla Dias', 'Carla123', 'CarlaDias@gmail.com', '1998-05-21', 'F', 'PFP2.jpg', 2, 2);
INSERT INTO Usuario (Nome, Senha, Email, DataNascimento, Genero, ImagemUsuario, IdTipoUsuario, IdEndereco) values ('Erica Sobral', 'Erica123', 'EricaSobral@gmail.com', '1999-11-13', 'F', 'PFP3.jpg', 2, 3);
INSERT INTO Usuario (Nome, Senha, Email, DataNascimento, Genero, ImagemUsuario, IdTipoUsuario, IdEndereco) values ('Gabriel Ruiz', 'Gabriel123', 'GabrielRuiz@gmail.com', '1998-09-05', 'M', 'PFP4.jpg', 2, 4);
INSERT INTO Usuario (Nome, Senha, Email, DataNascimento, Genero, ImagemUsuario, IdTipoUsuario, IdEndereco) values ('Marcos Caridade', 'Marcos123', 'MarcosCaridade@gmail.com', '1994-02-18', 'M', 'PFP5.jpg', 2, 5);
INSERT INTO Usuario (Nome, Senha, Email, DataNascimento, Genero, ImagemUsuario, IdTipoUsuario, IdEndereco) values ('Ryze', 'Ryze123', 'Ryze@gmail.com', '1991-11-28', 'M', 'Ryze.png', 2, 6);
INSERT INTO Usuario (Nome, Senha, Email, DataNascimento, Genero, ImagemUsuario, IdTipoUsuario, IdEndereco) values ('Stan', 'Stan123', 'stanSP@gmail.com', '1995-06-12', 'M', 'Stan.jpg', 2, 7);
-- SELECT * FROM Usuario;
-- Inserts da tabela Administrador
INSERT INTO Administrador (Nome, Email, Senha, CPF, IdTipoUsuario) values ('Administrator', 'admin@bfriend.com', 'admin123', '32953076687', 3);
-- SELECT * FROM Administrador;
-- Inserts da tabela Fornecedor
INSERT INTO Fornecedor (CPFouCNPJ, IdUsuario) values ('44712325890', 1);
INSERT INTO Fornecedor (CPFouCNPJ, IdUsuario) values ('70913274485', 2);
INSERT INTO Fornecedor (CPFouCNPJ, IdUsuario) values ('83346573811', 3);
INSERT INTO Fornecedor (CPFouCNPJ, IdUsuario) values ('17463552991', 4);
INSERT INTO Fornecedor (CPFouCNPJ, IdUsuario) values ('49855519713', 5);
INSERT INTO Fornecedor (CPFouCNPJ, IdUsuario) values ('63218875417', 6);
INSERT INTO Fornecedor (CPFouCNPJ, IdUsuario) values ('65748223919', 7);
-- SELECT * FROM Fornecedor;
-- Inserts da tabela Anuncio
INSERT INTO Anuncio (Titulo, Descricao, ImagemAnuncio, Telefone, Instagram, Facebook, Site, IdCategoria, IdFornecedor) values ('Brigadeiro Bom', 'Faço brigadeiros de chocolate artesanal.', 'Brigadeiro1.jpg;Brigadeiro2.jpg;Brigadeiro3.jpg;Brigadeiro4.jpg', '11997875543', 'brigad3ir0', 'brigad3ir0Oficial', 'http://brigadeiroBOM.com.br', 1, 1);
INSERT INTO Anuncio (Titulo, Descricao, ImagemAnuncio, Telefone, Instagram, Facebook, Site, IdCategoria, IdFornecedor) values ('Cristais', 'Vendo cristais energizados.', 'Cristais1.jpg;Cristais2.jpg;Cristais3.jpg;Cristais4.jpg', '11998779981', 'cristalenergy', 'cristalenergyOficial', 'http://cristalEnergy.com.br', 2, 2);
INSERT INTO Anuncio (Titulo, Descricao, ImagemAnuncio, Telefone, Instagram, Facebook, Site, IdCategoria, IdFornecedor) values ('Pintura Residencial', 'Faço serviços de pintura profissional.', 'Pintura1.jpg;Pintura2.jpg;Pintura3.jpg;Pintura4.jpg', '139981224315', 'PaintPro', 'paintProOficial', 'http://paintpro.com.br', 3, 3);
INSERT INTO Anuncio (Titulo, Descricao, ImagemAnuncio, Telefone, Instagram, Facebook, Site, IdCategoria, IdFornecedor) values ('Loja do potão', 'Faço potes.', 'Potes1.jpg;Potes2.jpg;Potes3.jpg;Potes4.jpg', '11997521448', 'PotesLoja', 'PotesLojaOficial', 'http://PotesLoja.com.br', 2, 4);
INSERT INTO Anuncio (Titulo, Descricao, ImagemAnuncio, Telefone, Instagram, Facebook, Site, IdCategoria, IdFornecedor) values ('Marmita Paulinho', 'Vendo marmitas para duas pessoas.', 'Comida1.jpg;Comida2.jpg;Comida3.jpg;Comida4.jpg', '13998789122', 'Paulinhomarmita', 'PaulinhomarmitaOficial', 'http://Paulinhomarmita.com.br', 1, 5);
INSERT INTO Anuncio (Titulo, Descricao, ImagemAnuncio, Telefone, Instagram, Facebook, Site, IdCategoria, IdFornecedor) values ('Log Estabelecimento', 'Presto serviços domésticos de marcenaria.', 'Madeira1.jpg;Madeira2.jpg;Madeira3.jpg;Madeira4.jpg', '13993811543', 'MRBatata', 'MRBatataOficial', 'http://MRBatata.com.br', 3, 1);
INSERT INTO Anuncio (Titulo, Descricao, ImagemAnuncio, Telefone, Instagram, Facebook, Site, IdCategoria, IdFornecedor) values ('Clothing Master', 'Vendo roupas e acessórios unisex.', 'Roupa1.jpg;Roupa2.jpg;Roupa3.jpg;Roupa4.jpg', '11997096327', 'boxBaiano', 'boxBaianoOficial', 'http://boxBaiano.com.br', 4, 2);
-- SELECT * FROM Anuncio;
-- Inserts da tabela Comentario | true |
bafbd7d5e75422c8aeb0aa44bd0d381e73b58279 | SQL | Mywaying/sdc | /sdc/order_flow_trans/script/order_flow_trans.sql | UTF-8 | 5,250 | 3.28125 | 3 | [] | no_license | use ods;
drop table if exists ods.odstmp_bpms_biz_order_flow_common;
CREATE TABLE ods.odstmp_bpms_biz_order_flow_common (
id STRING COMMENT '主键id',
apply_no STRING COMMENT '订单编号',
flow_type STRING COMMENT '流转类型',
flow_type_name STRING COMMENT '流转类型名称',
handle_time TIMESTAMP COMMENT '办理时间',
handle_user_id STRING COMMENT '办理人id',
handle_user_name STRING COMMENT '办理人姓名',
remark STRING COMMENT '备注',
create_user_id STRING COMMENT '创建人id',
update_user_id STRING COMMENT '更新人id',
create_time TIMESTAMP COMMENT '记录创建时间',
update_time TIMESTAMP COMMENT '记录更新时间',
rev bigint comment '版本号',
delete_flag STRING COMMENT '记录删除标识(1:删除;0:有效记录)',
flow_type_new STRING COMMENT '新流转类型',
flow_type_name_new STRING COMMENT '新流转类型名称',
rn bigint) STORED AS parquet;
insert overwrite table odstmp_bpms_biz_order_flow_common
select *,ROW_NUMBER() OVER(PARTITION BY apply_no,flow_type_new ORDER BY if(handle_time='',create_time,handle_time) asc) rn from (
select
a.id,
a.apply_no,
a.flow_type,
b.NAME_ flow_type_name,
a.handle_time,
a.handle_user_id,
a.handle_user_name,
a.remark,
a.create_user_id,
a.update_user_id,
a.create_time,
a.update_time,
a.rev,
a.delete_flag,
CASE
when LOWER(flow_type)='bldy_type' then 'mortgagepass'
when LOWER(flow_type)='bldy_zz_type' then 'mortgagepass_zz'
when LOWER(flow_type)='cd_type' then 'queryarchive'
when LOWER(flow_type)='dycj_type' then 'mortgageout'
when LOWER(flow_type)='dydj_type' then 'mortgagepass'
when LOWER(flow_type)='fydj_type' then 'costmark'
when LOWER(flow_type)='ghcj_type' then 'transferout'
when LOWER(flow_type)='ghdj_type' then 'transferin'
when LOWER(flow_type)='gh_type' then 'transferin'
when LOWER(flow_type)='gh_zz_type' then 'transferin_zz'
when LOWER(flow_type)='gz_type' then 'notarization'
when LOWER(flow_type)='hstdxx_type' then 'agreeloanmark'
when LOWER(flow_type)='mq_type' then 'interview'
when LOWER(flow_type)='qxz_type' then 'qxz_type'
when LOWER(flow_type)='qzjzxcl_type' then 'qzjzxcl_type'
when LOWER(flow_type)='sldj_type' then 'randommark'
when LOWER(flow_type)='sqaj_type' then 'sqaj_type'
when LOWER(flow_type)='sqdk_type' then 'applyloan'
when LOWER(flow_type)='tdxxdj_type' then 'agreeloanmark'
when LOWER(flow_type)='yjtg_type' then 'trustaccount'
when LOWER(flow_type)='yysl_type' then 'prerandom'
when LOWER(flow_type)='zhcs_type' then 'accounttest'
when LOWER(flow_type)='zhtg_type' then 'zhtg_type'
when LOWER(flow_type)='zxdy_type' then 'canclemortgage'
when LOWER(flow_type)='zxdy_zz_type' then 'canclemortgage_zz'
when LOWER(flow_type)='slzjhh_pc' then 'randomcashback'
when LOWER(flow_type)='tdsdj_pc' then 'agreeloanmark'
when LOWER(flow_type)='jb_pc' then 'overinsurance'
when LOWER(flow_type)='wksf_pc' then 'transfertailrelese'
when LOWER(flow_type)='qdzjdz_pc' then 'confirmarrival'
when LOWER(flow_type)='agreeloanresult' then 'agreeloanresult'
ELSE
flow_type
end flow_type_new,
CASE
when LOWER(flow_type)='bldy_type' then '抵押递件'
when LOWER(flow_type)='bldy_zz_type' then '抵押递件_郑州'
when LOWER(flow_type)='cd_type' then '查档'
when LOWER(flow_type)='dycj_type' then '抵押出件'
when LOWER(flow_type)='dydj_type' then '抵押递件'
when LOWER(flow_type)='fydj_type' then '费率登记/费用登记'
when LOWER(flow_type)='ghcj_type' then '过户出件'
when LOWER(flow_type)='ghdj_type' then '过户递件'
when LOWER(flow_type)='gh_type' then '过户递件'
when LOWER(flow_type)='gh_zz_type' then '过户递件_郑州'
when LOWER(flow_type)='gz_type' then '办理公证'
when LOWER(flow_type)='hstdxx_type' then '同贷信息登记/同贷登记'
when LOWER(flow_type)='mq_type' then '面签'
when LOWER(flow_type)='qxz_type' then '取新证'
when LOWER(flow_type)='qzjzxcl_type' then '取证及注销材料'
when LOWER(flow_type)='sldj_type' then '赎楼登记'
when LOWER(flow_type)='sqaj_type' then '申请按揭'
when LOWER(flow_type)='sqdk_type' then '申请贷款'
when LOWER(flow_type)='tdxxdj_type' then '同贷信息登记/同贷登记'
when LOWER(flow_type)='yjtg_type' then '要件托管'
when LOWER(flow_type)='yysl_type' then '预约赎楼'
when LOWER(flow_type)='zhcs_type' then '账户测试'
when LOWER(flow_type)='zhtg_type' then '账户托管'
when LOWER(flow_type)='zxdy_type' then '注销抵押'
when LOWER(flow_type)='zxdy_zz_type' then '注销抵押_郑州'
when LOWER(flow_type)='slzjhh_pc' then '赎楼资金划回'
when LOWER(flow_type)='tdsdj_pc' then '同贷登记'
when LOWER(flow_type)='jb_pc' then '解保'
when LOWER(flow_type)='wksf_pc' then '尾款释放'
when LOWER(flow_type)='qdzjdz_pc' then '确认资金到账'
when LOWER(flow_type)='agreeloanresult' then '确认银行放款'
ELSE
b.NAME_
end flow_type_name_new
FROM ods_bpms_biz_order_flow a
left join (
select DISTINCT KEY_,NAME_new_ NAME_ from ods_bpms_sys_dic_common where TYPE_ID_='10000030350009' or TYPE_ID_='10000041100002' or TYPE_ID_='10000033420071')b
on b.KEY_=lower(a.flow_type))T;
drop table if exists ods_bpms_biz_order_flow_common;
ALTER TABLE odstmp_bpms_biz_order_flow_common RENAME TO ods_bpms_biz_order_flow_common; | true |
4fbba7061900c9d74d70215b2e3efae94f926ea0 | SQL | kinkay17/beasiswalp3i.github.io | /biodata.sql | UTF-8 | 10,243 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | -- phpMyAdmin SQL Dump
-- version 5.0.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Feb 06, 2021 at 12:56 AM
-- 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: `biodata`
--
-- --------------------------------------------------------
--
-- Table structure for table `biodata`
--
CREATE TABLE `biodata` (
`id` int(11) NOT NULL,
`nama` varchar(128) NOT NULL,
`email` varchar(128) NOT NULL,
`image` varchar(128) NOT NULL,
`password` varchar(256) NOT NULL,
`role_id` int(11) NOT NULL,
`is_active` int(1) NOT NULL,
`date_created` int(11) NOT NULL,
`nisn` varchar(50) NOT NULL,
`tmp_lahir` varchar(50) NOT NULL,
`tgl_lahir` date NOT NULL,
`hp` varchar(50) NOT NULL,
`wa` varchar(50) NOT NULL,
`jk` varchar(50) NOT NULL,
`jurusan` varchar(128) NOT NULL,
`id_sekolah` varchar(50) NOT NULL,
`prodi` varchar(200) NOT NULL,
`alamat` varchar(200) NOT NULL,
`tahapan` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `biodata`
--
INSERT INTO `biodata` (`id`, `nama`, `email`, `image`, `password`, `role_id`, `is_active`, `date_created`, `nisn`, `tmp_lahir`, `tgl_lahir`, `hp`, `wa`, `jk`, `jurusan`, `id_sekolah`, `prodi`, `alamat`, `tahapan`) VALUES
(5, 'Mumus Musbihin', 'kinkay17@gmail.com', 'logo_youtube.jpg', '$2y$10$F/NmCGbqqWJKJ6O.eCGUB.LSAeVsgEsZeDHQAJNXuDTk0FSYqPDsK', 1, 1, 1607165282, 'lp3i', '', '2021-01-27', '', '', '', '', 'lp3i', '', '', ''),
(10, 'Viggy', 'mumussaputra@gmail.com', '167810030017_Viggy_Ariesta_Stiawan.jpg', '$2y$10$ssvAYtONYXzKfS4ewBYmnudVFtoQpsG8zSYSbocwJH2.rRF9/T39u', 2, 1, 1610007466, '0022125346', 'Tasikmalaya', '2021-01-07', '082214895203', '082214895203', 'Laki-laki', 'RPL', '3', 'Office Management', 'DSN.RAUBOSOK RT.008/RW.003 DS. MUARA BARU KEC. CILAMAYA WETAN KAB. KARAWANG JAWA BARAT', 'Tahap 2'),
(15, 'Ainun Lestari', 'lp3ikarawang2@gmail.com', 'default.jpg', '$2y$10$UL4vDWxYQdtRt7kIRNeziu8I5x7niHVwLIA4Oif/h.D/nXmHiC.1W', 2, 1, 1612239966, '0022125345', 'Karawang', '1994-12-03', '082214895203', '082214895203', 'Perempuan', 'IPA', '4', 'Office Management', 'Gempol wetan', 'Tahap 2');
-- --------------------------------------------------------
--
-- Table structure for table `master_periode`
--
CREATE TABLE `master_periode` (
`id_periode` int(11) NOT NULL,
`tahun_pmb` varchar(128) NOT NULL,
`ket` varchar(128) NOT NULL,
`tgl_pelaksanaan` date NOT NULL,
`tgl_pengumuman` date NOT NULL,
`status` varchar(100) NOT NULL,
`target` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `master_periode`
--
INSERT INTO `master_periode` (`id_periode`, `tahun_pmb`, `ket`, `tgl_pelaksanaan`, `tgl_pengumuman`, `status`, `target`) VALUES
(5, '2020/2021', 'Tahap 2', '2021-01-01', '2021-01-02', 'off', '30');
-- --------------------------------------------------------
--
-- Table structure for table `master_sekolah`
--
CREATE TABLE `master_sekolah` (
`id_sekolah` int(11) NOT NULL,
`kategori_sekolah` varchar(128) NOT NULL,
`nama_sekolah` varchar(128) NOT NULL,
`blokir` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `master_sekolah`
--
INSERT INTO `master_sekolah` (`id_sekolah`, `kategori_sekolah`, `nama_sekolah`, `blokir`) VALUES
(1, 'SMA', 'SMAN 1 KARAWANG', '1'),
(2, 'MA', 'MAN 1 KARAWANG', '1'),
(3, 'SMK', 'SMKN 2 KARAWANG', '1'),
(4, 'SMK', 'SMKN 1 KARAWANG', '1');
-- --------------------------------------------------------
--
-- Table structure for table `nilai`
--
CREATE TABLE `nilai` (
`id_nilai` int(11) NOT NULL,
`nisn` varchar(50) NOT NULL,
`score` varchar(50) NOT NULL,
`keterangan` varchar(50) NOT NULL,
`hari` date NOT NULL,
`jam` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `nilai`
--
INSERT INTO `nilai` (`id_nilai`, `nisn`, `score`, `keterangan`, `hari`, `jam`) VALUES
(315, '0022125346', '78', 'LULUS KATEGORI 1', '2021-02-02', '08:00');
-- --------------------------------------------------------
--
-- Table structure for table `periode`
--
CREATE TABLE `periode` (
`idperiode` int(11) NOT NULL,
`tahun_pmb` varchar(128) NOT NULL,
`ket` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `periode`
--
INSERT INTO `periode` (`idperiode`, `tahun_pmb`, `ket`) VALUES
(1, '2017/2018', 'Tahap 1'),
(2, '2020/2021', 'Tahap 2'),
(3, '2021/2022', 'Tahap 2');
-- --------------------------------------------------------
--
-- Table structure for table `user_access_menu`
--
CREATE TABLE `user_access_menu` (
`id` int(11) NOT NULL,
`role_id` int(11) NOT NULL,
`menu_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `user_access_menu`
--
INSERT INTO `user_access_menu` (`id`, `role_id`, `menu_id`) VALUES
(1, 1, 1),
(3, 2, 2),
(18, 1, 3),
(22, 1, 2),
(26, 1, 7),
(27, 1, 8),
(28, 2, 11);
-- --------------------------------------------------------
--
-- Table structure for table `user_menu`
--
CREATE TABLE `user_menu` (
`id` int(11) NOT NULL,
`menu` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `user_menu`
--
INSERT INTO `user_menu` (`id`, `menu`) VALUES
(1, 'Admin'),
(2, 'User'),
(3, 'Menu'),
(7, 'Master'),
(11, 'Hasil');
-- --------------------------------------------------------
--
-- Table structure for table `user_role`
--
CREATE TABLE `user_role` (
`id` int(11) NOT NULL,
`role` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `user_role`
--
INSERT INTO `user_role` (`id`, `role`) VALUES
(1, 'Administrator'),
(2, 'Member');
-- --------------------------------------------------------
--
-- Table structure for table `user_sub_menu`
--
CREATE TABLE `user_sub_menu` (
`id` int(11) NOT NULL,
`menu_id` int(11) NOT NULL,
`title` varchar(128) NOT NULL,
`url` varchar(128) NOT NULL,
`icon` varchar(128) NOT NULL,
`is_active` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `user_sub_menu`
--
INSERT INTO `user_sub_menu` (`id`, `menu_id`, `title`, `url`, `icon`, `is_active`) VALUES
(1, 1, 'Dashboard', 'admin', 'fas fa-fw fa-tachometer-alt', 1),
(2, 2, 'My Profile', 'user', 'fas fa-fw fa-user-graduate', 1),
(3, 2, 'Edit Profile', 'user/edit_user', 'fas fa-fw fa-user-edit', 1),
(4, 3, 'Menu Management', 'menu/', 'fas fa-fw fa-folder\"', 1),
(5, 3, 'Submenu Management', 'menu/submenu', 'fas fa-fw fa-folder-open', 1),
(7, 1, 'Role', 'admin/role', 'fas fa-w fa-users-cog ', 1),
(8, 2, 'Change Password', 'user/changepassword', 'fa-fw fas fa-key', 1),
(9, 7, 'Sekolah', 'master', 'fas fa-fw fa-university', 1),
(10, 7, 'Siswa', 'master/siswa', 'fas fa-fw fa-user-graduate', 1),
(11, 7, 'Hasil Tes', 'master/hasil', 'fas fa-fw fa-clipboard-list', 1),
(12, 11, 'Hasil Tes Beasiswa', 'user/hasiltes', 'fas fa-fw fa-user-graduate', 1),
(13, 7, 'Periode', 'master/periode', 'far fa-fw fa-calendar-check', 1);
-- --------------------------------------------------------
--
-- Table structure for table `user_token`
--
CREATE TABLE `user_token` (
`id` int(11) NOT NULL,
`email` varchar(128) NOT NULL,
`token` varchar(128) NOT NULL,
`date_created` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `biodata`
--
ALTER TABLE `biodata`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `master_periode`
--
ALTER TABLE `master_periode`
ADD PRIMARY KEY (`id_periode`);
--
-- Indexes for table `master_sekolah`
--
ALTER TABLE `master_sekolah`
ADD PRIMARY KEY (`id_sekolah`);
--
-- Indexes for table `nilai`
--
ALTER TABLE `nilai`
ADD PRIMARY KEY (`id_nilai`);
--
-- Indexes for table `periode`
--
ALTER TABLE `periode`
ADD PRIMARY KEY (`idperiode`);
--
-- Indexes for table `user_access_menu`
--
ALTER TABLE `user_access_menu`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `user_menu`
--
ALTER TABLE `user_menu`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `user_role`
--
ALTER TABLE `user_role`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `user_sub_menu`
--
ALTER TABLE `user_sub_menu`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `user_token`
--
ALTER TABLE `user_token`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `biodata`
--
ALTER TABLE `biodata`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT for table `master_periode`
--
ALTER TABLE `master_periode`
MODIFY `id_periode` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `master_sekolah`
--
ALTER TABLE `master_sekolah`
MODIFY `id_sekolah` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- AUTO_INCREMENT for table `nilai`
--
ALTER TABLE `nilai`
MODIFY `id_nilai` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=316;
--
-- AUTO_INCREMENT for table `periode`
--
ALTER TABLE `periode`
MODIFY `idperiode` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `user_access_menu`
--
ALTER TABLE `user_access_menu`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=29;
--
-- AUTO_INCREMENT for table `user_menu`
--
ALTER TABLE `user_menu`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `user_role`
--
ALTER TABLE `user_role`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `user_sub_menu`
--
ALTER TABLE `user_sub_menu`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- AUTO_INCREMENT for table `user_token`
--
ALTER TABLE `user_token`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
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 |
f507fde00ed41b67dd41ecaaa2c6d89eee035bec | SQL | MaximIkonnikov/bd | /modify.sql | UTF-8 | 1,005 | 3.484375 | 3 | [] | no_license | connect 'C:\SCLUB'
user 'SYSDBA' password 'masterkey';
alter table Clients drop ID_TICKET;
alter table Accounting add ID_TICKET int not null;
alter table Accounting add constraint acc_to_tickets foreign key (ID_TICKET)
references SeasonTickets (ID_TICKET);
create table Visits(
ID_CLIENT int not null
,NumberOfVisits int
);
alter table Visits add constraint visits_to_clients foreign key (ID_CLIENT)
references Clients (ID_CLIENT);
create table AddServices(
ID_SERVICE int primary key
,ID_TYPE int
,ServiceName varchar(255)
);
alter table AddServices add constraint services_to_types foreign key (ID_TYPE)
references TicketTypes (ID_TYPE);
create table AccountingServices(
ID_CLIENT int not null
,ID_SERVICE int not null
);
alter table AccountingServices add constraint accserv_to_clients foreign key (ID_CLIENT)
references Clients(ID_CLIENT);
alter table AccountingServices add constraint accserv_to_services foreign key (ID_SERVICE)
references AddServices(ID_SERVICE);
| true |
814ae18548ca7d1a716a012ec2b6821a0014cf0d | SQL | jefflee/leetcode_mssql | /TripsAndUsers.sql | UTF-8 | 1,057 | 4.375 | 4 | [] | no_license | -- https://leetcode.com/problems/trips-and-users/
WITH cancel_cte as (
SELECT Request_at, cast(count(1) as decimal(6,4)) as num
FROM Users as u WITH (nolock)
JOIN Trips AS t WITH (nolock) on u.Users_Id = t.Client_Id
WHERE u.Role = 'client' and u.Banned = 'No'
AND CAST(t.Request_at AS datetime) >= '2013-10-01'
AND CAST(t.Request_at AS datetime) <= '2013-10-03'
AND t.Status in ('cancelled_by_client','cancelled_by_driver')
GROUP BY Request_at
), total_cte as (
SELECT Request_at, cast(count(1) as decimal(6,4)) as num
FROM Users as u WITH (nolock)
JOIN Trips AS t WITH (nolock) on u.Users_Id = t.Client_Id
WHERE u.Role = 'client' and u.Banned = 'No'
AND
CAST(t.Request_at AS datetime) >= '2013-10-01'
AND CAST(t.Request_at AS datetime) <= '2013-10-03'
GROUP BY Request_at
)
select t.Request_at as Day, CAST((ISNULL(c.num, 0)/t.num) as decimal(3,2)) as 'Cancellation Rate'
from total_cte as t
LEFT join cancel_cte as c on t.Request_at = c.Request_at
| true |
66b6a82af20ef7ad13c79f262a1d44537c4e061e | SQL | sarbpreetboparai/sqlCodes | /q07-1.sql | UTF-8 | 537 | 3.640625 | 4 | [] | no_license | -- Sarbpreet Boparai
-- Print the mailing label formatted name, full address, car make and model of
-- the person who purchased the most expensive car from us.
SELECT cu.cname || CHR(10) ||
cstreet || CHR(10) ||
TRIM(ccity) || ', ' || TRIM(cprov) || ' ' || cpostal || CHR(10) ||
'Make: ' || c.make || ' Model: ' || c.model AS "Address Label"
FROM s1.customer cu, s1.car c, s1.saleinv si
WHERE cu.cname = si.cname
AND si.serial = c.serial
AND si.net = (SELECT MAX(net)
FROM s1.saleinv);
| true |
7393da637d5c2b0f1b2e5ccab7087508bfda6591 | SQL | Everson-Menezes/Sistema_Loja_JSP | /banco/sistema_loja_noturno.sql | UTF-8 | 14,956 | 3.078125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.6.0
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: 08-Jun-2021 às 18:55
-- Versão do servidor: 5.7.12
-- PHP Version: 5.6.20
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: `sistema_loja_noturno`
--
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_compras`
--
CREATE TABLE `tb_compras` (
`com_codigo` int(11) NOT NULL,
`tpg_codigo` int(11) NOT NULL,
`for_codigo` int(11) NOT NULL,
`nf_codigo` int(11) NOT NULL,
`com_datacompra` date NOT NULL,
`com_valortotal` decimal(18,2) NOT NULL,
`com_observacoes` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_compras`
--
INSERT INTO `tb_compras` (`com_codigo`, `tpg_codigo`, `for_codigo`, `nf_codigo`, `com_datacompra`, `com_valortotal`, `com_observacoes`) VALUES
(1, 1, 1, 1, '2021-04-21', '8.00', 'ttt');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_contapagar`
--
CREATE TABLE `tb_contapagar` (
`cp_codigo` int(11) NOT NULL,
`cp_valorconta` decimal(10,0) NOT NULL,
`cp_datavencimento` date NOT NULL,
`cp_datarecebimento` date NOT NULL,
`nf_codigo` int(11) NOT NULL,
`cp_observacoes` varchar(80) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_contapagar`
--
INSERT INTO `tb_contapagar` (`cp_codigo`, `cp_valorconta`, `cp_datavencimento`, `cp_datarecebimento`, `nf_codigo`, `cp_observacoes`) VALUES
(1, '0', '2021-05-30', '2021-05-30', 1, 'teste');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_contareceber`
--
CREATE TABLE `tb_contareceber` (
`cr_codigo` int(11) NOT NULL,
`cr_valorconta` decimal(18,4) NOT NULL,
`cr_datavencimento` date NOT NULL,
`cr_datarecebimento` date NOT NULL,
`nf_codigo` int(11) NOT NULL,
`cr_observacoes` varchar(80) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_contareceber`
--
INSERT INTO `tb_contareceber` (`cr_codigo`, `cr_valorconta`, `cr_datavencimento`, `cr_datarecebimento`, `nf_codigo`, `cr_observacoes`) VALUES
(1, '11.0000', '2021-05-31', '2021-05-31', 1, 'teste');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_fornecedor`
--
CREATE TABLE `tb_fornecedor` (
`for_codigo` int(11) NOT NULL,
`for_nome` varchar(80) NOT NULL,
`for_endereco` varchar(80) NOT NULL,
`for_numero` varchar(20) NOT NULL,
`for_bairro` varchar(80) NOT NULL,
`for_cidade` varchar(80) NOT NULL,
`for_uf` char(2) NOT NULL,
`for_cnpjcpf` varchar(14) NOT NULL,
`for_rgie` varchar(12) NOT NULL,
`for_telefone` varchar(10) NOT NULL,
`for_fax` varchar(10) NOT NULL,
`for_celular` varchar(10) NOT NULL,
`for_email` varchar(80) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_fornecedor`
--
INSERT INTO `tb_fornecedor` (`for_codigo`, `for_nome`, `for_endereco`, `for_numero`, `for_bairro`, `for_cidade`, `for_uf`, `for_cnpjcpf`, `for_rgie`, `for_telefone`, `for_fax`, `for_celular`, `for_email`) VALUES
(1, 'ibm', 'internet3', '113', 'seleta3', 'sbc3', 'rj', '11122233344', '123456789', '11223355', '44332214', '999999998', 'tete@test2e.com');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_funcionario`
--
CREATE TABLE `tb_funcionario` (
`fun_codigo` int(11) NOT NULL,
`fun_nome` varchar(80) NOT NULL,
`fun_endereco` varchar(80) NOT NULL,
`fun_numero` varchar(20) NOT NULL,
`fun_complemento` varchar(50) NOT NULL,
`fun_bairro` varchar(80) NOT NULL,
`fun_cidade` varchar(80) NOT NULL,
`fun_uf` char(2) NOT NULL,
`fun_cnpjcpf` varchar(14) NOT NULL,
`fun_rgie` varchar(12) NOT NULL,
`fun_sexo` char(1) NOT NULL,
`fun_nascimento` date NOT NULL,
`fun_telefone` varchar(10) NOT NULL,
`fun_celular` varchar(10) NOT NULL,
`fun_email` varchar(80) NOT NULL,
`fun_salario` decimal(18,4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_funcionario`
--
INSERT INTO `tb_funcionario` (`fun_codigo`, `fun_nome`, `fun_endereco`, `fun_numero`, `fun_complemento`, `fun_bairro`, `fun_cidade`, `fun_uf`, `fun_cnpjcpf`, `fun_rgie`, `fun_sexo`, `fun_nascimento`, `fun_telefone`, `fun_celular`, `fun_email`, `fun_salario`) VALUES
(1, 'everson', 'a', '1', 'casa', 'b', 'c', 'd', '2222', '3333', 'm', '1989-04-19', '3333', '5555', '6666teste', '3242.0000');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_itenscompra`
--
CREATE TABLE `tb_itenscompra` (
`itc_codigo` int(11) NOT NULL,
`com_codigo` int(11) NOT NULL,
`pro_codigo` int(11) NOT NULL,
`tpp_codigo` int(11) NOT NULL,
`nf_codigo` int(11) NOT NULL,
`for_codigo` int(11) NOT NULL,
`tpg_codigo` int(11) NOT NULL,
`itc_embalagem` char(2) NOT NULL,
`itc_qtde` decimal(15,3) NOT NULL,
`itc_valorun` decimal(18,3) NOT NULL,
`itc_desc` decimal(18,3) NOT NULL,
`itc_valortotal` decimal(18,3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_itenscompra`
--
INSERT INTO `tb_itenscompra` (`itc_codigo`, `com_codigo`, `pro_codigo`, `tpp_codigo`, `nf_codigo`, `for_codigo`, `tpg_codigo`, `itc_embalagem`, `itc_qtde`, `itc_valorun`, `itc_desc`, `itc_valortotal`) VALUES
(1, 1, 1, 1, 1, 1, 1, 'pl', '33.000', '22.000', '2.000', '55.000');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_itensvenda`
--
CREATE TABLE `tb_itensvenda` (
`itv_codigo` int(11) NOT NULL,
`ven_codigo` int(11) NOT NULL,
`pro_codigo` int(11) NOT NULL,
`tpp_codigo` int(11) NOT NULL,
`nf_codigo` int(11) NOT NULL,
`tpg_codigo` int(11) NOT NULL,
`fun_codigo` int(11) NOT NULL,
`itv_embalagem` char(2) NOT NULL,
`itv_qtde` decimal(15,3) NOT NULL,
`itv_valorun` decimal(18,3) NOT NULL,
`itv_desc` decimal(18,3) NOT NULL,
`itv_valortotal` decimal(18,3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_itensvenda`
--
INSERT INTO `tb_itensvenda` (`itv_codigo`, `ven_codigo`, `pro_codigo`, `tpp_codigo`, `nf_codigo`, `tpg_codigo`, `fun_codigo`, `itv_embalagem`, `itv_qtde`, `itv_valorun`, `itv_desc`, `itv_valortotal`) VALUES
(1, 1, 1, 1, 1, 1, 1, 'pl', '9.000', '99.000', '33.000', '66.000'),
(2, 1, 1, 1, 1, 1, 1, 'un', '1.000', '22.000', '1.000', '20.000');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_notafiscal`
--
CREATE TABLE `tb_notafiscal` (
`nf_codigo` int(11) NOT NULL,
`nf_valornf` decimal(18,4) NOT NULL,
`nf_taxaimpostonf` decimal(15,2) NOT NULL,
`nf_valorimposto` decimal(18,3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_notafiscal`
--
INSERT INTO `tb_notafiscal` (`nf_codigo`, `nf_valornf`, `nf_taxaimpostonf`, `nf_valorimposto`) VALUES
(1, '2.0000', '3.00', '4.000'),
(2, '1.0000', '4.00', '4.000');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_produtos`
--
CREATE TABLE `tb_produtos` (
`pro_codigo` int(11) NOT NULL,
`pro_descricao` varchar(80) NOT NULL,
`tpp_codigo` int(11) NOT NULL,
`pro_precocusto` decimal(18,4) NOT NULL,
`pro_precovenda` decimal(18,4) NOT NULL,
`pro_estoque` decimal(18,3) NOT NULL,
`pro_embalagem` char(2) NOT NULL,
`pro_ipi` decimal(5,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_produtos`
--
INSERT INTO `tb_produtos` (`pro_codigo`, `pro_descricao`, `tpp_codigo`, `pro_precocusto`, `pro_precovenda`, `pro_estoque`, `pro_embalagem`, `pro_ipi`) VALUES
(1, 'arroz', 1, '4.0000', '999.0000', '10.000', 'un', '1.00');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_tipopagto`
--
CREATE TABLE `tb_tipopagto` (
`tpg_codigo` int(11) NOT NULL,
`tpg_descricao` varchar(80) NOT NULL,
`tpg_qtde` int(11) NOT NULL,
`tpg_ativo` char(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_tipopagto`
--
INSERT INTO `tb_tipopagto` (`tpg_codigo`, `tpg_descricao`, `tpg_qtde`, `tpg_ativo`) VALUES
(1, 'credito', 11, 'n');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_tipoproduto`
--
CREATE TABLE `tb_tipoproduto` (
`tpp_codigo` int(11) NOT NULL,
`tpp_descricao` varchar(80) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_tipoproduto`
--
INSERT INTO `tb_tipoproduto` (`tpp_codigo`, `tpp_descricao`) VALUES
(1, 'servico');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_vendas`
--
CREATE TABLE `tb_vendas` (
`ven_codigo` int(11) NOT NULL,
`fun_codigo` int(11) NOT NULL,
`tpg_codigo` int(11) NOT NULL,
`nf_codigo` int(11) NOT NULL,
`ven_datavenda` date NOT NULL,
`ven_valortotal` decimal(18,3) NOT NULL,
`ven_observacoes` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `tb_vendas`
--
INSERT INTO `tb_vendas` (`ven_codigo`, `fun_codigo`, `tpg_codigo`, `nf_codigo`, `ven_datavenda`, `ven_valortotal`, `ven_observacoes`) VALUES
(1, 1, 1, 1, '2020-12-12', '8811.000', 'teste2');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tb_compras`
--
ALTER TABLE `tb_compras`
ADD PRIMARY KEY (`com_codigo`),
ADD KEY `nf_codigo` (`nf_codigo`),
ADD KEY `for_codigo` (`for_codigo`),
ADD KEY `tpg_codigo` (`tpg_codigo`);
--
-- Indexes for table `tb_contapagar`
--
ALTER TABLE `tb_contapagar`
ADD PRIMARY KEY (`cp_codigo`),
ADD KEY `nf_codigo` (`nf_codigo`);
--
-- Indexes for table `tb_contareceber`
--
ALTER TABLE `tb_contareceber`
ADD PRIMARY KEY (`cr_codigo`),
ADD KEY `nf_codigo` (`nf_codigo`);
--
-- Indexes for table `tb_fornecedor`
--
ALTER TABLE `tb_fornecedor`
ADD PRIMARY KEY (`for_codigo`);
--
-- Indexes for table `tb_funcionario`
--
ALTER TABLE `tb_funcionario`
ADD PRIMARY KEY (`fun_codigo`);
--
-- Indexes for table `tb_itenscompra`
--
ALTER TABLE `tb_itenscompra`
ADD PRIMARY KEY (`itc_codigo`),
ADD KEY `tpp_codigo` (`tpp_codigo`),
ADD KEY `pro_codigo` (`pro_codigo`),
ADD KEY `com_codigo` (`com_codigo`),
ADD KEY `nf_codigo` (`nf_codigo`),
ADD KEY `for_codigo` (`for_codigo`),
ADD KEY `tpg_codigo` (`tpg_codigo`);
--
-- Indexes for table `tb_itensvenda`
--
ALTER TABLE `tb_itensvenda`
ADD PRIMARY KEY (`itv_codigo`),
ADD KEY `ven_codigo` (`ven_codigo`),
ADD KEY `pro_codigo` (`pro_codigo`),
ADD KEY `fun_codigo` (`fun_codigo`),
ADD KEY `tpg_codigo` (`tpg_codigo`),
ADD KEY `nf_codigo` (`nf_codigo`),
ADD KEY `tpp_codigo` (`tpp_codigo`);
--
-- Indexes for table `tb_notafiscal`
--
ALTER TABLE `tb_notafiscal`
ADD PRIMARY KEY (`nf_codigo`);
--
-- Indexes for table `tb_produtos`
--
ALTER TABLE `tb_produtos`
ADD PRIMARY KEY (`pro_codigo`),
ADD KEY `tpp_codigo` (`tpp_codigo`);
--
-- Indexes for table `tb_tipopagto`
--
ALTER TABLE `tb_tipopagto`
ADD PRIMARY KEY (`tpg_codigo`);
--
-- Indexes for table `tb_tipoproduto`
--
ALTER TABLE `tb_tipoproduto`
ADD PRIMARY KEY (`tpp_codigo`);
--
-- Indexes for table `tb_vendas`
--
ALTER TABLE `tb_vendas`
ADD PRIMARY KEY (`ven_codigo`),
ADD KEY `nf_codigo` (`nf_codigo`),
ADD KEY `tpg_codigo` (`tpg_codigo`),
ADD KEY `fun_codigo` (`fun_codigo`);
--
-- Constraints for dumped tables
--
--
-- Limitadores para a tabela `tb_compras`
--
ALTER TABLE `tb_compras`
ADD CONSTRAINT `tb_compras_ibfk_1` FOREIGN KEY (`nf_codigo`) REFERENCES `tb_notafiscal` (`nf_codigo`),
ADD CONSTRAINT `tb_compras_ibfk_2` FOREIGN KEY (`for_codigo`) REFERENCES `tb_fornecedor` (`for_codigo`),
ADD CONSTRAINT `tb_compras_ibfk_3` FOREIGN KEY (`tpg_codigo`) REFERENCES `tb_tipopagto` (`tpg_codigo`);
--
-- Limitadores para a tabela `tb_contapagar`
--
ALTER TABLE `tb_contapagar`
ADD CONSTRAINT `tb_contapagar_ibfk_1` FOREIGN KEY (`nf_codigo`) REFERENCES `tb_notafiscal` (`nf_codigo`);
--
-- Limitadores para a tabela `tb_contareceber`
--
ALTER TABLE `tb_contareceber`
ADD CONSTRAINT `tb_contareceber_ibfk_1` FOREIGN KEY (`nf_codigo`) REFERENCES `tb_notafiscal` (`nf_codigo`);
--
-- Limitadores para a tabela `tb_itenscompra`
--
ALTER TABLE `tb_itenscompra`
ADD CONSTRAINT `tb_itenscompra_ibfk_1` FOREIGN KEY (`tpp_codigo`) REFERENCES `tb_produtos` (`tpp_codigo`),
ADD CONSTRAINT `tb_itenscompra_ibfk_2` FOREIGN KEY (`pro_codigo`) REFERENCES `tb_produtos` (`pro_codigo`),
ADD CONSTRAINT `tb_itenscompra_ibfk_3` FOREIGN KEY (`com_codigo`) REFERENCES `tb_compras` (`com_codigo`),
ADD CONSTRAINT `tb_itenscompra_ibfk_4` FOREIGN KEY (`nf_codigo`) REFERENCES `tb_compras` (`nf_codigo`),
ADD CONSTRAINT `tb_itenscompra_ibfk_5` FOREIGN KEY (`for_codigo`) REFERENCES `tb_compras` (`for_codigo`),
ADD CONSTRAINT `tb_itenscompra_ibfk_6` FOREIGN KEY (`tpg_codigo`) REFERENCES `tb_compras` (`tpg_codigo`);
--
-- Limitadores para a tabela `tb_itensvenda`
--
ALTER TABLE `tb_itensvenda`
ADD CONSTRAINT `tb_itensvenda_ibfk_1` FOREIGN KEY (`ven_codigo`) REFERENCES `tb_vendas` (`ven_codigo`),
ADD CONSTRAINT `tb_itensvenda_ibfk_2` FOREIGN KEY (`pro_codigo`) REFERENCES `tb_produtos` (`pro_codigo`),
ADD CONSTRAINT `tb_itensvenda_ibfk_3` FOREIGN KEY (`fun_codigo`) REFERENCES `tb_vendas` (`fun_codigo`),
ADD CONSTRAINT `tb_itensvenda_ibfk_4` FOREIGN KEY (`tpg_codigo`) REFERENCES `tb_vendas` (`tpg_codigo`),
ADD CONSTRAINT `tb_itensvenda_ibfk_5` FOREIGN KEY (`nf_codigo`) REFERENCES `tb_vendas` (`nf_codigo`),
ADD CONSTRAINT `tb_itensvenda_ibfk_6` FOREIGN KEY (`fun_codigo`) REFERENCES `tb_vendas` (`fun_codigo`),
ADD CONSTRAINT `tb_itensvenda_ibfk_7` FOREIGN KEY (`tpg_codigo`) REFERENCES `tb_vendas` (`tpg_codigo`),
ADD CONSTRAINT `tb_itensvenda_ibfk_8` FOREIGN KEY (`nf_codigo`) REFERENCES `tb_vendas` (`nf_codigo`),
ADD CONSTRAINT `tb_itensvenda_ibfk_9` FOREIGN KEY (`tpp_codigo`) REFERENCES `tb_produtos` (`tpp_codigo`);
--
-- Limitadores para a tabela `tb_produtos`
--
ALTER TABLE `tb_produtos`
ADD CONSTRAINT `tb_produtos_ibfk_1` FOREIGN KEY (`tpp_codigo`) REFERENCES `tb_tipoproduto` (`tpp_codigo`);
--
-- Limitadores para a tabela `tb_vendas`
--
ALTER TABLE `tb_vendas`
ADD CONSTRAINT `tb_vendas_ibfk_1` FOREIGN KEY (`nf_codigo`) REFERENCES `tb_notafiscal` (`nf_codigo`),
ADD CONSTRAINT `tb_vendas_ibfk_2` FOREIGN KEY (`tpg_codigo`) REFERENCES `tb_tipopagto` (`tpg_codigo`),
ADD CONSTRAINT `tb_vendas_ibfk_3` FOREIGN KEY (`fun_codigo`) REFERENCES `tb_funcionario` (`fun_codigo`);
/*!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 |
048ee6f9903b0f2d6d60230c84d8cd54e41520b9 | SQL | drewitzmax/WF-Java-DrewitzMax-CodeReview-06 | /sql/cr6_student.sql | UTF-8 | 2,358 | 3.015625 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 8.0.18, for Win64 (x86_64)
--
-- Host: localhost Database: cr6
-- ------------------------------------------------------
-- Server version 8.0.18
/*!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 */;
/*!50503 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 `student`
--
DROP TABLE IF EXISTS `student`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `student` (
`idstudent` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`surname` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
`classID` int(11) DEFAULT NULL,
PRIMARY KEY (`idstudent`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `student`
--
LOCK TABLES `student` WRITE;
/*!40000 ALTER TABLE `student` DISABLE KEYS */;
INSERT INTO `student` VALUES (1,'Max','Drewitz','blub@gmx.de',3),(2,'Marco','Schreiner','schreiner@gmx.at',2),(3,'Finn','Kliemann','kliemann@kliemannsland.de',1),(4,'Anna','Tehorst','tehorst@gmail.com',4),(5,'Verena','van Stegen','verenavs@gmail.com',2),(6,'Lena','Baecker','lb@rwth-edu.com',1),(7,'Phillip','Schroer','phillip@schroer.de',3),(8,'Ramona','Fries','fries@t-online.de',4),(9,'Delia','Tries','tries@yahoo.at',1),(10,'Nico','Draeger','nd@googlemail.com',2);
/*!40000 ALTER TABLE `student` 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-01-10 10:06:30
| true |
572d91472d3b70dd1d49513e122613eefd306387 | SQL | jcurtiswebb/sql-dividend-analyzer | /SQLFinance/Year_Table_Initalization.sql | UTF-8 | 146 | 2.859375 | 3 | [
"MIT"
] | permissive | INSERT INTO SQLFinance.ref.Yr
SELECT TRY_CAST(N AS varchar(4))
FROM SQLFinance.ref.Tally
WHERE N > 1999
AND N < (YEAR(GETDATE()) + 1)
| true |
460c93cbfc90e3759d4af07bf45361904c307458 | SQL | CiSigep/storefrontdb | /bamazonSeed.sql | UTF-8 | 2,418 | 3.8125 | 4 | [] | no_license | DROP DATABASE IF EXISTS bamazon;
CREATE DATABASE bamazon;
USE bamazon;
CREATE TABLE departments(
department_id INTEGER(100) NOT NULL AUTO_INCREMENT,
department_name VARCHAR(50),
over_head_costs FLOAT(20,2),
PRIMARY KEY (department_id)
);
CREATE TABLE products(
item_id INTEGER(100) NOT NULL AUTO_INCREMENT,
product_name VARCHAR(50) NOT NULL,
department_id INTEGER(100),
price FLOAT(10,2),
stock_quantity INTEGER(6) DEFAULT 0,
product_sales float(20,2) DEFAULT 0.00,
PRIMARY KEY(item_id),
FOREIGN KEY(department_id) REFERENCES departments(department_id)
);
INSERT INTO departments(department_name, over_head_costs) VALUES ("Office", 10000.00);
INSERT INTO departments(department_name, over_head_costs) VALUES ("Groceries", 12000.00);
INSERT INTO departments(department_name, over_head_costs) VALUES ("Electronics", 15000.00);
INSERT INTO departments(department_name, over_head_costs) VALUES ("Personal Care", 8000.00);
INSERT INTO departments(department_name, over_head_costs) VALUES ("Crafts", 5000.00);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Double Sided Tape", 1, 3.00, 100);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Bacon", 2, 2.00, 100);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Soda", 2, 4.00, 100);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Video Game", 3, 60.00, 100);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Video Game Console", 3, 250.00, 100);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Shampoo", 4, 5.00, 100);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Milk", 2, 3.00, 100);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Glue", 5, 1.00, 100);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Smartphone", 3, 500.00, 100);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Laptop", 3, 800.00, 100);
INSERT INTO products(product_name, department_id, price, stock_quantity) VALUES ("Camera", 3, "100.00", 3);
SELECT item_id, product_name, department_name, price, stock_quantity FROM products LEFT JOIN departments ON products.department_id = departments.department_id; | true |
084eeb6fd666b1256d7d740092523404e12667dc | SQL | leixiang-A/vux-cm | /dangdang_client_mysql/user.sql | UTF-8 | 2,302 | 3.15625 | 3 | [] | no_license | -- --------------------------------------------------------
-- 主机: 192.168.3.234
-- 服务器版本: 5.5.53 - MySQL Community Server (GPL)
-- 服务器操作系统: Win32
-- HeidiSQL 版本: 9.5.0.5220
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!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' */;
-- 导出 dangdang 的数据库结构
CREATE DATABASE IF NOT EXISTS `dangdang` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `dangdang`;
-- 导出 表 dangdang.user 结构
CREATE TABLE IF NOT EXISTS `user` (
`uid` int(100) NOT NULL AUTO_INCREMENT COMMENT '用户id',
`username` varchar(100) NOT NULL DEFAULT '0' COMMENT '用户名',
`password` varchar(100) NOT NULL DEFAULT '0' COMMENT '密码',
`imgsrc` varchar(900) NOT NULL DEFAULT '0' COMMENT '用户头像',
`type` int(11) NOT NULL DEFAULT '0' COMMENT '0是个人,1是商家。',
`blacklist` varchar(50) NOT NULL DEFAULT '否' COMMENT '是否为黑名单用户。',
PRIMARY KEY (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;
-- 正在导出表 dangdang.user 的数据:~4 rows (大约)
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` (`uid`, `username`, `password`, `imgsrc`, `type`, `blacklist`) VALUES
(1, 'muss1998', 'muss', 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1722506617,2322243230&fm=26&gp=0.jpg', 1, '否'),
(9, 'objobj', '1234567', 'http://img4.imgtn.bdimg.com/it/u=1659322401,3609956675&fm=26&gp=0.jpg', 1, '否'),
(11, 'sein1998', 'sein', 'http://img4.imgtn.bdimg.com/it/u=1659322401,3609956675&fm=26&gp=0.jpg', 0, '否'),
(13, '123123', '123123', 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1722506617,2322243230&fm=26&gp=0.jpg', 1, '是');
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
| true |
85aff592386acde5ba25604fa838b35918d60dbf | SQL | joannalimbaga/DoOrDie | /db_quiz.sql | UTF-8 | 17,210 | 3.09375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.1.12
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Aug 26, 2014 at 11:41 PM
-- Server version: 5.6.16
-- PHP Version: 5.5.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `db_quiz`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_question`
--
CREATE TABLE IF NOT EXISTS `tbl_question` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`QuestionNum` varchar(100) NOT NULL,
`Question` varchar(10000) NOT NULL,
`Answer1` varchar(10000) NOT NULL,
`Answer2` varchar(10000) NOT NULL,
`Answer3` varchar(10000) NOT NULL,
`Sagot` varchar(10000) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=102 ;
--
-- Dumping data for table `tbl_question`
--
INSERT INTO `tbl_question` (`id`, `QuestionNum`, `Question`, `Answer1`, `Answer2`, `Answer3`, `Sagot`) VALUES
(1, '1', 'In the movie 10 000 hrs. what is the character name of Robin Padilla?', 'Gabriel', 'Alfred', 'Sebastian', 'Gabriel'),
(2, '2', 'Who is the Legal wife in the Mano po 4: Ako Legal wife films under Regal Entertainments?', 'Cherry Pie Picache', 'Rufa Mae Quinto', 'Zsa Zsa Padilla', 'Zsa Zsa Padilla'),
(3, '3', 'Who is the writer of this mystery – thriller film entitled Another me that was released on year 2013 starring Sophie Turner.', 'Isabel Coixet', 'Jonathan Rhys Meyers', 'Zita Sattar', 'Isabel Coixet'),
(4, '4', 'Ang Dalubhasa comedy film starring Fernando Poe, Jr. was released on 26th of January 2000. Who is the Director of this film?', 'Fernando Poe, Jr', 'Marco Polo Garcia', 'Maritoni Fernandez', 'Fernando Poe, Jr'),
(5, '5', 'What is the title of this romantic comedy film that direct by Jean-Pierre Jeunet?', 'Emilie', 'Amelie', 'Emelia', 'Amelie'),
(6, '6', 'Who is the producer of this epic science fiction film entitled AVATAR, he is also the writer and director.', 'James Cameron', 'Stephen Lang', 'Jon Landau', 'James Cameron'),
(7, '7', 'What is the title of this 2010 American psychological thriller/horror film directed by Darren Aronofsky and starring Natalie Portman, Vincent Cassel, and Mila Kunis?', 'Black Swan', 'Black Jack', 'Black Butler', 'Black Swan'),
(8, '8', 'What is the title of this 2012 American superhero film based on the Marvel Comics superhero team of the same name, produced by Marvel Studios?', 'Captain America', 'Avenger', 'Iron Man', 'Avenger'),
(10, '9', 'Who is the Director of this 2009 American semi-biographical sports drama film The Blind Side, he also the director of the films Snow White and the Huntsman and Saving Mr. Banks?', 'John Lee Hancock', 'Robert Stromberg', 'Ron Howard', 'John Lee Hancock'),
(11, '10', 'A 2014 Filipino romantic comedy film directed by Mae Cruz starring Kim Chiu and Xian Lim. It is produced by Star Cinema as its opening salvo for the year. What is the title of this movie film?', 'Bakit hindi ka crush ng crush mo', 'Bride for rent', 'My Girl', 'Bride for rent'),
(12, '11', 'It is a 2011 American romantic comedy film direct by Paul Feig, written by Annie Mumolo and Kristen Wiig, and produced by Judd Apatow, Barry Mendel, and Clayton Townsend. What is the title of this film?', 'Brides Maid', 'Devious Maid', 'The Maids', 'Brides Maid'),
(13, '12', 'In the movie of skylight films and star cinema in 2013 it is a Filipino family comedy drama film directed by Don Cuaresma, starring Pokwang, Jessy Mendiola, and Enchong Dee. What is this movie film?', 'My Telephone', 'Call Center Girl', 'Call me maybe', 'Call Center Girl'),
(14, '13', 'This epic drama film directed by Joseph L. Mankiewicz was released on what year?', '1990', '1960', '1963', '1963'),
(15, '14', 'A 2012 Filipino psychological thriller film starring Erich Gonzales and Derek Ramsay. It is also the second film produced by skylight films. What is this movie film?', 'Corazon: Ang Unang aswang', 'Cora: Ang nagiisang aswang', 'Corazon: Ang aswang', 'Corazon: Ang Unang aswang'),
(16, '15', 'Who is the producer of “Bakit hindi ka Crush ng Crush mo” the romantic comedy film that released on 2013?', 'Cathy Garcia Molina', 'Charo Santos-Concio', 'Joyce Bernal', 'Charo Santos-Concio'),
(17, '16', 'What is the title of this supernatural psychological horror film that released on 2007?', 'Dead City', 'Walking Dead', 'Dead Silence', 'Dead Silence'),
(18, '17', 'What is the genre of this movie film “Delivery man “that released on 22nd of November 2013.', 'Comedy-drama', 'Romantic-comedy', 'Comedy', 'Comedy-drama'),
(19, '18', 'When this movie film “The Exorcist” was released?', 'December 1973', 'November 1980', 'October 1990', 'December 1973'),
(20, '19', 'In the movie film “the Expandables” what is the character name of Jet Li?', 'Ying Ying', 'Yin Yang', 'Yong Yan', 'Yin Yang'),
(21, '20', 'Who is the director of this 1995 medieval film based on Arthurian legend and also the producer of this film?', 'Hunt Lawry', 'Jerry Zucker', 'Lorne Cameron', 'Jerry Zucker'),
(22, '21', 'What is the title of this 1984 American supernatural comedy film directed and produced by Ivan Reitman and written by Dan Aykroyd and Harold Ramis?', 'Ghostbusters', 'Ghost Land', 'Ghost', 'Ghostbusters'),
(23, '22', 'What is the title of this 2009 American military science fiction action film that direct by Stephen Sommers?', 'G-Force', 'G.I. Joe', 'G.I Jack', 'G.I. Joe'),
(24, '23', 'What is the title of this 1972 American crime film directed by Francis Ford Coppola and produced by Albert S. Ruddy?', 'The God Mother', 'The God Father', 'The God Friend', 'The God Father'),
(25, '24', 'What is the title of this 2011 American comedy film produced by Legendary Pictures and distributed by Warner Bros.?', 'The Hangover', 'The Huntsman', 'The Night', 'The Hangover'),
(26, '25', 'Who is the director of this 2006 Australian-American computer-animated musical family film?', 'Happy Feet', 'The Penguin', 'Rio', 'Happy Feet'),
(27, '26', 'When is the Harry Potter released?', 'June 27, 2010', 'July 3, 2007', 'June 3, 2003', 'July 3, 2007'),
(28, '27', 'Who is the Director of “The Healing”?', 'Chito S. Roño', 'Cathy Garcia Molina', 'Wenn De ramas', 'Chito S. Roño'),
(29, '28', 'What is the real name that performed as Hercules?', 'Dwayne Johnson', 'Ian McShane', 'Reece Ritchie', 'Dwayne Johnson'),
(30, '29', 'What is the title of this 1990 American Christmas family comedy film written and produced by John Hughes and directed by Chris Columbus?', 'House alone', 'Home Alone', 'You''re Alone', 'Home Alone'),
(31, '30', 'What is the title of this 2005 Australian-American horror film directed by Jaume Collet-Serra?', 'The Wax', 'The Candle', 'House of wax', 'House of wax'),
(32, '31', 'What is the real name that portrays as katniss Everdeen?', 'Jennifer Lawrence', 'Jennifer Lopez', 'Jennifer Anniston ', 'Jennifer Lawrence'),
(33, '32', 'Who is the director and also the producer of Inception?', 'Hunt Lawry', 'Jerry Zucker', 'Christopher Nolan', 'Christopher Nolan'),
(34, '33', 'What year when movie film “Indiana Jones” release.', '1980', '1981', '1979', '1981'),
(35, '34', 'What is the title of this 2014 American thriller co-produced, written and directed by Gregg Araki?', 'Snow White and the Huntsman', 'White Oleandar', 'White Bird in a Blizzard', 'White Bird in a Blizzard'),
(36, '35', 'It is a 2012 Filipino comedy film starring Ogie Alcasid, Solenn Heussaff, and Dennis Trillo. The film was directed by Dominic Zapata and released by GMA Films & Regal Films. What is the title of this film?', 'Boy pick-up', 'Pick-up lines', 'Pick-up lines Battle', 'Boy pick-up'),
(37, '36', 'Based on the movie film Cabin in the wood, how many college students was there in the cabin?', '10', '5', '15', '5'),
(38, '37', 'What is the title of this 2010 American[4] supernatural horror film directed by James Wan?', 'The Conjuring', 'Insidious', 'Sinister', 'Insidious'),
(39, '38', 'What is the title of this 1975 American thriller film directed by Steven Spielberg?', 'Haws', 'Jaws', 'Laws', 'Jaws'),
(40, '39', 'In a 2014 American fantasy film directed by Robert Stromberg. Who portray the role of Maleficent?', 'Scarlett Johansson', 'Ella Purnell ', 'Angelina Jolie', 'Angelina Jolie'),
(41, '40', 'In a 2014 French science fiction action film directed. Who portray the role of Lucy?', 'Angelina Jolie', 'Scarlett Johansson', 'Ella Purnell ', 'Scarlett Johansson'),
(42, '41', 'This movie film is an epic high fantasy novel written by English author J. R. R. Tolkien. What is this film?', 'The Hobbit', 'The Lord of the ring', 'Snow White and the Huntsman', 'The Lord of the ring'),
(43, '42', 'In a 2014 American fantasy film directed by Robert Stromberg. Who portray the role of Maleficent?', 'Scarlett Johansson', 'Ella Purnell', 'Angelina Jolie', 'Angelina Jolie'),
(44, '43', 'In a 2014 French science fiction action film directed. Who portray the role of Lucy?', 'Ella Purnell ', 'Scarlett Johansson', 'Angelina Jolie', 'Scarlett Johansson'),
(45, '44', 'Thor: The Dark World is a 2013 American superhero film featuring the Marvel Comics character Thor, produced by Marvel Studios. What year released this movie?', '2010', '2012', '2013', '2013'),
(46, '45', 'What is this 2012 Filipino drama film starring Nora Aunor?', 'My Womb', 'Thy Womb', 'The Womb', 'Thy Womb'),
(47, '46', 'Titanic is a 1997 American epic romantic disaster film? What is the character name of Leonardo DiCaprio?', 'Jack Jackson', 'Johnson Jack', 'Jack Dawson', 'Jack Dawson'),
(48, '47', 'What year released the Toy Story 2?', '1999', '2000', '2001', '1999'),
(49, '48', 'In the movie film Transformer that released on 2007. Who is the young descendant of an Arctic explorer who stumbled on a big secret which becomes the last hope for Earth.', 'Sandy', 'Sam', 'Mace', 'Sam'),
(50, '49', 'This movie film is an epic high fantasy novel written by English author J. R. R. Tolkien. What is this film?', 'The Hobbit', 'The Lord of the ring', 'Snow White and the Huntsman', 'The Lord of the ring'),
(51, '50', 'Kung Fu Panda 2 is a 3D American computer-animated action comedy-drama martial arts film. What year was released this movie?', '2010', '2012', '2011', '2011'),
(52, '51', 'Kung Fu Divas is a 2013 Filipino action comedy film produced under Reality Entertainment, and The O&Co. Who is the director of this movie?', 'Onat Diaz', 'Joyce Bernal', 'Cathy Molina', 'Onat Diaz'),
(53, '52', 'My Kontrabida Girl is a 2012 Filipino romantic comedy film directed by Jade Castro. What is the character name of Rhian Ramos?', 'Cameo Appearance', 'Isabel Reyes', ' Joyce Bernal', 'Isabel Reyes'),
(54, '53', 'This movie film is a 2005 epic adventure film and remake of the 1933 film of the same name.', 'Gorilla', 'King Kong', 'Rise of the Planet Apes', 'King Kong'),
(55, '54', 'Who is the producer of this movie films?', 'Eugene Domingo', 'Piolo Pascual', 'Ariel Ureta ', 'Piolo Pascual'),
(56, '55', 'Who is the producer of this 2013 British-American superhero parody action comedy film?', 'Brad Pitt', 'James Camerom', 'Jeff Wadlow', 'Brad Pitt'),
(57, '56', 'What is the title of this American romantic comedy fantasy film released on September 16, 2005?', 'Just for you', 'Just You and me', 'Just like heaven', 'Just like heaven'),
(58, '57', 'What yesr did Jurassic Park released?', '1992', '1993', '1994', '1993'),
(59, '58', 'Who is the director of this 2000 romantic comedy film by Viva Films?', 'Joyce Bernal', 'Cathy Molina', 'Chito Ronio', 'Joyce Bernal'),
(60, '59', 'Who is the director of this a 2010 American 3D computer-animated action-fantasy film by DreamWorks Animation?', 'Chris Sanders', 'James Cameron', 'Brad Pitt', 'Chris Sanders'),
(61, '60', 'Who is the producer and also one of the main cast of Mission: Impossible movie film?', 'Tom Cruise', 'Brad Pitt', 'Roberto Orci', 'Tom Cruise'),
(62, '61', 'It is a Filipino romantic drama film starring Coco Martin and Julia Montes. Who is the Director of this film?', 'Joyce Bernal', 'Wenn V. De Ramas', 'Emmanuel Quindo Palo', 'Emmanuel Quindo Palo'),
(63, '62', 'What is this comedy film directed by Wenn Deramas that release on 2012?', 'Moron 5 and the crying girl', 'Moron 5 and the crying lady', 'Moron 5 and the crying guy', 'Moron 5 and the crying lady'),
(64, '63', 'When Mr. Suave released?', '2002', '2003', '2000', '2003'),
(65, '64', 'What is the Nickname of the character of Kathryn Bernardo in this movie film?', 'Patchot', 'Patpat', 'Kambal', 'Patchot'),
(66, '65', 'Narnia is a series of fantasy films from Walden Media based on The Chronicles of Narnia. When did they released this?', '2004', '2005', '2006', '2005'),
(67, '66', 'What is the title of this 2006 American fantasy adventure-comedy film?', 'Narnia', 'Night at the Museum', 'The Fantasy', 'Night at the Museum'),
(68, '67', 'What is the title of this 2013 American caper thriller film directed by Louis Leterrier?', 'You can see me', 'Now you see me', 'I see You', 'Now you see me'),
(69, '68', 'What is the character name of Angel Locsin?', 'Isabel', 'Marge', 'Grace', 'Grace'),
(70, '69', 'Who is the director of this horror and suspense film Pagpag siyam na buhay?', 'Frasco S. Mortiz', 'Joyce Bernal', 'Wenn V. Deramas', 'Frasco S. Mortiz'),
(71, '70', 'Who portray the role of Percy Jackson in the movie?', 'Brandon T. Jackson', 'Jake Abel', 'Logan Lerman', 'Logan Lerman'),
(72, '71', 'Who portray the role of Captain Jack Sparrow?', 'Johnny Depp', 'Geoffrey Rush', 'Ian McShane', 'Johnny Depp'),
(73, '72', 'What is the title of this 2006 drama film directed by Christopher Nolan?', 'The Prestige', 'The smoke', 'The Hill', 'The Prestige'),
(74, '73', 'What is the title of this horror movie?', 'The mummy', 'The Road', 'The Mask', 'The Road'),
(75, '74', 'What is the title of this 2012 science fiction film directed by Ridley Scott?', 'Prometheus', 'The eye', 'Dark nights', 'Prometheus'),
(76, '75', 'What kind of bird is Blu?', 'Loro', 'Parrot', 'Macaw', 'Macaw'),
(77, '76', 'What is the title of this 2011 American science fiction film directed by Rupert Wyatt and starring James Franco, Freida Pinto?', 'Rise of the Planet Apes', 'Gorilla', 'King Kong', 'Rise of the Planet Apes'),
(78, '77', 'What is the title of this 2006 road comedy film directed by Barry Sonnenfeld?', 'RV', 'TV', 'AD', 'RV'),
(79, '78', 'What is the character name of Kris Aquino in this movie?', 'Mabel', 'Adela', 'Ariella', 'Mabel'),
(80, '79', 'When is this American psychological thriller film directed by Martin Scorsese released?', '2008', '2009', '2010', '2010'),
(81, '80', 'What is the title of this movie?', 'Silver Lining', 'Silver and Gold', 'Silver Wedding', 'Silver Lining'),
(82, '81', 'It is a American neo-noir action thriller anthology film. When this movie released?', 'April 1,2003', 'December 14, 2004', 'March 28, 2005', 'March 28, 2005'),
(83, '82', 'Who is the director of a 2012 supernatural horror film?', 'Scott Derrickson', 'Brian Kavanaugh-Jones', 'Jason Blum', 'Scott Derrickson'),
(84, '83', 'This movie film is the twenty-third James Bond film produced by Eon Productions.', 'Silver Lining', 'The Agent', 'Skyfall', 'Skyfall'),
(85, '84', 'Who is the director of this movie film?', 'James Cameron', 'Raja Gosnell', 'Jordan Kerner', 'Raja Gosnell'),
(86, '85', 'Who portray the role of Peter Parker in this ', 'Denis Leary', 'Andrew Garfield', 'James Horner', 'Andrew Garfield'),
(87, '86', 'It is a Filipino romantic comedy film. Who is the director of this movie film?', 'Cathy Garcia Molina', 'Joyce Bernal', 'Olivia M. Lamasan', 'Olivia M. Lamasan'),
(88, '87', 'What is this American epic space opera film?', 'Star Game', 'Star Wars', 'The Robot', 'Star Wars'),
(89, '88', 'Who is the director of this American 3D dance film?', 'Scott Speer', 'Ryan Guzman', 'Aaron Zigman', 'Scott Speer'),
(90, '89', 'Who portray the role of Clark Kent in the movie Superman?', 'Kevin Spacey ', 'James Marsden', 'Brandon Routh', 'Brandon Routh'),
(91, '90', 'What is the title of this 2010 American computer animated musical fantasy-comedy film produced by Walt Disney Animation Studios and released by Walt Disney Pictures?', 'Tangled', 'Rapunzel', 'The Hair', 'Tangled'),
(92, '91', 'What is the title of this 2009 American/British science fiction action film directed by McG?', 'The transformer', 'Terminator', 'Star Wars', 'Terminator'),
(93, '92', 'What is the title of this horror film?', 'Insidious', 'The Conjuring', 'Chucky', 'The Conjuring'),
(94, '93', 'What is the title of this horror film?', 'Joker', 'The Dark Night', 'The Dark Knight', 'The Dark Knight'),
(95, '94', 'It is a 1967 American comedy-drama film directed by Mike Nichols?', 'The Girl', 'The Graduate', 'Stocking', 'The Graduate'),
(96, '95', 'What is the title of this 2011 American thriller co-written, produced and directed by Joe Carnahan?', 'The Snow', 'The Grey', 'The Morning After', 'The Grey'),
(97, '96', 'It is a a 2011 American comedy film produced by Legendary Pictures?', 'The Hangover', 'The Host', 'The Man', 'The Hangover'),
(98, '97', 'What this movie released?', 'August 10, 2010', 'August 9, 2011', 'August 8, 2012', 'August 9, 2011'),
(99, '98', 'What year released this movie?', '1973', '1974', '1975', '1973'),
(100, '99', 'What is this 2008 American computer animated science fiction romantic comedy film produced by Pixar Animation Studios?', 'Wall-E', 'Technology', 'The Hero', 'Wall-E'),
(101, '100', 'What is this Filipino romantic film directed by Cathy Garcia-Molina?', 'Unofficially Yours', 'Starting Over Again', 'In Love we trust', 'Unofficially Yours');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_user`
--
CREATE TABLE IF NOT EXISTS `tbl_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Fullname` varchar(30) NOT NULL,
`Username` varchar(30) NOT NULL,
`Password` varchar(30) NOT NULL,
`Highscore` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
--
-- Dumping data for table `tbl_user`
--
INSERT INTO `tbl_user` (`id`, `Fullname`, `Username`, `Password`, `Highscore`) VALUES
(1, 'Admin', 'admin', 'admin', 0),
(3, 'Albert Rementilla', 'a', 'a', 16),
(4, 'b', 'b', 'b', 6),
(10, 'Elena', 'e', 'e', 6),
(11, 'joanna', 'joan', 'j', 6);
/*!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 |
520fb618d2cd8f7079baa642f7b5b53bfb42571b | SQL | dbmdz/cudami | /dc-cudami-server/dc-cudami-server-backend-jdbi/src/main/resources/de/digitalcollections/cudami/server/backend/impl/database/migration/V11.02.00__DML_Update_identifiableObjectType_for_all_Identifiables.sql | UTF-8 | 3,222 | 2.65625 | 3 | [
"MIT"
] | permissive | ALTER TABLE identifiables DISABLE TRIGGER ALL;
UPDATE identifiables SET identifiable_objecttype = 'IDENTIFIABLE';
ALTER TABLE identifiables ENABLE TRIGGER ALL;
ALTER TABLE entities DISABLE TRIGGER ALL;
UPDATE entities SET identifiable_objecttype = 'ENTITY';
ALTER TABLE entities ENABLE TRIGGER ALL;
UPDATE articles SET identifiable_objecttype = 'ARTICLE';
UPDATE collections SET identifiable_objecttype = 'COLLECTION';
UPDATE corporatebodies SET identifiable_objecttype = 'CORPORATE_BODY';
UPDATE digitalobjects SET identifiable_objecttype = 'DIGITAL_OBJECT';
UPDATE familynames SET identifiable_objecttype = 'FAMILY_NAME';
UPDATE givennames SET identifiable_objecttype = 'GIVEN_NAME';
UPDATE headwordentries SET identifiable_objecttype = 'HEADWORD_ENTRY';
UPDATE items SET identifiable_objecttype = 'ITEM';
UPDATE persons SET identifiable_objecttype = 'PERSON';
UPDATE projects SET identifiable_objecttype = 'PROJECT';
UPDATE topics SET identifiable_objecttype = 'TOPIC';
UPDATE websites SET identifiable_objecttype = 'WEBSITE';
UPDATE works SET identifiable_objecttype = 'WORK';
UPDATE geolocations SET identifiable_objecttype = 'GEO_LOCATION';
UPDATE geolocations SET identifiable_objecttype = 'CANYON' WHERE geolocation_type = 'CANYON';
UPDATE geolocations SET identifiable_objecttype = 'CAVE' WHERE geolocation_type = 'CAVE';
UPDATE geolocations SET identifiable_objecttype = 'CONTINENT' WHERE geolocation_type = 'CONTINENT';
UPDATE geolocations SET identifiable_objecttype = 'COUNTRY' WHERE geolocation_type = 'COUNTRY';
UPDATE geolocations SET identifiable_objecttype = 'CREEK' WHERE geolocation_type = 'CREEK';
UPDATE geolocations SET identifiable_objecttype = 'LAKE' WHERE geolocation_type = 'LAKE';
UPDATE geolocations SET identifiable_objecttype = 'MOUNTAIN' WHERE geolocation_type = 'MOUNTAIN';
UPDATE geolocations SET identifiable_objecttype = 'OCEAN' WHERE geolocation_type = 'OCEAN';
UPDATE geolocations SET identifiable_objecttype = 'RIVER' WHERE geolocation_type = 'RIVER';
UPDATE geolocations SET identifiable_objecttype = 'SEA' WHERE geolocation_type = 'SEA';
UPDATE geolocations SET identifiable_objecttype = 'STILL_WATERS' WHERE geolocation_type = 'STILL_WATERS';
UPDATE geolocations SET identifiable_objecttype = 'VALLEY' WHERE geolocation_type = 'VALLEY';
UPDATE humansettlements SET identifiable_objecttype = 'HUMAN_SETTLEMENT';
ALTER TABLE fileresources DISABLE TRIGGER ALL;
UPDATE fileresources SET identifiable_objecttype = 'FILE_RESOURCE';
ALTER TABLE fileresources ENABLE TRIGGER ALL;
UPDATE fileresources_application SET identifiable_objecttype = 'APPLICATION_FILE_RESOURCE';
UPDATE fileresources_audio SET identifiable_objecttype = 'AUDIO_FILE_RESOURCE';
UPDATE fileresources_image SET identifiable_objecttype = 'IMAGE_FILE_RESOURCE';
UPDATE fileresources_linkeddata SET identifiable_objecttype = 'LINKED_DATA_FILE_RESOURCE';
UPDATE fileresources_text SET identifiable_objecttype = 'TEXT_FILE_RESOURCE';
UPDATE fileresources_video SET identifiable_objecttype = 'VIDEO_FILE_RESOURCE';
UPDATE webpages SET identifiable_objecttype = 'WEBPAGE';
-- no tables, yet:
-- AGENT(Agent.class),
-- EXPRESSION(Expression.class),
-- FAMILY(Family.class),
-- MANIFESTATION(Manifestation.class), | true |
3a1f3ec5acd75962b3ed91ba70755ff5ed4d75a1 | SQL | Bookmonkey/IntraLite | /documentation/sql/createtable.sql | UTF-8 | 331 | 2.734375 | 3 | [] | no_license | -- using PostgreSQL
create database quicklinksintranet;
use quicklinksintranet;
create table settings (
title text,
logo_image text,
);
create table link (
id serial PRIMARY KEY,
link text not null,
link_name text not null,
is_external_link boolean not null
);
insert into settings (title) VALUES ('Quick links'); | true |
ef90ac6fe505690bf057f77abd80f55ac5d82c38 | SQL | MAMATJ/bank | /bank.sql | UTF-8 | 3,096 | 2.671875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.1.12
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Dec 29, 2015 at 08:25 AM
-- Server version: 5.6.16
-- PHP Version: 5.5.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `bank`
--
-- --------------------------------------------------------
--
-- Table structure for table `registration`
--
CREATE TABLE IF NOT EXISTS `registration` (
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`phone` varchar(100) NOT NULL,
`gender` varchar(100) NOT NULL,
`bdate` varchar(100) NOT NULL,
`address` varchar(100) NOT NULL,
`city` varchar(100) NOT NULL,
`state` varchar(100) NOT NULL,
`zipcode` int(100) NOT NULL,
`country` varchar(100) NOT NULL,
`type` varchar(100) NOT NULL,
`pin` int(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `registration`
--
INSERT INTO `registration` (`username`, `password`, `email`, `phone`, `gender`, `bdate`, `address`, `city`, `state`, `zipcode`, `country`, `type`, `pin`) VALUES
('mamataj', '123', 'm@ymail.com', '6t8868555555555', 'Felame', '0000-00-00', 'nnnnnn', 'chapai', 'chapai', 1234, 'bbb', 'SA', 222),
('mamataj', '123', 'm@ymail.com', '6t8868555555555', 'Felame', '0000-00-00', 'nnnnnn', 'chapai', 'chapai', 1234, 'bbb', 'SA', 222),
('', '', '', '', '', '0000-00-00', '', '', '', 0, '', '', 0),
('', '', '', '', '', '0000-00-00', '', '', '', 0, '', '', 0),
('', '', '', '', '', '0000-00-00', '', '', '', 0, '', '', 0),
('', '', '', '', '', '0000-00-00', '', '', '', 0, '', '', 0),
('mahal', '2222', 'm@ymail.com', '097777777777777', 'Felame', '0000-00-00', 'fffff', 'chapai', 'chapai', 3333, 'bb', 'SA', 5555),
('', '', '', '', '', '', '', '', '', 0, '', '', 0),
('', '', '', '', '', '', '', '', '', 0, '', '', 0),
('mamataj mahal', '333', 'm@ymail.com', '00000000000', 'Felame', '22-11-2012', 'nn', 'chapai', 'chapai', 1233, 'vvvvv', 'SA', 2222),
('', '', '', '', '', '', '', '', '', 0, '', '', 0),
('mmmm', '111', 'm@ymail.com', '011111111', 'Felame', '11-11-2012', 'chapai', 'chapai', 'sss', 111111, 'bangladesh', 'CA', 234),
('sumona', '123', 'a@ymail.com', '000000000', 'Felame', '11-11-15', 'aaaaaa', 'wwwww', 'ssssss', 123, 'cccccccc', 'CA', 222);
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`user_name` varchar(200) NOT NULL,
`password` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`user_name`, `password`) VALUES
('mamataj mahal', '123'),
('sumona', '123');
/*!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 |
2caabce30c06b6b0da4615f410cc96c3f7a58e54 | SQL | Guiroc/forumg | /forum_sql.sql | UTF-8 | 2,447 | 3.640625 | 4 | [] | no_license | create table utilisateur(
utilisateur_id serial;
utilisateur_pseudo varchar(50),
utilisateur_E_mail varchar(50),
utilisateur_mot_de_passe varchar(50),
constraint pk_utilisateur_id primary key (utilisateur_id));
create table categorie(
categorie_id int,
categorie_titre varchar(50),
constraint pk_categorie_id primary key (categorie_id));
create table sujet(
sujet_id serial,
sujet_titre varchar(50),
sujet_description varchar(100),
sujet_categorie_id int,
sujet_utilisateur_id int,
constraint pk_sujet_id primary key (sujet_id),
constraint fk_sujet_categorie_id foreign key(sujet_categorie_id) references categorie(categorie_id));
constraint fk_sujet_utilisateur_id foreign key(sujet_utilisateur_id) references utilisateur(utilisateur_id));
create table message(
message_id int,
message_titre varchar(50),
message_contenu varchar(1000),
message_date_creation date,
message_date_edite date,
message_sujet_id int,
message_utilisateur_id int,
constraint pk_message_id primary key (message_id),
constraint fk_message_sujet_id foreign key(message_sujet_id) references sujet(sujet_id),
constraint fk_message_utilisateur_id foreign key(message_utilisateur_id) references utilisateur(utilisateur_id));
----------------------------------------------------------------------------------------
create table utilisateur(
utilisateur_id serial,
utilisateur_pseudo varchar(50),
utilisateur_E_mail varchar(50),
utilisateur_mot_de_passe varchar(50),
constraint pk_utilisateur_id primary key (utilisateur_id),
constraint u_utilisateur_id unique (utilisateur_id));
create table sujet(
sujet_id serial,
sujet_titre varchar(50),
sujet_description varchar(100),
sujet_utilisateur_id int,
constraint pk_sujet_id primary key (sujet_id, sujet_utilisateur_id),
constraint fk_sujet_utilisateur_id foreign key(sujet_utilisateur_id) references utilisateur(utilisateur_id),
constraint u_sujet_id unique (sujet_id));
create table message(
message_id serial,
message_titre varchar(50),
message_contenu varchar(1000),
message_date_creation date,
message_date_edite date,
message_sujet_id int,
message_utilisateur_id int,
constraint pk_message_id primary key (message_id, message_sujet_id, message_utilisateur_id),
constraint fk_message_sujet_id foreign key(message_sujet_id) references sujet(sujet_id),
constraint fk_message_utilisateur_id foreign key(message_utilisateur_id) references utilisateur(utilisateur_id),
constraint u_message_id unique (message_id)); | true |
0d24cd84d1c8a7701dcf2a0054f43c1cc543228a | SQL | kfr2359/prac_webapp | /insert.sql | UTF-8 | 2,691 | 2.9375 | 3 | [] | no_license | use prac_db;
-- service_type
insert into service_type (name) values ("Создание документов"),
("Восстановление документов"),
("Сопровождение документов"),
("Банкротсво"),
("Эмиссия акций"),
("Сопрвождение сделок"),
("Судебное представительство"),
("Консультация");
insert into `client` (name) values ("Иванов Иван Иванович"),
("Менкеев Андрей Сергеевич"),
("ООО Союз Детективов Руси");
insert into job (name) values ("Юрист-стажер"),
("Менеджер"),
("Юрист-консультант");
insert into employee (name, address, education, jobId) values ("Петров Андрей Алексеевич", "Москва Лебедянская 8-50", "МГУ Юрфак", 1),
("Сидоров Владимир Станиславович", "Москва Лебедянская 4-53", "МГУ Юрфак", 2),
("Петренко Иван Андреевич", "Москва Шеногина 4к3", "МГУ Юрфак", 3);
insert into employee_phone (employeeId, phone) values (1, "9676512312"),
(2, "9673247659"),
(2, "9169879343"),
(3, "9153243565");
insert into employee_email (employeeId, email) values (1, "a.petrov@mail.ru"),
(2, "v.sydorov@mail.ru"),
(3, "y.petrenko@mail.ru");
insert into client_contact (name, address, clientId) values ("Иванов Иван Иванович", "Москва Саратовская 12-43", 1),
("Менкеев Андрей Сергеевич", "Москва Люблинская 17-110", 2),
("Мартынов Андрей Владимирович", "Москва Тверская 17-4", 3);
insert into client_contact_phone (contactId, phone) values (1, "9092543321"),
(2, "9677654765"),
(3, "9157135458");
insert into client_contact_email (contactId, email) values (1, "y.yvanov@mail.ru"),
(2, "a.menkeev@mail.ru"),
(3, "a.martynov@mail.ru");
insert into service (typeId, clientId, cost, startDate, endDate) values (1, 1, 5000, "2010.10.12", "2010.10.14"),
(2, 2, 2000, "2010.10.15", "2010.10.17"),
(3, 3, 7000, "2010.10.18", "2010.10.20"),
(3, 3, 8000, "2010.10.21", "2010.10.23");
insert into service_employee (serviceId, employeeId) values (1, 1),
(2, 2),
(3, 3);
| true |
3f4d36b527e90e026acd5538547e256d5989313f | SQL | johnspart/api-jdbc | /api-jdbc/src/co/edu/beans/instituciones.sql | UTF-8 | 381 | 2.84375 | 3 | [] | no_license | -- Table: instituciones
-- DROP TABLE instituciones;
CREATE TABLE instituciones
(
id_institucion bigserial NOT NULL,
nombre character varying,
direccion character varying,
comentario character varying,
estado boolean,
CONSTRAINT pk_id_institucion PRIMARY KEY (id_institucion )
)
WITH (
OIDS=FALSE
);
ALTER TABLE instituciones
OWNER TO postgres;
| true |
2efa2baaf2604f7ad34c6bef6f0d240a7619dadc | SQL | blenz3/leetcode | /ex183_customers_who_never_order/solution.sql | UTF-8 | 161 | 3.484375 | 3 | [] | no_license | /* Write your T-SQL query statement below */
SELECT
c.Name as Customers
FROM
Customers c LEFT JOIN Orders o ON c.Id = o.CustomerId
WHERE
o.Id is NULL | true |
3f57633f152a99472e8a76661946b05d972c9a21 | SQL | Neprincessa/Data-science | /лаба1/window_functions/2/B/report_2_2B.sql | UTF-8 | 618 | 4.09375 | 4 | [] | no_license | select CountryRegion, StateProvince,
count([SalesLT].[Customer].CustomerID) as AmountOfClients,
dense_rank ()
OVER (partition by CountryRegion order by count([SalesLT].[Customer].CustomerID) ) as DenseRank
from [SalesLT].[Customer]
left join [SalesLT].[CustomerAddress] on [SalesLT].[Customer].CustomerID = [SalesLT].[CustomerAddress].CustomerID
and [SalesLT].[CustomerAddress].AddressType = 'Main Office'
left join [SalesLT].[Address] on [SalesLT].[Address].AddressID = [SalesLT].[CustomerAddress].AddressID
group by CountryRegion, StateProvince
order by CountryRegion, AmountOfClients , StateProvince;
| true |
ddad9a4a0ece2ba40c3e4e3036c24b341857e5aa | SQL | bcgov/mds | /migrations/sql/V2020.11.09.08.27__updated_now_progress_status_codes.sql | UTF-8 | 637 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | update now_application_progress_status set description='Referral' where application_progress_status_code='REF';
delete from now_application_progress_status where application_progress_status_code='VER';
delete from now_application_progress_status where application_progress_status_code='DEC';
INSERT INTO now_application_progress_status (
application_progress_status_code,
description,
create_user,
update_user
)
VALUES
('CON', 'Consultation', 'system-mds', 'system-mds'),
('PUB', 'Public Comment', 'system-mds', 'system-mds'),
('DFT', 'Draft Permit', 'system-mds', 'system-mds')
ON CONFLICT DO NOTHING; | true |
761fb62d5238f7f48c9f4ee1a80e06f0f90acb05 | SQL | darklight721/roofster | /roofster.sql | UTF-8 | 2,019 | 3 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 3.5.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 21, 2012 at 03:50 PM
-- Server version: 5.5.25a
-- PHP Version: 5.4.4
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `roofster`
--
-- --------------------------------------------------------
--
-- Table structure for table `roof`
--
CREATE TABLE IF NOT EXISTS `roof` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(16) NOT NULL,
`address` varchar(256) NOT NULL,
`city` varchar(128) NOT NULL,
`country` varchar(128) NOT NULL,
`rate` int(11) NOT NULL DEFAULT '0',
`latitude` float NOT NULL,
`longitude` float NOT NULL,
`contact_person` varchar(128) NOT NULL,
`contact_number` varchar(128) NOT NULL,
`details` text,
`email` varchar(128) DEFAULT NULL,
`passcode` varchar(16) DEFAULT NULL,
`date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Dumping data for table `roof`
--
INSERT INTO `roof` (`id`, `type`, `address`, `city`, `country`, `rate`, `latitude`, `longitude`, `contact_person`, `contact_number`, `details`, `email`, `passcode`, `date_added`) VALUES
(1, 'room', '', 'Cebu City', 'Philippines', 0, 0, 0, '', '', '', '', '', '2012-08-21 13:02:13'),
(2, 'room', 'gfs', 'Cebu City', 'Philippines', 543, 0, 0, 'tre', 'tret', 'ytre', 'tre@gfd.com', 'fsddf', '2012-08-21 13:30:32'),
(3, 'room', 'tret', 'Cebu City', 'Philippines', 54654, 0, 0, 'gfds', 'gfds', 'gfdsgfd', 'tre@fdsgf.vom', 'gfdgfd', '2012-08-21 13:33:41');
/*!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 |
d94baf3519a5b17251d6ba1ab3157a6f47ff7d79 | SQL | ruchira088/chirper-api | /user-service/conf/evolutions/default/2.sql | UTF-8 | 294 | 2.53125 | 3 | [] | no_license | -- !Ups
create table authentication_tokens(
session_token varchar(255),
user_id uuid not null,
secret_token varchar(255) not null,
created_at timestamp not null,
expires_at timestamp not null,
primary key (secret_token)
);
-- !Downs
drop table authentication_tokens;
| true |
aa238ab65e2b294ed976b515f60a124522b54852 | SQL | ItAllCanW8/SUBD | /5/task1.sql | UTF-8 | 611 | 3.625 | 4 | [] | no_license | use laba;
SET foreign_key_checks =0;
TRUNCATE TABLE student;
SET foreign_key_checks =1;
INSERT INTO student (id_first_name, id_surname, id_fathername,
id_personal_data)
WITH
temp_first_name AS
(SELECT id FROM first_name ORDER BY rand() LIMIT 100),
temp_surname AS
(SELECT id FROM surname ORDER BY rand() LIMIT 100),
temp_fathername AS
(SELECT id FROM fathername ORDER BY rand() LIMIT 100),
temp_result AS(SELECT
a.id AS id_name,
b.id AS id_surname,
c.Id AS id_fathername,
row_number() over () r
FROM temp_first_name AS a
CROSS JOIN temp_surname AS b
CROSS JOIN temp_fathername AS c)
SELECT * FROM temp_result; | true |
bad6a606e5af36d1ecd91258daeccf67caee2f04 | SQL | bkramak/baseline | /OADB_JNB/sql/.ipynb_checkpoints/make_tables-checkpoint.sql | UTF-8 | 3,832 | 3.5625 | 4 | [] | no_license | /*
2020 Oct create database for operational assessments
author: brian kramak 518-925-9030
unlicensed and unwarranted
create OADB tables
*/
CREATE SCHEMA IF NOT EXISTS sandbox; -- for importing raw data
CREATE SCHEMA IF NOT EXISTS bl; -- baseline for the main tables
CREATE SCHEMA IF NOT EXISTS ats; -- for time series asset data - event logs, 10min, hr data
CREATE SCHEMA IF NOT EXISTS rts; -- for resource time series data - met mast, merra2, era5
CREATE SCHEMA IF NOT EXISTS maint; -- for maintenance record type data
CREATE SCHEMA IF NOT EXISTS inv; -- for inventory management
CREATE SCHEMA IF NOT EXISTS mgmt; -- monthly/annual summary data for reports
DROP TABLE IF EXISTS bl.type;
DROP TABLE IF EXISTS bl.asset_type CASCADE;
DROP TABLE IF EXISTS bl.asset CASCADE;
DROP TABLE IF EXISTS bl.facility CASCADE;
CREATE TABLE bl.type(
tid bigserial not null primary key,
name varchar(50) not null,
description varchar(250) not null
);
INSERT INTO type(name, description) values('wind turbine', 'all wind turbines including AC out');
INSERT INTO type(name, description) values('solar inverter', 'inverters including AC out');
INSERT INTO type(name, description) values('solar pv', 'pv array');
INSERT INTO type(name, description) values('solar csp', 'concentrating solar not pv');
INSERT INTO type(name, description) values('electrical meter', 'all string, substation, revenue electrical meters');
INSERT INTO type(name, description) values('onsite resmeas', 'all wind or solar onsite measurements');
INSERT INTO type(name, description) values('modeled resmeas', 'MERRA-2, ERA-5, WRF and other modeled resource measurements');
CREATE TABLE bl.asset_type(
atid bigserial not null primary key,
tid bigint not null,
name varchar(50) not null,
description varchar(250) not null,
CONSTRAINT fk_tid FOREIGN KEY(tid) REFERENCES type(tid)
);
INSERT INTO asset_type(tid,name,description) values(1,'Repower MM82', '2000kW turbine with 82m rotor, Repower is now Senvion');
CREATE TABLE bl.facility (
fid bigserial not null primary key,
parent_fid bigint,
shortname varchar(20) not null,
longname varchar(100) not null,
akaname varchar(250),
capacity_mw_ac real not null,
description varchar(250) not null,
latitude real not null,
longitude real not null,
country varchar(100) not null,
state_prov varchar(100) not null,
cod timestamp not null,
mailing_addr varchar(250),
owner_id int,
operator_id int,
eia_id int,
usgs_id int
);
INSERT INTO facility(shortname,longname,akaname,capacity_mw_ac,description,latitude,longitude,country,state_prov,cod)
values('LHB','La Haute Borne','La Haute Borne-Vaudeville-le-Haut',8.0,'Engie on-shore wind plant with opensource data',48.451194,5.589603,'France','Champagne Ardenne',date '2009-01-01');
CREATE TABLE bl.asset(
aid bigserial not null primary key,
fid bigint not null,
atid bigint not null,
shortname varchar(25) not null,
akaname varchar(150),
latitude real not null,
longitude real not null,
elevation real,
cod timestamp not null,
CONSTRAINT fk_fid FOREIGN KEY(fid) REFERENCES facility(fid) ,
CONSTRAINT fk_atid FOREIGN KEY(atid) REFERENCES asset_type(atid)
);
INSERT INTO asset(fid,atid,shortname,akaname,latitude,longitude,elevation,cod)
VALUES(1,1,'R80736','WT001', 48.4510653, 5.5930283, 439,date '2009-01-01');
INSERT INTO asset(fid,atid,shortname,akaname,latitude,longitude,elevation,cod)
VALUES(1,1,'R80721','WT002', 48.453557, 5.587520, 427.0,date '2009-01-01');
INSERT INTO asset(fid,atid,shortname,akaname,latitude,longitude,elevation,cod)
VALUES(1,1,'R80790','WT003', 48.449718, 5.586903, 412.0,date '2009-01-01');
INSERT INTO asset(fid,atid,shortname,akaname,latitude,longitude,elevation,cod)
VALUES(1,1,'R80711','WT004', 48.446035, 5.592451, 405.0,date '2009-01-01');
| true |
992abc685d52323acbcd12140b810882a8e8518b | SQL | VeselinAtanasov/mysql-database-demos | /mysql-database-demos/06_SubqueriesAndJoins/lab/tasks/07_EmployeesWithProjects.sql | UTF-8 | 322 | 3.765625 | 4 | [] | no_license | SELECT e.`employee_id`, e.`first_name`, b.`name` AS 'project_name'
FROM `employees` AS e
JOIN `employees_projects` AS p
ON e.`employee_id` = p.`employee_id`
JOIN `projects` as b
ON b.`project_id` = p.`project_id`
WHERE DATE(b.`start_date`) > '2002-08-13' AND b.`end_date` IS NULL
ORDER BY e.`first_name`, b.`name`
LIMIT 5; | true |
7ffc96bb016504783be564c3c0a2e0d73ed8fd52 | SQL | robgalicia/katsa_php | /Database/Tablas/GRADOESCOLARIDAD.sql | UTF-8 | 736 | 2.65625 | 3 | [] | no_license | /*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 30/12/2020 11:29:39 a. m. */
/*==============================================================*/
/*==============================================================*/
/* Table: gradoescolaridad */
/*==============================================================*/
create table gradoescolaridad
(
idgradoescolaridad smallint not null auto_increment,
descgradoescolaridad varchar(30) not null,
quien varchar(15) not null,
cuando datetime not null,
primary key (idgradoescolaridad)
);
| true |
29d8d0e39e65dcd89fbefb313e0ca6f430e90e0f | SQL | Hoverbear/CSC-370 | /Assignment4/dump.sql | UTF-8 | 23,182 | 3.203125 | 3 | [] | no_license | --
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: access; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE access (
accountid integer NOT NULL,
supporterid integer NOT NULL
);
ALTER TABLE public.access OWNER TO c370_s19;
--
-- Name: account; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE account (
id integer NOT NULL,
purpose character varying(60),
bank character varying(60)
);
ALTER TABLE public.account OWNER TO c370_s19;
--
-- Name: campaign; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE campaign (
title character varying(40) NOT NULL,
slogan character varying(60) DEFAULT ''::character varying,
currentphase integer DEFAULT 1
);
ALTER TABLE public.campaign OWNER TO c370_s19;
--
-- Name: eight; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE eight (
name character varying(60),
phone character varying(20),
email character varying(60),
sum bigint
);
ALTER TABLE public.eight OWNER TO c370_s19;
--
-- Name: employee; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE employee (
id integer NOT NULL,
salary integer NOT NULL
);
ALTER TABLE public.employee OWNER TO c370_s19;
--
-- Name: event; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE event (
id integer NOT NULL,
name character varying(40),
location character varying(60),
starttimestamp timestamp with time zone,
endtimestamp timestamp with time zone
);
ALTER TABLE public.event OWNER TO c370_s19;
--
-- Name: expensedonation; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE expensedonation (
paymentid integer NOT NULL,
campaigntitle character varying(40) NOT NULL
);
ALTER TABLE public.expensedonation OWNER TO c370_s19;
--
-- Name: organizes; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE organizes (
supporterid integer NOT NULL,
campaigntitle character varying(40) NOT NULL
);
ALTER TABLE public.organizes OWNER TO c370_s19;
--
-- Name: supporter; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE supporter (
id integer NOT NULL,
phone character varying(20),
email character varying(60),
name character varying(60),
title character varying(60)
);
ALTER TABLE public.supporter OWNER TO c370_s19;
--
-- Name: five; Type: VIEW; Schema: public; Owner: c370_s19
--
CREATE VIEW five AS
SELECT supporter.name, supporter.phone, supporter.email, supporter.title, organizes.campaigntitle FROM (supporter JOIN organizes ON ((supporter.id = organizes.supporterid)));
ALTER TABLE public.five OWNER TO c370_s19;
--
-- Name: participatedin; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE participatedin (
supporterid integer NOT NULL,
eventid integer NOT NULL
);
ALTER TABLE public.participatedin OWNER TO c370_s19;
--
-- Name: four; Type: VIEW; Schema: public; Owner: c370_s19
--
CREATE VIEW four AS
SELECT supporter.name, supporter.phone, supporter.email FROM supporter supporter WHERE (NOT (EXISTS (SELECT participatedin.supporterid, participatedin.eventid FROM participatedin WHERE (supporter.id = participatedin.supporterid))));
ALTER TABLE public.four OWNER TO c370_s19;
--
-- Name: fundingstream; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE fundingstream (
accountid integer NOT NULL,
title character varying(60) NOT NULL
);
ALTER TABLE public.fundingstream OWNER TO c370_s19;
--
-- Name: payment; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE payment (
id integer NOT NULL,
accountid integer,
amount integer,
datetime timestamp with time zone,
description character varying(120)
);
ALTER TABLE public.payment OWNER TO c370_s19;
--
-- Name: reimbursementdonation; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE reimbursementdonation (
paymentid integer NOT NULL,
supporterid integer NOT NULL
);
ALTER TABLE public.reimbursementdonation OWNER TO c370_s19;
--
-- Name: nine; Type: VIEW; Schema: public; Owner: c370_s19
--
CREATE VIEW nine AS
SELECT supporter.name, supporter.id AS supporterid, payment.amount, payment.id AS paymentid, account.id AS accountid, account.purpose, payment.description FROM (((payment JOIN reimbursementdonation ON ((reimbursementdonation.paymentid = payment.id))) JOIN supporter ON ((reimbursementdonation.supporterid = supporter.id))) JOIN account ON ((payment.accountid = account.id))) WHERE (payment.amount <= 0) ORDER BY supporter.name;
ALTER TABLE public.nine OWNER TO c370_s19;
--
-- Name: one; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE one (
id integer,
purpose character varying(60),
bank character varying(60),
balance bigint
);
ALTER TABLE public.one OWNER TO c370_s19;
--
-- Name: partof; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE partof (
eventid integer NOT NULL,
title character varying(60) NOT NULL,
phasenumber integer NOT NULL
);
ALTER TABLE public.partof OWNER TO c370_s19;
--
-- Name: phase; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE phase (
phasenumber integer NOT NULL,
campaigntitle character varying(40) NOT NULL,
goal character varying(80),
starttimestamp timestamp with time zone,
endtimestamp timestamp with time zone
);
ALTER TABLE public.phase OWNER TO c370_s19;
--
-- Name: seven; Type: VIEW; Schema: public; Owner: c370_s19
--
CREATE VIEW seven AS
SELECT event.id AS eventid, partof.title, event.name, partof.phasenumber FROM (event JOIN partof ON ((event.id = partof.eventid))) ORDER BY partof.title;
ALTER TABLE public.seven OWNER TO c370_s19;
--
-- Name: six; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE six (
name character varying(60),
phone character varying(20),
email character varying(60),
title character varying(60),
count bigint
);
ALTER TABLE public.six OWNER TO c370_s19;
--
-- Name: ten; Type: VIEW; Schema: public; Owner: c370_s19
--
CREATE VIEW ten AS
SELECT campaign.title, account.id AS accountid, account.purpose, payment.amount, payment.id AS paymentid, payment.description FROM (((campaign JOIN fundingstream ON (((campaign.title)::text = (fundingstream.title)::text))) JOIN account ON ((account.id = fundingstream.accountid))) JOIN payment ON ((payment.accountid = account.id))) ORDER BY campaign.title;
ALTER TABLE public.ten OWNER TO c370_s19;
--
-- Name: three; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE three (
name character varying(60),
phone character varying(20),
email character varying(60),
title character varying(60),
numberofevents bigint
);
ALTER TABLE public.three OWNER TO c370_s19;
--
-- Name: two; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE two (
name character varying(60),
phone character varying(20),
email character varying(60),
title character varying(60),
numberofevents bigint
);
ALTER TABLE public.two OWNER TO c370_s19;
--
-- Name: workswith; Type: TABLE; Schema: public; Owner: c370_s19; Tablespace:
--
CREATE TABLE workswith (
supporter1 integer NOT NULL,
supporter2 integer NOT NULL
);
ALTER TABLE public.workswith OWNER TO c370_s19;
--
-- Data for Name: access; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY access (accountid, supporterid) FROM stdin;
4 8
5 9
6 10
4 7
5 7
6 7
3 7
2 7
1 7
4 6
5 6
6 6
3 6
2 6
1 6
4 5
5 5
6 5
3 5
2 5
1 5
\.
--
-- Data for Name: account; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY account (id, purpose, bank) FROM stdin;
1 General Operations Vancity
2 Payroll Vancity
3 Media and Materials Vancity
4 Global Warming Campaign Vancity
5 Northern Gateway Campaign Coast Capital
6 Keystone Campaign Coast Capital
\.
--
-- Data for Name: campaign; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY campaign (title, slogan, currentphase) FROM stdin;
Global Warming Don't leave the oven on! 1
Northern Gateway Don't kill the whales yet 2
Keystone Environment before profits! 2
\.
--
-- Data for Name: employee; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY employee (id, salary) FROM stdin;
5 500
6 500
7 1000
\.
--
-- Data for Name: event; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY event (id, name, location, starttimestamp, endtimestamp) FROM stdin;
1 Gala Opening Dinner Victoria Convention Center 2013-10-05 18:00:00-07 2013-10-05 21:00:00-07
2 Legislature Protest BC Legislature Protest 2013-10-10 13:00:00-07 2013-10-10 03:00:00-07
3 Street Canvasing Downtown Victoria, meet at Bay Center 2013-10-15 12:00:00-07 2013-10-15 15:00:00-07
4 Rally Against Gas Companies Centennial Square 2013-10-20 12:00:00-07 2013-10-20 15:00:00-07
5 Closing Gala Dinner October 31 17:00:00 2013 PST 2013-10-31 21:00:00-07 \N
6 Gala Opening Dinner Victoria Convention Center 2013-10-06 18:00:00-07 2013-10-06 21:00:00-07
7 Legislature Protest BC Legislature Protest 2013-10-11 13:00:00-07 2013-10-11 03:00:00-07
8 Street Canvasing Downtown Victoria, meet at Bay Center 2013-10-14 12:00:00-07 2013-10-14 15:00:00-07
9 Rally Against Enbridge Centennial Square 2013-10-21 12:00:00-07 2013-10-21 15:00:00-07
10 Closing Gala Dinner October 30 17:00:00 2013 PST 2013-10-30 21:00:00-07 \N
11 Gala Opening Dinner Victoria Convention Center 2013-10-16 18:00:00-07 2013-10-16 21:00:00-07
12 Legislature Protest BC Legislature Protest 2013-10-17 13:00:00-07 2013-10-17 03:00:00-07
13 Street Canvasing Downtown Victoria, meet at Bay Center 2013-11-02 12:00:00-07 2013-11-02 15:00:00-07
14 Rally Against Enbridge Centennial Square 2013-11-05 11:00:00-08 2013-11-05 14:00:00-08
15 Closing Gala Dinner November 30 17:00:00 2013 PST 2013-11-30 20:00:00-08 \N
\.
--
-- Data for Name: expensedonation; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY expensedonation (paymentid, campaigntitle) FROM stdin;
1 Global Warming
2 Global Warming
22 Global Warming
23 Global Warming
3 Northern Gateway
4 Northern Gateway
5 Northern Gateway
6 Northern Gateway
24 Keystone
25 Keystone
26 Keystone
27 Keystone
\.
--
-- Data for Name: fundingstream; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY fundingstream (accountid, title) FROM stdin;
4 Global Warming
5 Northern Gateway
6 Keystone
\.
--
-- Data for Name: organizes; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY organizes (supporterid, campaigntitle) FROM stdin;
8 Global Warming
9 Northern Gateway
10 Keystone
\.
--
-- Data for Name: participatedin; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY participatedin (supporterid, eventid) FROM stdin;
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
7 11
7 12
7 13
7 14
7 15
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
5 11
5 12
5 13
5 14
5 15
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
6 11
6 12
6 13
6 14
6 15
8 1
8 2
8 3
8 4
8 5
9 6
9 7
9 8
9 9
9 10
10 11
10 12
10 13
10 14
10 15
1 1
1 5
1 6
1 10
2 1
2 5
\.
--
-- Data for Name: partof; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY partof (eventid, title, phasenumber) FROM stdin;
1 Global Warming 1
2 Global Warming 1
3 Global Warming 1
4 Global Warming 2
5 Global Warming 2
6 Northern Gateway 1
7 Northern Gateway 1
8 Northern Gateway 1
9 Northern Gateway 2
10 Northern Gateway 2
11 Keystone 1
12 Keystone 1
13 Keystone 2
14 Keystone 2
15 Keystone 2
\.
--
-- Data for Name: payment; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY payment (id, accountid, amount, datetime, description) FROM stdin;
1 4 5000 2013-10-05 11:00:00-07 Donation fron Wilfred Wolf
2 4 -250 2013-10-14 18:00:00-07 Printing costs
22 4 9000 2013-10-14 18:00:00-07 Donation from Betty Bear
23 4 -950 2013-10-14 18:00:00-07 Rally costs
3 5 2000 2013-10-10 14:00:00-07 Donation from Val Volpix
4 5 -350 2013-10-14 14:00:00-07 Printing costs
5 5 -350 2013-10-19 14:00:00-07 Printing costs
6 5 5000 2013-10-30 17:00:00-07 Donation from Betty Bear
24 6 2000 2013-10-20 14:00:00-07 Donation from Wally Wolf
25 6 -350 2013-10-25 14:00:00-07 Printing costs
26 6 -350 2013-11-13 13:00:00-08 Printing costs
27 6 5000 2013-11-15 16:00:00-08 Donation from Val Volpix
7 1 500 2013-10-01 10:00:00-07 Administration costs
8 1 -100 2013-10-01 10:00:01-07 Telephone & Internet Fees
9 1 -100 2013-10-01 10:00:01-07 Web hosting fees
10 1 -200 2013-10-01 10:00:01-07 Strata Fees
11 1 -100 2013-10-01 10:00:01-07 Printer contract with Xerox.
12 2 2000 2013-10-01 10:00:00-07 Salary Deposit.
13 2 -500 2013-10-01 10:00:01-07 Salary for Olly Octopus.
14 2 -500 2013-10-01 10:00:01-07 Salary for Sarah Skunk
15 2 -1000 2013-10-01 10:00:01-07 Salary for Crazy CEO Cat
16 2 2000 2013-10-15 10:00:00-07 Salary Deposit.
17 2 -500 2013-10-14 10:00:01-07 Salary for Olly Octopus.
18 2 -500 2013-10-15 10:00:01-07 Salary for Sarah Skunk
19 2 -1000 2013-10-15 10:00:01-07 Salary for Crazy CEO Cat
20 3 100 2013-10-02 10:00:00-07 Initial Deposit for general printing funds.
21 3 -22 2013-10-15 11:30:00-07 Costs for printing a few posters
\.
--
-- Data for Name: phase; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY phase (phasenumber, campaigntitle, goal, starttimestamp, endtimestamp) FROM stdin;
1 Global Warming Spread the word about Global Warming. 2013-10-05 10:00:00-07 2013-10-15 21:00:00-07
2 Global Warming Promote government attention to the topic. 2013-10-16 10:00:00-07 2013-10-31 21:00:00-07
1 Northern Gateway It's not worth it, block the pipeline! 2013-10-05 10:00:00-07 2013-10-15 21:00:00-07
2 Northern Gateway Hold a rally to show our concerns. 2013-10-16 10:00:00-07 2013-10-31 21:00:00-07
1 Keystone It's not worth it, block the pipeline! 2013-10-16 10:00:00-07 2013-10-31 21:00:00-07
2 Keystone Hold a rally to show our concerns. 2013-11-01 10:00:00-07 2013-11-30 20:00:00-08
\.
--
-- Data for Name: reimbursementdonation; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY reimbursementdonation (paymentid, supporterid) FROM stdin;
1 1
6 2
22 2
3 3
27 3
24 4
4 5
5 6
20 5
21 6
7 7
8 7
9 7
10 7
11 7
\.
--
-- Data for Name: supporter; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY supporter (id, phone, email, name, title) FROM stdin;
1 250-123-12345 Wilfred@wolf.com Wilfred Wolf \N
2 250-124-12345 betty@bear.com Betty Bear \N
3 250-125-12345 val@volpix.com Val Volpix \N
4 250-126-12345 wally@wolf.com Wally Wolf \N
5 250-128-12345 olly@octopus.com Olly Octopus Chief Fundraiser
6 250-128-12345 sarah@skunk.com Sarah Skunk Chief Organizer
7 250-120-12345 crazy@cat.com Crazy CEO Cat CEO
8 250-120-2345 peter@porpoise.com Peter Porpoise Global Warming Contact
9 250-120-4345 pal@polarbear.com Pal Polar Bear Northern Gateway Contact
10 250-120-4348 fella@fox.com Fella Fox Keystone Contact
11 250-124-4745 ally@antelope.com Ally Antelope \N
12 250-124-4785 buddy@beaver.com Buddy Beaver \N
\.
--
-- Data for Name: workswith; Type: TABLE DATA; Schema: public; Owner: c370_s19
--
COPY workswith (supporter1, supporter2) FROM stdin;
5 6
5 7
5 8
5 9
5 10
6 7
6 8
6 9
6 10
\.
--
-- Name: access_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY access
ADD CONSTRAINT access_pkey PRIMARY KEY (accountid, supporterid);
--
-- Name: account_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY account
ADD CONSTRAINT account_pkey PRIMARY KEY (id);
--
-- Name: campaign_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY campaign
ADD CONSTRAINT campaign_pkey PRIMARY KEY (title);
--
-- Name: employee_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY employee
ADD CONSTRAINT employee_pkey PRIMARY KEY (id, salary);
--
-- Name: event_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY event
ADD CONSTRAINT event_pkey PRIMARY KEY (id);
--
-- Name: expensedonation_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY expensedonation
ADD CONSTRAINT expensedonation_pkey PRIMARY KEY (paymentid, campaigntitle);
--
-- Name: fundingstream_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY fundingstream
ADD CONSTRAINT fundingstream_pkey PRIMARY KEY (accountid, title);
--
-- Name: organizes_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY organizes
ADD CONSTRAINT organizes_pkey PRIMARY KEY (supporterid, campaigntitle);
--
-- Name: participatedin_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY participatedin
ADD CONSTRAINT participatedin_pkey PRIMARY KEY (supporterid, eventid);
--
-- Name: partof_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY partof
ADD CONSTRAINT partof_pkey PRIMARY KEY (eventid, title, phasenumber);
--
-- Name: payment_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY payment
ADD CONSTRAINT payment_pkey PRIMARY KEY (id);
--
-- Name: phase_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY phase
ADD CONSTRAINT phase_pkey PRIMARY KEY (phasenumber, campaigntitle);
--
-- Name: reimbursementdonation_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY reimbursementdonation
ADD CONSTRAINT reimbursementdonation_pkey PRIMARY KEY (paymentid, supporterid);
--
-- Name: supporter_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY supporter
ADD CONSTRAINT supporter_pkey PRIMARY KEY (id);
--
-- Name: workswith_pkey; Type: CONSTRAINT; Schema: public; Owner: c370_s19; Tablespace:
--
ALTER TABLE ONLY workswith
ADD CONSTRAINT workswith_pkey PRIMARY KEY (supporter1, supporter2);
--
-- Name: _RETURN; Type: RULE; Schema: public; Owner: c370_s19
--
CREATE RULE "_RETURN" AS ON SELECT TO one DO INSTEAD SELECT account.id, account.purpose, account.bank, sum(payment.amount) AS balance FROM (payment JOIN account ON ((payment.accountid = account.id))) GROUP BY account.id;
--
-- Name: _RETURN; Type: RULE; Schema: public; Owner: c370_s19
--
CREATE RULE "_RETURN" AS ON SELECT TO two DO INSTEAD SELECT supporter.name, supporter.phone, supporter.email, supporter.title, count(participatedin.*) AS numberofevents FROM (supporter JOIN participatedin ON ((supporter.id = participatedin.supporterid))) GROUP BY supporter.id;
--
-- Name: _RETURN; Type: RULE; Schema: public; Owner: c370_s19
--
CREATE RULE "_RETURN" AS ON SELECT TO three DO INSTEAD SELECT query.name, query.phone, query.email, query.title, query.numberofevents FROM (SELECT supporter.name, supporter.phone, supporter.email, supporter.title, count(participatedin.*) AS numberofevents FROM (supporter JOIN participatedin ON ((supporter.id = participatedin.supporterid))) GROUP BY supporter.id) query WHERE (query.numberofevents > 3);
--
-- Name: _RETURN; Type: RULE; Schema: public; Owner: c370_s19
--
CREATE RULE "_RETURN" AS ON SELECT TO six DO INSTEAD SELECT supporter.name, supporter.phone, supporter.email, supporter.title, count(supporter.id) AS count FROM (supporter JOIN workswith ON (((supporter.id = workswith.supporter1) OR (supporter.id = workswith.supporter2)))) GROUP BY supporter.id;
--
-- Name: _RETURN; Type: RULE; Schema: public; Owner: c370_s19
--
CREATE RULE "_RETURN" AS ON SELECT TO eight DO INSTEAD SELECT DISTINCT supporter.name, supporter.phone, supporter.email, sum(payment.amount) AS sum FROM ((reimbursementdonation JOIN payment ON ((reimbursementdonation.paymentid = payment.id))) JOIN supporter ON ((reimbursementdonation.supporterid = supporter.id))) WHERE (payment.amount >= 0) GROUP BY supporter.id;
--
-- Name: access_accountid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY access
ADD CONSTRAINT access_accountid_fkey FOREIGN KEY (accountid) REFERENCES account(id);
--
-- Name: access_supporterid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY access
ADD CONSTRAINT access_supporterid_fkey FOREIGN KEY (supporterid) REFERENCES supporter(id);
--
-- Name: employee_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY employee
ADD CONSTRAINT employee_id_fkey FOREIGN KEY (id) REFERENCES supporter(id);
--
-- Name: expensedonation_campaigntitle_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY expensedonation
ADD CONSTRAINT expensedonation_campaigntitle_fkey FOREIGN KEY (campaigntitle) REFERENCES campaign(title);
--
-- Name: expensedonation_paymentid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY expensedonation
ADD CONSTRAINT expensedonation_paymentid_fkey FOREIGN KEY (paymentid) REFERENCES payment(id);
--
-- Name: fundingstream_accountid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY fundingstream
ADD CONSTRAINT fundingstream_accountid_fkey FOREIGN KEY (accountid) REFERENCES account(id);
--
-- Name: fundingstream_title_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY fundingstream
ADD CONSTRAINT fundingstream_title_fkey FOREIGN KEY (title) REFERENCES campaign(title);
--
-- Name: organizes_campaigntitle_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY organizes
ADD CONSTRAINT organizes_campaigntitle_fkey FOREIGN KEY (campaigntitle) REFERENCES campaign(title);
--
-- Name: organizes_supporterid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY organizes
ADD CONSTRAINT organizes_supporterid_fkey FOREIGN KEY (supporterid) REFERENCES supporter(id);
--
-- Name: participatedin_eventid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY participatedin
ADD CONSTRAINT participatedin_eventid_fkey FOREIGN KEY (eventid) REFERENCES event(id);
--
-- Name: participatedin_supporterid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY participatedin
ADD CONSTRAINT participatedin_supporterid_fkey FOREIGN KEY (supporterid) REFERENCES supporter(id);
--
-- Name: partof_eventid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
--
ALTER TABLE ONLY partof
ADD CONSTRAINT partof_eventid_fkey FOREIGN KEY (eventid) REFERENCES event(id);
--
-- Name: partof_title_fkey; Type: FK CONSTRAINT; Schema: public; Owner: c370_s19
- | true |
5dde0e78bcc53fe6c55d1e4029c16d39ad260775 | SQL | RaeChen07/SteamDataAnalysis | /production/data/sql/get_100_games.sql | UTF-8 | 228 | 3.421875 | 3 | [
"MIT"
] | permissive | -- Randomly selects 100 games from all apps.
-- Filter out non-game apps, order by random, and pick first 100.
USE steam;
CREATE TABLE app_id_info_100
SELECT *
FROM app_id_info A
WHERE A.type = "game"
ORDER BY rand()
LIMIT 100; | true |
fd044e03b53da0d362b9ab384c2350e5ebb3a6c6 | SQL | kiln/cartograms | /maps/usa.sql | UTF-8 | 3,065 | 3.25 | 3 | [] | no_license | -- US States
-- $ curl -LO http://geocommons.com/overlays/21424.zip
-- $ (mkdir 21424 && cd 21424 && unzip ../21424.zip)
-- $ shp2pgsql -s 4326 21424/usa_state_shapefile.shx | psql
-- http://spatialreference.org/ref/esri/102003/postgis/
INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 9102003, 'esri', 102003, '+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ', 'PROJCS["USA_Contiguous_Albers_Equal_Area_Conic",GEOGCS["GCS_North_American_1983",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["False_Easting",0],PARAMETER["False_Northing",0],PARAMETER["longitude_of_center",-96],PARAMETER["Standard_Parallel_1",29.5],PARAMETER["Standard_Parallel_2",45.5],PARAMETER["latitude_of_center",37.5],UNIT["Meter",1],AUTHORITY["EPSG","102003"]]');
insert into division (name) values ('us-states');
insert into region (division_id, name, the_geom, area) (
select currval('division_id_seq'), state_name, the_geom, ST_Area(the_geom) from usa_state_shapefile
);
select compute_breakpoints('us-states');
-- robin=# select ST_Extent(ST_Transform(the_geom, 9102003)) from usa_state_shapefile where state_name not in ('Alaska', 'Hawaii');
-- BOX(-2354935.75 -1294963.875,2256319.25 1558806.125)
insert into map (
division_id,
name, srid,
x_min, y_min, x_max, y_max,
width, height
) values (
currval('division_id_seq'),
'usa-contiguous', 9102003,
-2354935.75, -1294963.875, 2256319.25, 1558806.125,
800, 500
);
select populate_grid('usa-contiguous')
, grid_set_regions('usa-contiguous', 'us-states');
-- $ curl -LO http://www.nws.noaa.gov/geodata/catalog/national/data/s_01ja11.zip
-- $ (mkdir s_01ja11 && cd s_01ja11 && unzip ../s_01ja11.zip)
-- $ shp2pgsql -s 4326 s_01ja11/s_01ja11.shx | psql
-- select ST_Extent(ST_Transform(the_geom, 9102003)) from s_01ja11 where state not in ('AK', 'AH', 'AS', 'GU', 'HI', 'MP', 'PR', 'UM', 'VI');
-- BOX(-2356113.742898 -1337508.07561825,2258224.79945606 1565791.05687272)
delete from grid where division_id = (select id from division where name = 'us-states');
delete from region where division_id = (select id from division where name = 'us-states');
insert into region (division_id, name, the_geom, area) (
select division.id, state, the_geom, ST_Area(the_geom)
from s_01ja11
, division
where division.name = 'us-states'
);
delete from grid where map_id = (select id from map where name = 'usa-contiguous');
delete from map where name = 'usa-contiguous';
insert into map (
division_id,
name, srid,
x_min, y_min, x_max, y_max,
width, height
) (select
division.id,
'usa-contiguous', 9102003,
-2356113.742898, -1337508.07561825, 2258224.79945606, 1565791.05687272,
800, 500
from division
where name = 'us-states'
);
select populate_grid('usa-contiguous')
, grid_set_regions('usa-contiguous', 'us-states');
| true |
39ea6878d7164f5f4f0525085edd572f992cd926 | SQL | AlexSh-l/Projects_JavaScript | /ImageGallery/db/imageviewdb.sql | UTF-8 | 1,684 | 3.0625 | 3 | [] | no_license | -- MySQL Script generated by MySQL Workbench
-- Sat May 8 13:34:08 2021
-- 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='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema imageviewdb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema imageviewdb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `imageviewdb` DEFAULT CHARACTER SET utf8 ;
USE `imageviewdb` ;
-- -----------------------------------------------------
-- Table `imageviewdb`.`users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `imageviewdb`.`users` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`login` VARCHAR(45) NOT NULL,
`email` VARCHAR(45) NOT NULL,
`password` VARCHAR(60) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `imageviewdb`.`images`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `imageviewdb`.`images` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(32) NOT NULL,
`filename` VARCHAR(45) NOT NULL,
`user_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
| true |
4734f81644e7aafa0cf4a0eafb2193bafbafea8b | SQL | praisenoa/si-php-crud | /databasesi.sql | UTF-8 | 4,661 | 3.359375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1:3306
-- Généré le : jeu. 15 fév. 2018 à 12:48
-- Version du serveur : 5.7.19
-- Version de PHP : 7.1.9
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 : `databasesi`
--
-- --------------------------------------------------------
--
-- Structure de la table `categories`
--
DROP TABLE IF EXISTS `categories`;
CREATE TABLE IF NOT EXISTS `categories` (
`category_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
PRIMARY KEY (`category_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
--
-- Déchargement des données de la table `categories`
--
INSERT INTO `categories` (`category_id`, `name`) VALUES
(1, 'Categorie tro bien'),
(3, 'La catégorie du bonheur'),
(4, 'Catégorie 3');
-- --------------------------------------------------------
--
-- Structure de la table `replies`
--
DROP TABLE IF EXISTS `replies`;
CREATE TABLE IF NOT EXISTS `replies` (
`reply_id` int(11) NOT NULL AUTO_INCREMENT,
`topic_id` int(11) DEFAULT NULL,
`category_id` int(11) DEFAULT NULL,
`content` text NOT NULL,
`date` datetime DEFAULT CURRENT_TIMESTAMP,
`author` varchar(255) NOT NULL DEFAULT 'Anonymous',
PRIMARY KEY (`reply_id`),
KEY `repliesTOcategories` (`category_id`),
KEY `repliesTOtopics` (`topic_id`)
) ENGINE=InnoDB AUTO_INCREMENT=89 DEFAULT CHARSET=latin1;
--
-- Déchargement des données de la table `replies`
--
INSERT INTO `replies` (`reply_id`, `topic_id`, `category_id`, `content`, `date`, `author`) VALUES
(81, 6, NULL, 'Le commentaire du bonheur', '2018-02-15 01:57:20', 'Gontran'),
(82, 7, NULL, 'OUI OUI OUI LA FAMILLE', '2018-02-15 01:59:03', 'Anonymous'),
(83, 6, NULL, 'trop bien', '2018-02-15 02:00:03', 'Anonymous'),
(84, 8, NULL, 'test', '2018-02-15 10:38:12', 'Anonymous'),
(85, 6, NULL, 'bfhhf', '2018-02-15 10:38:47', 'Anonymous'),
(86, 9, NULL, 'oui ououo oxpuviomdfhgitvr', '2018-02-15 12:20:59', 'Anonymous'),
(87, 10, NULL, 'hfduigiodf', '2018-02-15 12:23:43', 'Anonymous'),
(88, 6, NULL, 'olalaa', '2018-02-15 13:02:08', 'pignouf');
-- --------------------------------------------------------
--
-- Structure de la table `topics`
--
DROP TABLE IF EXISTS `topics`;
CREATE TABLE IF NOT EXISTS `topics` (
`topic_id` int(11) NOT NULL AUTO_INCREMENT,
`category_id` int(11) NOT NULL,
`subject` varchar(255) NOT NULL,
`date` datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`topic_id`),
KEY `topicsTOcategoriesID` (`category_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
--
-- Déchargement des données de la table `topics`
--
INSERT INTO `topics` (`topic_id`, `category_id`, `subject`, `date`) VALUES
(6, 3, 'Le topic du bonheur', '2018-02-15 01:57:20'),
(7, 3, 'mouss diouf', '2018-02-15 01:59:03'),
(8, 1, 'test', '2018-02-15 10:38:12'),
(9, 1, 'Bonjour', '2018-02-15 12:20:59'),
(10, 4, 'ildiugdiofo', '2018-02-15 12:23:43');
-- --------------------------------------------------------
--
-- Structure de la table `users`
--
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`admin` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
--
-- Déchargement des données de la table `users`
--
INSERT INTO `users` (`id`, `username`, `email`, `password`, `admin`) VALUES
(1, 'ad', 'ad@mail.com', 'ad', 1);
--
-- Contraintes pour les tables déchargées
--
--
-- Contraintes pour la table `replies`
--
ALTER TABLE `replies`
ADD CONSTRAINT `repliesTOcategories` FOREIGN KEY (`category_id`) REFERENCES `topics` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `repliesTOtopics` FOREIGN KEY (`topic_id`) REFERENCES `topics` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Contraintes pour la table `topics`
--
ALTER TABLE `topics`
ADD CONSTRAINT `topicsTOcategoriesID` FOREIGN KEY (`category_id`) REFERENCES `categories` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE;
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 |
d4d68a006aadaa63894c2730f72d9610aa1d18d1 | SQL | BolderBrighterExperience/playground | /intern04/Proiect02/PACKAGES/pkg_unit_testing_body.sql | UTF-8 | 11,615 | 2.53125 | 3 | [] | no_license | CREATE OR REPLACE PACKAGE BODY pkg_unit_testing
AS
PROCEDURE prc_ut_add_department
IS
BEGIN
BEGIN
pkg_hr_departments.prc_add_department('Internship', 200, 1700);
dbms_output.put_line('Success on insert department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert department.');
ROLLBACK;
END;
BEGIN
pkg_hr_departments.prc_add_department(NULL, 100, 1800);
dbms_output.put_line('Success on insert department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert department.');
ROLLBACK;
END;
BEGIN
pkg_hr_departments.prc_add_department('DB', 200, 900);
dbms_output.put_line('Success on insert department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert department.');
ROLLBACK;
END;
BEGIN
pkg_hr_departments.prc_add_department('Intern', 13, 1700);
dbms_output.put_line('Success on insert department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert department.');
ROLLBACK;
END;
END prc_ut_add_department;
PROCEDURE prc_ut_adjust_department_data
IS
BEGIN
BEGIN
pkg_hr_departments.prc_adjust_department_data(120, 'Treasury', 108, 2700);
dbms_output.put_line('Success on update department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update department.');
ROLLBACK;
END;
BEGIN
pkg_hr_departments.prc_adjust_department_data(500, 'Operator', 108, 2700);
dbms_output.put_line('Success on update department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update department.');
ROLLBACK;
END;
BEGIN
pkg_hr_departments.prc_adjust_department_data(120, null, 108, 2700);
dbms_output.put_line('Success on update department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update department.');
ROLLBACK;
END;
BEGIN
pkg_hr_departments.prc_adjust_department_data(120, 'Treasury', 13, 2700);
dbms_output.put_line('Success on update department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update department.');
ROLLBACK;
END;
BEGIN
pkg_hr_departments.prc_adjust_department_data(120, 'Treasury', 100, 700);
dbms_output.put_line('Success on update department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update department.');
ROLLBACK;
END;
END prc_ut_adjust_department_data;
PROCEDURE prc_ut_remove_department
IS
BEGIN
BEGIN
pkg_hr_departments.prc_remove_department(290);
dbms_output.put_line('Success on delete department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on delete department.');
ROLLBACK;
END;
BEGIN
pkg_hr_departments.prc_remove_department(460);
dbms_output.put_line('Success on delete department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on delete department.');
ROLLBACK;
END;
BEGIN
pkg_hr_departments.prc_remove_department(340);
dbms_output.put_line('Success on delete department.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on delete department.');
ROLLBACK;
END;
END prc_ut_remove_department;
PROCEDURE prc_ut_add_employee
IS
BEGIN
BEGIN
pkg_hr_employees.prc_add_employee( 'Mihaela', 'Spirache', 'miha', '076.644.1217', SYSDATE, 'AC_MGR', 12000, NULL, 101, 290);
dbms_output.put_line('Success on insert employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_add_employee( 'Mihaela', NULL, 'mihaelaspirache', '076.644.1217', SYSDATE, 'AC_MGR', 12000, NULL, 101, 290);
dbms_output.put_line('Success on insert employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_add_employee( 'Mihaela', 'Spirache', 'miha', '076.644.1217', TO_DATE('24/07/2006','dd/mm/yyyy'), 'AC_MGR', 12000, NULL, 101, 290);
dbms_output.put_line('Success on insert employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_add_employee( 'Mihaela', 'Spirache', 'mihaelaspirache', '076.644.1217', NULL, 'AC_MGR', 12000, NULL, 101, 290);
dbms_output.put_line('Success on insert employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_add_employee( 'Mihaela', 'Spirache', 'mihaelaspirache', '076.644.1217', TO_DATE('25/03/2008','dd/mm/yyyy'), 'AC_', 12000, NULL, 101, 290);
dbms_output.put_line('Success on insert employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_add_employee( 'Mihaela', 'Spirache', 'mihaelaspirache', '076.644.1217', SYSDATE, NULL, 12000, NULL, 101, 290);
dbms_output.put_line('Success on insert employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_add_employee( 'Mihaela', 'Spirache', 'mihaelaspirache', '076.644.1217', SYSDATE, 'AC_MGR', -1000, NULL, 101, 290);
dbms_output.put_line('Success on insert employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_add_employee( 'Mihaela', 'Spirache', 'mihaelaspirache', '076.644.1217', SYSDATE, 'AC_MGR', 12000, NULL, 13, 290);
dbms_output.put_line('Success on insert employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_add_employee( 'Mihaela', 'Spirache', 'mihaelaspirache', '076.644.1217', SYSDATE, 'AC_MGR', 12000, NULL, 101, 500);
dbms_output.put_line('Success on insert employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on insert employee.');
ROLLBACK;
END;
END prc_ut_add_employee;
PROCEDURE prc_ut_adjust_employee_data
IS
BEGIN
BEGIN
pkg_hr_employees.prc_adjust_employee_data( 228, 'Miha', NULL, 'mihaelaspirache', '076.644.1217', SYSDATE, 'MK_REP', 6000, NULL, 201, 20);
dbms_output.put_line('Success on update employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_adjust_employee_data( 228, 'Miha', 'Dumitrescu', 'mihaeladumitrescu', '076.555.1217', TO_DATE('14/08/2001','dd/mm/yyyy'), 'MK_REP', 6000, NULL, 201, 20);
dbms_output.put_line('Success on update employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_adjust_employee_data( 228, 'Miha', 'Dumitrescu', 'jseo', '076.555.1217', SYSDATE, 'MK_REP', 6000, NULL, 201, 500);
dbms_output.put_line('Success on update employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_adjust_employee_data( 228, 'Miha', 'Dumitrescu', 'mihaeladumitrescu', '076.555.1217', NULL, 'MK_REP', 6000, NULL, 201, 20);
dbms_output.put_line('Success on update employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_adjust_employee_data( 228, 'Miha', 'Dumitrescu', 'mihaeladumitrescu', '076.555.1217', SYSDATE, 'MK', 6000, NULL, 201, 20);
dbms_output.put_line('Success on update employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_adjust_employee_data( 228, 'Miha', 'Dumitrescu', 'mihaeladumitrescu', '076.555.1217', SYSDATE, NULL, 6000, NULL, 201, 20);
dbms_output.put_line('Success on update employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_adjust_employee_data( 228, 'Miha', 'Dumitrescu', 'mihaeladumitrescu', '076.555.1217', TO_DATE('14/08/2001','dd/mm/yyyy'), 'MK_REP', 6000, NULL, 201, 20);
dbms_output.put_line('Success on update employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_adjust_employee_data( 228, 'Miha', 'Dumitrescu', 'mihaeladumitrescu', '076.555.1217', SYSDATE, 'MK_REP', -600, NULL, 201, 20);
dbms_output.put_line('Success on update employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on update employee.');
ROLLBACK;
END;
END prc_ut_adjust_employee_data;
PROCEDURE prc_ut_remove_employee
IS
BEGIN
BEGIN
pkg_hr_employees.prc_remove_employee(186);
dbms_output.put_line('Success on delete employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on delete employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_remove_employee(405);
dbms_output.put_line('Success on delete employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on delete employee.');
ROLLBACK;
END;
BEGIN
pkg_hr_employees.prc_remove_employee(180);
dbms_output.put_line('Success on delete employee.');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Fail on delete employee.');
ROLLBACK;
END;
END prc_ut_remove_employee;
END pkg_unit_testing;
/ | true |
91a33c62d64ee448d0a6aaa3f7aaaa7c452080e3 | SQL | MLClark/Bookmarks | /Benefit Specific/HSA/BEK/Eligibility/BEK_HSA_elig_demo.sql | UTF-8 | 5,346 | 3.015625 | 3 | [] | no_license | select distinct
-- Only employees enrolled in the HDHP plan should be included with hsa eligibility
pi.personid
,'2' ::char(1) as sort_seq
,pbemed.benefitplanid
-- 1 - Demographic Information
,'146534' ::char(7) as employer_id
,' ' ::char(10) as division
,pi.identity ::char(9) as member_number
,pi.identity ::char(9) as ssn
,pn.fname ::char(20) as fname
,pn.lname ::char(20) as lname
,pn.mname ::char(1) as mname
,to_char(pv.birthdate,'MM/DD/YYYY')::char(10) as dob
,to_char(pe.emplservicedate,'MM/DD/YYYY')::char(10) as doh
--,to_char(pe.empllasthiredate,'MM/DD/YYYY')::char(10) as ldoh
--,to_char(pe.emplservicedate,'MM/DD/YYYY')::char(10) as sdoh
,pv.gendercode ::char(1) as gender
,case when pe.emplstatus = 'T' then to_char(pe.effectivedate,'MM/DD/YYYY')::char(10) end as employee_status_date
,case when pe.emplstatus = 'T' then 'T' else ' ' ::char(1) end as employee_status
,coalesce(pa.streetaddress,pam.streetaddress) ::char(50) as addr1
,coalesce(pa.streetaddress2,pam.streetaddress2) ::char(50) as addr2
,coalesce(pa.city,pam.city) ::char(20) as city
,coalesce(pa.stateprovincecode,pam.stateprovincecode) ::char(2) as state
,coalesce(pa.postalcode,pam.postalcode) ::char(10) as zip
,case when coalesce(pa.countrycode,pam.countrycode) = 'US' then 'USA' else ' ' end ::char(3) as country
,'0771742' ::char(7) as control
,'011' ::char(3) as suffix
,'201' ::char(3) as account
,' ' ::char(10) as copay_code_med
,' ' ::char(10) as copay_code_dnt
,' ' ::char(10) as copay_code_vsn
,' ' ::char(10) as copay_code_rx
,case when bcd.benefitcoveragedesc = 'Employee Only' then 'I' else 'F' end ::char(1) as coverage_level
,' ' ::char(81) as fill81
,pncw.url::char(50) as email_address
,' ' ::char(10) as payroll_schedule_id
,' ' ::char(17) as bank_account_number
,' ' ::char(17) as bank_routing_number
,' ' ::char(3) as bank_account_type
,' ' ::char(15) as drivers_license_number
,' ' ::char(2) as drivers_license_issue_authority
-- 2 - Election Information
--,to_char(pbemed.effectivedate,'MM/DD/YYYY')::char(10) as plan_year_eff_date
-- plan year effective date needs to be the start of the current plan year not be based on effective date of coverage.
,to_char(date_trunc('year', current_date),'mm/dd/yyyy')::char(10) as plan_year_eff_date
,'16' ::char(2) as account_type
,to_char(pbemed.effectivedate,'MM/DD/YYYY')::char(10) as election_eff_date
,' ' ::char(8) as annual_ded
,' ' ::char(8) as annual_contrib
,' ' ::char(8) as sched_ded
,' ' ::char(8) as sched_contrib
,' ' ::char(1) as debit_card_selected
,' ' ::char(1) as auto_pay_dental
,' ' ::char(1) as auto_pay_healthcare
,' ' ::char(1) as auto_pay_vision
,' ' ::char(1) as auto_pay_rx
,' ' ::char(1) as fsa_first
,' ' ::char(10) as election_exp_date
,' ' ::char(10) as ltdfsa_ded_med_date
-- 3 - Additional Service Information
,'F' ::char(1) as commuter_transit
,'F' ::char(1) as commuter_parking
,' ' ::char(1) as wellness_status
,' ' ::char(10) as wellness_location
from person_identity pi
join edi.edi_last_update elu on elu.feedid = 'BEK_PayFlex_HSA_Eligibility_Export'
join person_employment pe
on pe.personid = pi.personid
and current_date between pe.effectivedate and pe.enddate
and current_timestamp between pe.createts and pe.endts
--and pe.emplstatus <> 'T'
join person_bene_election pbemed
on pbemed.personid = pe.personid
and current_date between pbemed.effectivedate and pbemed.enddate
and current_timestamp between pbemed.createts and pbemed.endts
and pbemed.benefitelection <> 'W'
and pbemed.selectedoption = 'Y'
and pbemed.benefitsubclass in ('10')
and pbemed.benefitplanid in ('9')
and (pbemed.effectivedate >= elu.lastupdatets::DATE
or (pbemed.createts > elu.lastupdatets and pbemed.effectivedate < coalesce(elu.lastupdatets, '2017-01-01')) )
left JOIN benefit_plan_desc bpd
on bpd.benefitsubclass = pbemed.benefitsubclass
and bpd.benefitplanid = pbemed.benefitplanid
and current_date between bpd.effectivedate and bpd.enddate
and current_timestamp between bpd.createts and bpd.endts
left JOIN benefit_coverage_desc bcd
on bcd.benefitcoverageid = pbemed.benefitcoverageid
and current_date between bcd.effectivedate and bcd.enddate
and current_timestamp between bcd.createts and bcd.endts
left join person_names pn
on pn.personid = pe.personid
and current_date between pn.effectivedate and pn.enddate
and current_timestamp between pn.createts and pn.endts
and pn.nametype = 'Legal'
left join person_vitals pv
on pv.personid = pe.personid
and current_date between pv.effectivedate and pv.enddate
and current_timestamp between pv.createts and pv.endts
left join person_address pa
on pa.personid = pe.personid
and current_date between pa.effectivedate and pa.enddate
and current_timestamp between pa.createts and pa.endts
and pa.addresstype = 'Res'
left join person_address pam
on pam.personid = pe.personid
and current_date between pam.effectivedate and pam.enddate
and current_timestamp between pam.createts and pam.endts
and pam.addresstype = 'Mail'
left join person_net_contacts pncw
on pncw.personid = pe.personid
and current_date between pncw.effectivedate and pncw.enddate
and current_timestamp between pncw.createts and pncw.endts
and pncw.netcontacttype = 'WRK'::bpchar
where pi.identitytype = 'SSN'
and current_timestamp between pi.createts and pi.endts | true |
e00773daa508dcec31f93e139af446b203c9ca30 | SQL | niraj125/Training-Jan-2021 | /Modules/SQL/Day6/Niraj-Sapra/View/viewextraquery.sql | UTF-8 | 4,435 | 4.46875 | 4 | [] | no_license | USE DAY6SQLMore;
/* View Task */
-- 1. Write a query to find the addresses (location_id, street_address,
--city, state_province, country_name) of all the departments.
CREATE VIEW ViewDepartments
AS
SELECT d.DepartmentName,l.LocationID,l.StreetAddress,l.City,l.StateProvince,c.CountryName
FROM Countries c
JOIN Locations l ON c.CountryID = l.CountryID
JOIN Departments d ON l.LocationID = d.LocationID;
SELECT * FROM ViewDepartments;
-- 2. Write a query to find the names (first_name, last name), department ID and name of all the employees.
CREATE VIEW ViewEmpHistory
AS
SELECT e.FirstName,e.LastName,d.DepartmentID,d.DepartmentName
FROM Employees e
LEFT OUTER JOIN Departments d ON d.DepartmentID = e.DepartmentID;
SELECT * FROM ViewEmpHistory;
-- 3. Find the names (first_name, last_name), job, department number,
--and department name of the employees who work in London.
CREATE VIEW Viewworklondon
AS
SELECT e.FirstName,e.LastName,e.JobId,d.DepartmentID,d.DepartmentName
FROM Employees e
JOIN Departments d ON e.DepartmentID = d.DepartmentID
JOIN Locations l ON d.LocationID = l.LocationID WHERE l.City = 'London';
SELECT * FROM Viewworklondon;
-- 4. Write a query to find the employee id, name (last_name) along with
--their manager_id, manager name (last_name).
CREATE VIEW ViewEmpManager
AS
SELECT e.EmployeeID, e.LastName 'Employee Last Name',e.ManagerID,em.LastName 'Manager Last Name'
FROM Employees e
LEFT OUTER JOIN Employees em ON em.EmployeeID = e.ManagerID;
SELECT * FROM ViewEmpHistory
-- 5. Find the names (first_name, last_name) and hire date of the employees who were hired
--after 'Jones'.
CREATE VIEW ViewAfterJones
AS
SELECT e.FirstName+e.LastName As 'names',e.HireDate
FROM Employees e where e.HireDate > (SELECT HireDate From Employees Where FirstName = 'Jones')
SELECT * FROM ViewAfterJones;
-- 6. Write a query to get the department name and number of employees in the department.
CREATE VIEW ViewDepartEmpNumbers
AS
SELECT d.DepartmentName,COUNT(e.EmployeeID) As 'Number Of Employees'
FROM Departments d
LEFT OUTER JOIN Employees e ON d.DepartmentID = e.DepartmentID GROUP BY d.DepartmentName;
SELECT * FROM ViewDepartEmpNumbers;
-- 7. Find the employee ID, job title, number of days between ending date and starting date
--for all jobs in department 90 from job history.
CREATE VIEW ViewDepartmentdatas
AS
SELECT EmployeeID,JobID,DATEDIFF(dd,StartDate,EndDate) As Date
FROM JobHistory WHERE DepartmentID = 90;
SELECT * FROM ViewDepartmentdatas;
-- 8. Write a query to display the department ID, department name and manager first name.
CREATE VIEW ViewDepartment
AS
SELECT d.DepartmentID,d.DepartmentName,e.FirstName AS 'Manager Names'
FROM Departments d
JOIN Employees e ON e.EmployeeID = d.ManagerID;
SELECT * FROM ViewDepartment;
-- 9. Write a query to display the department name, manager name, and city.
CREATE VIEW viewmanager
AS
SELECT d.DepartmentName,e.FirstName AS 'Manager Name',l.City
FROM Departments d
JOIN Locations l ON d.LocationID = l.LocationID
JOIN Employees e ON e.EmployeeID = d.ManagerID
;
SELECT * FROM viewmanager;
-- 10. Write a query to display the job title and average salary of employees.
CREATE VIEW ViewAVGSalary
AS
SELECT JobId,AVG(Salary) AS 'AVG Salary'
FROM Employees GROUP BY JobId;
SELECT * FROM ViewAVGSalary;
-- 11. Display job title, employee name, and the difference between salary of the
--employee and minimum salary for the job.
CREATE VIEW ViewSalaryDiff
AS
SELECT FirstName,LastName,JobId,Salary-(SELECT MIN(e.Salary) FROM Employees e WHERE em.JobId=e.JobId) 'Salary Diff'
FROM Employees em;
SELECT * FROM ViewSalaryDiff;
-- 12. Write a query to display the job history that were done by any employee who is
--currently drawing more than 10000 of salary.
CREATE VIEW ViewSalaryMore
AS
SELECT j.* FROM JobHistory j
JOIN Employees e ON j.EmployeeID = e.EmployeeID
WHERE Salary > 10000;
SELECT * FROM ViewSalaryMore;
-- 13. Write a query to display department name, name (first_name, last_name), hire date,
--salary of the manager for all managers whose experience is more than 15 years.
CREATE VIEW Viewexpmanager
AS
SELECT d.DepartmentName,e.FirstName+' '+e.LastName AS 'Name',e.HireDate ,e.Salary ,j.StartDate,j.EndDate
FROM Departments d
JOIN Employees e ON e.EmployeeID = d.ManagerID
JOIN JobHistory j ON j.EmployeeID = d.ManagerID
WHERE DATEDIFF(yy,j.StartDate,j.EndDate) > 15;
SELECT * FROM Viewexpmanager; | true |
e770220e71677459fedba8b0a2187beba2bb0638 | SQL | nivertech/Olive | /Database/Schema Objects/Schemas/Bitcoin/Programmability/Stored Procedures/GetLastProcessedTransationId.proc.sql | UTF-8 | 200 | 2.75 | 3 | [] | no_license | CREATE PROCEDURE [Bitcoin].[GetLastProcessedTransactionId]
@TransactionId VARCHAR(64) OUTPUT
AS
SELECT TOP 1 @TransactionId = TransactionId FROM Bitcoin.[Transaction]
ORDER BY CreatedAt DESC;
| true |
a8e1af7c3435f696a21f288f818dc3b7ba1fe627 | SQL | xycpand/my-lemon | /src/main/resources/dbmigrate/mysql/disk/V0_0_0_3__disk_acl.sql | UTF-8 | 467 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive |
-------------------------------------------------------------------------------
-- disk acl
-------------------------------------------------------------------------------
CREATE TABLE DISK_ACL(
ID BIGINT AUTO_INCREMENT,
TYPE VARCHAR(50),
REF VARCHAR(64),
SHARE_ID BIGINT,
CONSTRAINT PK_DISK_ACL PRIMARY KEY(ID),
CONSTRAINT FK_DISK_ACL_SHARE FOREIGN KEY (SHARE_ID) REFERENCES DISK_SHARE(ID)
) ENGINE=INNODB CHARSET=UTF8;
| true |
20a87046f82bea9bdfff67f07fbdbc8f71d2d268 | SQL | NelliMarliana/pw2020_193040165 | /Praktikum/P5_SENIN08_193040165/pw_193040165.sql | UTF-8 | 2,574 | 3.234375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 17, 2020 at 12:36 PM
-- Server version: 10.1.37-MariaDB
-- PHP Version: 7.3.0
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: `pw_193040165`
--
-- --------------------------------------------------------
--
-- Table structure for table `pakaian`
--
CREATE TABLE `pakaian` (
`ID` int(11) NOT NULL,
`JENIS PAKAIAN` varchar(100) NOT NULL,
`UKURAN` varchar(100) NOT NULL,
`STOK` char(100) NOT NULL,
`HARGA` char(100) NOT NULL,
`KETERANGAN` varchar(100) NOT NULL,
`FOTO` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `pakaian`
--
INSERT INTO `pakaian` (`ID`, `JENIS PAKAIAN`, `UKURAN`, `STOK`, `HARGA`, `KETERANGAN`, `FOTO`) VALUES
(1, 'Gamis', 'L, XL, XXL', '95', '250000', 'Bahan katun dan tidak panas, tersedia dengan hijab', '1.jpg'),
(2, 'Tunik', 'ALL SIZE', '80', '130000', 'Warna sesuai digambar, bahan licin transparan', '2.jpg'),
(3, 'Blazer Wanita', 'M, L', '50', '98000', 'Motif ada yang lain, bahan katun biasa', '3.jpg'),
(4, 'Trench Coat Wanita', 'M, L', '20', '195000', 'Bahan wol tebal', '4.jpg'),
(5, 'Rok Panjang', 'ALL SIZE', '80', '70000', 'Bahan transparan, warna sesuai gambar', '5.jpg'),
(6, 'Kulot', 'ALL SIZE', '80', '70000', 'STOK TIDAK TERSEDIA', '6.jpg'),
(7, 'Baju Koko', 'M, L, XL', '90', '135000', 'Bahan menyerap keringat dan tidak panas', '7.jpg'),
(8, 'Kemeja Pria', 'ALL SIZE', '70', '145000', 'Bahan yang dingin tidak akan terasa panas nyaman dipakai', '8.jpg'),
(9, 'Blazer Pria', 'L', '10', '70000', 'Sudah satu set dengan celana', '9.jpg'),
(10, 'Trench Coat Pria', 'L, XL', '20', '170000', 'Bahan tebal cocok digunakan saat musim dingin', '0.jpg');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `pakaian`
--
ALTER TABLE `pakaian`
ADD PRIMARY KEY (`ID`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `pakaian`
--
ALTER TABLE `pakaian`
MODIFY `ID` int(11) 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 |
2c684dc47a0e7ec2a04067d217415b8194b32674 | SQL | MauryaSrishti/NextecAssignments | /Day4_03Jan2020/PL_SQL_ExceptionHandlingPractice.sql | UTF-8 | 1,964 | 3.84375 | 4 | [] | no_license | SET serveroutput ON;
SET verify OFF;
--NAmed System Defined Exception
DECLARE
vname employees.last_name%TYPE;
vsal employees.salary%TYPE;
BEGIN
SELECT last_name, salary
INTO vname, vsal
FROM employees
WHERE employee_id IN (&empid);
dbms_output.put_line(vname||' '||vsal);
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('No Employees!');
WHEN TOO_MANY_ROWS THEN
dbms_output.put_line('More Than One Row!');
END;
--NAmed Syatem Defined Exception
DECLARE
vname employees.last_name%TYPE;
vsal employees.salary%TYPE;
BEGIN
SELECT last_name, salary
INTO vname, vsal
FROM employees
WHERE employee_id = &empid;
EXCEPTION
/*WHEN NO_DATA_FOUND THEN
dbms_output.put_line('No Employees!');*/
WHEN OTHERS THEN
dbms_output.put_line('Error...');
END;
--Unnamed System defined exceptions
DECLARE
emp_exist EXCEPTION;
PRAGMA EXCEPTION_INIT(emp_exist, -02292);
BEGIN
delete from departments
where department_id = &empid;
EXCEPTION
WHEN emp_exist THEN
dbms_output.put_line('Cannot remove department since employees exist');
END;
--Age must be between 21 and 60 else raise exception using named User defined Exception.
DECLARE
v_age NUMBER := &age;
invalid_age EXCEPTION;
BEGIN
IF v_age NOT BETWEEN 21 AND 60 THEN
RAISE invalid_age;
ELSE
dbms_output.put_line('Congrats you are eligible!');
END IF;
EXCEPTION
when invalid_age THEN
dbms_output.put_line('age must be between 21 and 60');
END;
--Age must be between 21 and 60 else raise exception using Unnamed User defined Exception.
DECLARE
v_age NUMBER := &age;
BEGIN
IF v_age NOT BETWEEN 21 AND 60 THEN
RAISE_APPLICATION_ERROR(-20111, 'Age must be 21-60');
ELSE
dbms_output.put_line('Congrats you are eligible!');
END IF;
END;
| true |
693dfdb47f94625300d4d207a2c91f05f15ac89e | SQL | neel4software/PizzaAppRepo | /sql_test_db.sql | UTF-8 | 2,668 | 3.328125 | 3 | [] | no_license | -- --------------------------------------------------------
-- Host: 127.0.0.1
-- Server version: 5.5.29-MariaDB - mariadb.org binary distribution
-- Server OS: Win32
-- HeidiSQL version: 7.0.0.4053
-- Date/time: 2014-02-11 04:35:03
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET FOREIGN_KEY_CHECKS=0 */;
-- Dumping database structure for pizza_db_test
CREATE DATABASE IF NOT EXISTS `pizza_db_test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `pizza_db_test`;
-- Dumping structure for table pizza_db_test.price
CREATE TABLE IF NOT EXISTS `price` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`product_code` varchar(230) NOT NULL,
`price` varchar(200) NOT NULL,
`store_name` varchar(200) DEFAULT NULL,
`notes` varchar(600) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
-- Dumping data for table pizza_db_test.price: ~0 rows (approximately)
/*!40000 ALTER TABLE `price` DISABLE KEYS */;
INSERT INTO `price` (`id`, `product_code`, `price`, `store_name`, `notes`) VALUES
(1, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!'),
(2, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!'),
(3, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!'),
(4, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!'),
(5, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!'),
(6, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!'),
(7, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!'),
(8, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!'),
(9, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!'),
(10, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!'),
(11, 'DOMI234', '345.66', 'SEC - 44, Gurgaon', 'Great !!');
/*!40000 ALTER TABLE `price` ENABLE KEYS */;
-- Dumping structure for table pizza_db_test.product
CREATE TABLE IF NOT EXISTS `product` (
`product_code` varchar(450) NOT NULL,
`product_name` varchar(45) NOT NULL,
`product_description` varchar(450) NOT NULL,
PRIMARY KEY (`product_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Dumping data for table pizza_db_test.product: ~0 rows (approximately)
/*!40000 ALTER TABLE `product` DISABLE KEYS */;
INSERT INTO `product` (`product_code`, `product_name`, `product_description`) VALUES
('DOMI234', 'Dominos', 'Excellent !!'),
('PIZZ101', 'PizzaHut', 'Good !!');
/*!40000 ALTER TABLE `product` ENABLE KEYS */;
/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
| true |
628bda2a978f928819e85565803452801ee9cbaa | SQL | itsdanny/SQL | /Sage/Planning/ITCR10019 Update SecurityRefs.sql | UTF-8 | 593 | 3.21875 | 3 | [] | no_license | -- this script is to update the security ref for IT change 10019
-- back up data
select * into scheme.bmwohm_10019 from scheme.bmwohm
select security_reference AS REF, CASE security_reference WHEN 'AM' THEN '1' WHEN 'PM' THEN '2' WHEN 'NS' THEN '3' WHEN '' THEN '' END, *
from scheme.bmwohm
WHERE order_date > '2016-03-14'
AND status in ('A','I')
and security_reference IS NOT NULL
UPDATE scheme.bmwohm
SET security_reference = CASE security_reference WHEN 'AM' THEN '1' WHEN 'PM' THEN '2' WHEN 'NS' THEN '3' WHEN '' THEN '' END
WHERE order_date > '2016-03-14'
AND status in ('A','I') | true |
6ee71ff13afbce44700865e936b81908d62ded45 | SQL | wuhuizhong/oracle.os_tools | /dbtools/OS_DIR_FIX.sql | UTF-8 | 830 | 2.625 | 3 | [
"MIT"
] | permissive | REM
REM This script must be run as SYS on CDB (Container level) and will spool out a script
REM for setup etcdba and DBTOOLS in all PDB's
REM
REM Then run the run_me_<CDB>.sql script to setup etcdba and DBTOOLS in all PDB's on a container.
REM The run_me script will be created in the same folder as this script is started from
REM
REM The produced script must be run as SYS on CDB level from sqlplus,sqlcl or SQL*Developer
REM
set echo off
set verify off
set term off
set heading off
set feedback off
set pagesize 0
column instance_name new_value suffix
select instance_name
from sys.v_$instance;
spool ./run_me_&suffix..sql
select 'alter session set container = '||name||';'||chr(10)||
'prompt '||name||chr(10)||
'@OS_DIR_PKB.sql'||chr(10)
from v$pdbs
where open_mode = 'READ WRITE'
and restricted = 'NO';
| true |
952d296b56c964d4828195350b5cb35c7e37902c | SQL | sebhani/RestaurantOrderingSystem | /restaurant-ordering-system-api/src/main/resources/restaurantorderingsystem_db.sql | UTF-8 | 898 | 3.046875 | 3 | [] | no_license | CREATE DATABASE restaurantorderingsystem_db;
USE restaurantorderingsystem_db;
DROP TABLE IF EXISTS `item`;
CREATE TABLE `item` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`description` varchar(200) NOT NULL,
`price` double NOT NULL,
`availability` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
LOCK TABLES `item` WRITE;
/*!40000 ALTER TABLE `item` DISABLE KEYS */;
INSERT INTO `item` VALUES (1,'Lasagna','Culinary dish made with stacked layers of pasta alternated with sauces and ingredients',15,1),(2,'Poutine','Dish that includes french fries and cheese curds topped with a brown gravy',4.35,1),(3,'Falafel','Deep-fried ball, or a flat or doughnut-shaped patty, made from ground chickpeas, fava beans, or both',8,1);
/*!40000 ALTER TABLE `item` ENABLE KEYS */;
UNLOCK TABLES;
| true |
f2a4ba6ce6606b877a76e63cfc242cabf1810649 | SQL | wudc5/LeetCode | /bytedance/TopN-sql/Solution.sql | UTF-8 | 185 | 3.390625 | 3 | [] | no_license | select a.*
from (
select country,city,visitors, row_number() over (partition by city order by visitors desc ) rank
from tripdata
order by country,city,visitors desc
) a
where a.rank<=3; | true |
9b7d07c35f030ff7c195afc4118c64c6eff5680b | SQL | temasarkisov/BMSTU-Data-Bases | /lab01/create_tables/create_table_lap_time.sql | UTF-8 | 241 | 2.90625 | 3 | [] | no_license | CREATE TABLE Lap_time(
race_id INTEGER,
driver_id INTEGER,
lap INTEGER,
position INTEGER,
time TIME,
FOREIGN KEY (race_id) REFERENCES race (race_id),
FOREIGN KEY (driver_id) REFERENCES driver (driver_id)
);
| true |
8864700eb5f6f056abac383979770235172b4907 | SQL | CityofToronto/anchorTO_DB | /CreateTables_R2.sql | UTF-8 | 1,745 | 3.265625 | 3 | [] | no_license | ALTER TABLE network.base_centreline
ADD COLUMN shape_length numeric(38, 3);
--drop table network.DMN_PLAN_TYPE_EXT;
CREATE TABLE network.DMN_PLAN_TYPE_EXT
(EXT_NAME varchar(12) NOT NULL ,
EXT_TYPE varchar(6) NOT NULL ,
DESCRIPTION varchar(500) NOT NULL ,
PLAN_TYPE varchar(50) NOT NULL ,
SORT_SEQUENCE numeric(7,2) NOT NULL ,
BIZ_EFFECTIVE_DATE timestamp NOT NULL ,
BIZ_EXPIRY_DATE timestamp NOT NULL ,
TRANS_ID_CREATE numeric(12,0) NOT NULL ,
TRANS_ID_EXPIRE numeric(12,0) NOT NULL ,
CONSTRAINT DMN_PLAN_TYPE_EXT_FK FOREIGN KEY (PLAN_TYPE)
REFERENCES network.DMN_PLAN_TYPE (PLAN_TYPE)
);
GRANT ALL ON TABLE network.DMN_PLAN_TYPE_EXT TO network;
GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE network.DMN_PLAN_TYPE_EXT TO sde;
CREATE TABLE network.DMN_CONTROL_TASK_TYPE
( CONTROL_TASK_TYPE varchar(30) NOT NULL primary key,
DESCRIPTION varchar(500) NOT NULL ,
SORT_SEQUENCE numeric(5,2) NOT NULL ,
BIZ_EFFECTIVE_DATE timestamp NOT NULL ,
BIZ_EXPIRY_DATE timestamp NOT NULL ,
TRANS_ID_CREATE numeric(12,0) NOT NULL ,
TRANS_ID_EXPIRE numeric(12,0) NOT NULL
);
CREATE UNIQUE INDEX DMN_CONTROL_TASK_TYPE_PK ON network.DMN_CONTROL_TASK_TYPE (CONTROL_TASK_TYPE);
GRANT ALL ON TABLE network.DMN_CONTROL_TASK_TYPE TO network;
GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE network.DMN_CONTROL_TASK_TYPE TO sde;
--insert into DMN_CONTROL_TASK_TYPE values ('PARCEL', 'Cadastral', 1, current_timestamp, '3000-01-01 00:00:00'::timestamp, 1, -1);
--insert into DMN_CONTROL_TASK_TYPE values ('STREET/ADDRESS', 'Centreline/Address', 2, current_timestamp, '3000-01-01 00:00:00'::timestamp, 1, -1);
select * from DMN_CONTROL_TASK_TYPE;
-----------------------------------------------------------
| true |
bea03ac85a012d6233d7eea4109d499cdf74fb98 | SQL | voatarc/voatarc | /submission-tables.sql | UTF-8 | 1,369 | 3.3125 | 3 | [
"MIT"
] | permissive |
START TRANSACTION;
SET time_zone = "+00:00";
-- --------------------------------------------------------
-- --------------------------------------------------------
CREATE TABLE submission
(
auto_id INT NOT NULL AUTO_INCREMENT
, submission_id INT NOT NULL
, title VARCHAR( 200 ) NULL
, timestamp VARCHAR( 50 ) NULL
, username VARCHAR( 100 ) NULL
, vote_score VARCHAR( 10 ) NULL
, comment_count VARCHAR( 10 ) NULL
, submission_link VARCHAR( 200 ) NULL
, submission_text VARCHAR( 4000 ) NULL
/* Keys and Indexes */
, PRIMARY KEY (auto_id)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
-- --------------------------------------------------------
CREATE TABLE comment
(
auto_id INT NOT NULL AUTO_INCREMENT
, submission_id INT NOT NULL
, comment_id INT NOT NULL
, parent_comment_id INT NULL
, timestamp VARCHAR( 50 ) NULL
, username VARCHAR( 100 ) NULL
, up_votes VARCHAR( 10 ) NULL
, down_votes VARCHAR( 10 ) NULL
, vote_score VARCHAR( 10 ) NULL
, comment_text VARCHAR( 4000 ) NULL
/* Keys and Indexes */
, PRIMARY KEY (auto_id)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
-- --------------------------------------------------------
COMMIT;
| true |
3c78ac6acda6a662a5374992f499d4181675c877 | SQL | evrimulgen/Sapia_Oracle | /bi/postpago/sql/2_vf2_015.sql | UTF-8 | 928 | 3.328125 | 3 | [] | no_license | WHENEVER SQLERROR EXIT 1;
SET ECHO ON;
SET SERVEROUTPUT ON;
SET TIMING ON;
WHENEVER SQLERROR EXIT 1;
BEGIN
DM.PKG_MGR_DWO_UTIL.PRC_DROP_TABLE(X_DES_TABLA => 'DM.DW_SPSS2_VF2_015');
END;
/
ALTER SESSION SET NLS_DATE_FORMAT='DD/MM/RRRR';
CREATE TABLE DM.DW_SPSS2_VF2_015 AS
SELECT PERIODO, MSISDN, VF2_015 FROM (
SELECT '&1' AS PERIODO, B.TELEFONO AS MSISDN, B.DESCUENTO AS VF2_015,
ROW_NUMBER () OVER (PARTITION BY B.TELEFONO ORDER BY FECHA_VENTA DESC) RW
FROM DWS.SA_SISACT_AP_VENTA V
INNER JOIN DWS.SA_SISACT_AP_VENTA_DETALLE B
ON B.ID_DOCUMENTO = V.ID_DOCUMENTO
WHERE V.TVENC_CODIGO = '01'
AND TO_CHAR (V.FECHA_VENTA, 'YYYYMM') < '&1'
AND B.DESCUENTO >0
AND V.TOPEN_CODIGO IN (1,2)
AND EXISTS (SELECT 1 FROM DWM.DW_MAESTRA_POSTPAGO D
WHERE D.MSISDN = '51'|| B.TELEFONO
AND MES = '&1'))
WHERE RW=1;
INSERT INTO DWM.DW_SPSS2_VF2_015 SELECT * FROM DM.DW_SPSS2_VF2_015;
COMMIT;
DROP TABLE DM.DW_SPSS2_VF2_015 PURGE;
EXIT; | true |
5447deabeb957a200941429a3d6ef69eb08944de | SQL | goran-erhartic-devtech/puphet_mongodb_app | /database/quickMySQL.sql | UTF-8 | 799 | 2.75 | 3 | [] | no_license | CREATE SCHEMA `guest` ;
CREATE TABLE `guest`.`employees` (
`id` INT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(45) NOT NULL,
`Age` INT NOT NULL,
`Project` VARCHAR(45) NULL,
`Department` VARCHAR(45) NULL,
`isActive` TINYINT(1) NULL,
PRIMARY KEY (`id`));
INSERT INTO `guest`.`employees` (`Name`, `Age`, `Project`, `Department`, `isActive`) VALUES ('Goran', '31', 'Onboarding', 'PHP', '1');
INSERT INTO `guest`.`employees` (`Name`, `Age`, `Project`, `Department`, `isActive`) VALUES ('Igor', '23', 'Ensighten', 'JS', '0');
INSERT INTO `guest`.`employees` (`Name`, `Age`, `Project`, `Department`, `isActive`) VALUES ('Mina', '41', 'AppRiver', '.NET', '1');
INSERT INTO `guest`.`employees` (`Name`, `Age`, `Project`, `Department`, `isActive`) VALUES ('Uros', '65', 'SwissCom', 'QA', '0');
| true |
a4aad360838ac0b2e25593be5810c3c2d447f73a | SQL | ralungei/OneClickWeb | /Debugging/prueba.sql | UTF-8 | 1,911 | 3.3125 | 3 | [] | no_license |
CREATE DATABASE Gestion;
USE Gestion;
CREATE TABLE IF NOT EXISTS Cliente
(
DNI INTEGER NOT NULL,
nombre CHAR(20) NOT NULL,
apellidos CHAR(20) NOT NULL,
fechaNac DATE NULL,
direccion CHAR(20) NULL,
PRIMARY KEY (DNI));
CREATE TABLE IF NOT EXISTS Trayecto
(
codT INTEGER NOT NULL,
coordOrigen INTEGER NOT NULL,
coordDestino INTEGER NOT NULL,
direccionOrigen CHAR(20) NULL,
direccionDestino CHAR(20) NULL,
kmsRecorridos INTEGER NULL,
fechaOrigen DATE NULL,
fechaDestino DATE NULL,
PRIMARY KEY (codT));
CREATE TABLE IF NOT EXISTS Dron
(
matricula CHAR(20) NOT NULL,
modelo CHAR(20) NULL,
combustible INTEGER NOT NULL,
potencia INTEGER NULL,
PRIMARY KEY (matricula));
CREATE TABLE IF NOT EXISTS Paquete
(
codP INTEGER NOT NULL,
descripcion CHAR(20) NULL,
destino CHAR(20) NOT NULL,
peso INTEGER NOT NULL,
PRIMARY KEY (codP));
CREATE TABLE IF NOT EXISTS Incidencia
(
codI INTEGER NOT NULL,
descripcion CHAR(120) NULL,
prioridad INTEGER NULL,
PRIMARY KEY (codI));
CREATE TABLE IF NOT EXISTS sufre
(
codT INTEGER NOT NULL,
codI INTEGER NOT NULL,
FOREIGN KEY (codT) REFERENCES Trayecto (codT),
FOREIGN KEY (codI) REFERENCES Incidencia (codI));
CREATE TABLE IF NOT EXISTS seEncuentra
(
origenmatricula CHAR(20) NOT NULL,
destinomatricula CHAR(20) NOT NULL,
metros INTEGER NOT NULL,
fecha DATE NOT NULL,
hora TIME NOT NULL,
FOREIGN KEY (origenmatricula) REFERENCES Dron (matricula),
FOREIGN KEY (destinomatricula) REFERENCES Dron (matricula));
| true |
f72a9ec3f145ea9c5f8a8bb4c62aa9693e903248 | SQL | sumit4myself/Esykart | /esykart-service/store-service/src/main/resources/sql/h2-setup.sql | UTF-8 | 780 | 2.90625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | INSERT INTO banner(name,status) VALUES ('Home Page Banner','A');
-- INSERT INTO banner_item (action_url,desc,image_url, title, banner_id) VALUES('');
INSERT INTO nav_menu (name,status) VALUES('Default Menu','A')
-- INSERT INTO nav_menu_item (name, category_id,page_id, parent_id, menu_id )
INSERT INTO page (name,url,status) VALUES ('Contact Us','/contactus','A');
INSERT INTO layout (name,default_layout,start_date,end_date,status,banner_id,nav_menu_id) values('Default Layout',true,'2016-01-01 00:00:00','2017-01-01 00:00:00','A',(select id FORM banner where name = 'Home Page Banner'),(select id FORM nav_menu where name = 'Default Menu'))
-- INSERT INTO layout_section (name,size,index,all_product_selection_rule,product_selection_rule,layout_id)
| true |
8d50d78f9896ebe4d901a83aee7fed863bbf163d | SQL | alexfdz/meetme | /meetme-openfire/src/database/meetme_mysql.sql | UTF-8 | 770 | 3.328125 | 3 | [] | no_license | INSERT INTO ofVersion (name, version) VALUES ('meetme', 0);
CREATE TABLE ofMeeting (
id BIGINT NOT NULL,
owner VARCHAR(32) NOT NULL,
description VARCHAR(255),
position VARCHAR(255),
start_time DATETIME,
status INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (owner) REFERENCES ofUser(username)
);
CREATE TABLE ofMeetingRequest (
id BIGINT NOT NULL,
meet_id BIGINT NOT NULL,
requested_user VARCHAR(32) NOT NULL,
status INTEGER NOT NULL,
updated DATETIME,
PRIMARY KEY (id),
FOREIGN KEY (meet_id) REFERENCES ofMeeting(id) ON DELETE CASCADE,
FOREIGN KEY (requested_user) REFERENCES ofUser(username)
); | true |
79b493d165b78ff77c6c5ddba3819054fcd6809f | SQL | radtek/Telecommunication | /SIM_TRADE/DataBase/SCRIPTS_FROM_DB/SIM_TRADE/TRIGGER/TIU_CONTRACTS.SQL | UTF-8 | 8,168 | 3.125 | 3 | [] | no_license |
CREATE OR REPLACE TRIGGER "SIM_TRADE"."TIU_CONTRACTS"
BEFORE INSERT OR UPDATE ON CONTRACTS
REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW
declare
vSTART integer;
vEND integer;
BEGIN
IF INSERTING THEN
IF NVL(:NEW.CONTRACT_ID, 0) = 0 then
:NEW.CONTRACT_ID := NEW_CONTRACT_ID;
END IF;
:NEW.USER_CREATED := USER;
:NEW.DATE_CREATED := SYSDATE;
END IF;
:NEW.USER_LAST_UPDATED := USER;
:NEW.DATE_LAST_UPDATED := SYSDATE;
if Updating then
IF nvl( :OLD.CONTRACT_ID , -1) <> nvl( :NEW.CONTRACT_ID , -1)
OR nvl( :OLD.CONTRACT_NUM , -1) <> nvl( :NEW.CONTRACT_NUM , -1)
OR nvl( :OLD.CONTRACT_DATE , to_date('01.01.1900','dd.mm.yyyy') ) <> nvl( :NEW.CONTRACT_DATE , to_date('01.01.1900','dd.mm.yyyy') )
OR nvl( :OLD.FILIAL_ID , -1) <> nvl( :NEW.FILIAL_ID , -1)
OR nvl( :OLD.OPERATOR_ID, -1) <> nvl( :NEW.OPERATOR_ID, -1)
OR nvl( :OLD.PHONE_NUMBER_FEDERAL , '-1') <> nvl( :NEW.PHONE_NUMBER_FEDERAL , '-1')
OR nvl( :OLD.PHONE_NUMBER_CITY , '-1') <> nvl( :NEW.PHONE_NUMBER_CITY , '-1')
OR nvl( :OLD.PHONE_NUMBER_TYPE , -1) <> nvl( :NEW.PHONE_NUMBER_TYPE , -1)
OR nvl( :OLD.TARIFF_ID , -1 ) <> nvl( :NEW.TARIFF_ID , -1 )
OR nvl( :OLD.SIM_NUMBER , '-1' ) <> nvl( :NEW.SIM_NUMBER , '-1' )
OR nvl( :OLD.SERVICE_ID , -1 ) <> nvl( :NEW.SERVICE_ID , -1 )
OR nvl( :OLD.DISCONNECT_LIMIT , -1 ) <> nvl( :NEW.DISCONNECT_LIMIT , -1 )
OR nvl( :OLD.CONFIRMED , -1 ) <> nvl( :NEW.CONFIRMED , -1 )
OR nvl( :OLD.USER_CREATED , '-1' ) <> nvl( :NEW.USER_CREATED , '-1' )
OR nvl( :OLD.DATE_CREATED , to_date('01.01.1900','dd.mm.yyyy') ) <> nvl( :NEW.DATE_CREATED , to_date('01.01.1900','dd.mm.yyyy') )
OR nvl( :OLD.ABONENT_ID , -1 ) <> nvl( :NEW.ABONENT_ID , -1 )
OR nvl( :OLD.RECEIVED_SUM , -1 ) <> nvl( :NEW.RECEIVED_SUM , -1 )
OR nvl( :OLD.START_BALANCE , -1 ) <> nvl( :NEW.START_BALANCE , -1 )
OR nvl( :OLD.GOLD_NUMBER_SUM , -1 ) <> nvl( :NEW.GOLD_NUMBER_SUM , -1 )
OR nvl( :OLD.HAND_BLOCK , -1 ) <> nvl( :NEW.HAND_BLOCK , -1 )
OR nvl( :OLD.CONNECT_LIMIT , -1 ) <> nvl( :NEW.CONNECT_LIMIT , -1 )
OR nvl( :OLD.IS_CREDIT_CONTRACT , -1 ) <> nvl( :NEW.IS_CREDIT_CONTRACT , -1 )
OR nvl( :OLD.COMMENTS , '-1' ) <> nvl( :NEW.COMMENTS , '-1' )
OR nvl( :OLD.SEND_ACTIV , -1 ) <> nvl( :NEW.SEND_ACTIV , -1 )
OR nvl( :OLD.HAND_BLOCK_DATE_END , to_date('01.01.1900','dd.mm.yyyy') ) <> nvl( :NEW.HAND_BLOCK_DATE_END , to_date('01.01.1900','dd.mm.yyyy') )
OR nvl( :OLD.DOP_STATUS , -1 ) <> nvl( :NEW.DOP_STATUS , -1 )
OR nvl( :OLD.DEALER_KOD , -1 ) <> nvl( :NEW.DEALER_KOD , -1 )
OR nvl( :OLD.ABON_TP_DISCOUNT , -1 ) <> nvl( :NEW.ABON_TP_DISCOUNT , -1 )
OR nvl( :OLD.INSTALLMENT_PAYMENT_DATE , to_date('01.01.1900','dd.mm.yyyy') ) <> nvl( :NEW.INSTALLMENT_PAYMENT_DATE , to_date('01.01.1900','dd.mm.yyyy') )
OR nvl( :OLD.INSTALLMENT_PAYMENT_SUM , -1 ) <> nvl( :NEW.INSTALLMENT_PAYMENT_SUM , -1 )
OR nvl( :OLD.INSTALLMENT_PAYMENT_MONTHS , -1 ) <> nvl( :NEW.INSTALLMENT_PAYMENT_MONTHS , -1 )
OR nvl( :OLD.INSTALLMENT_ADVANCED_REPAYMENT , to_date('01.01.1900','dd.mm.yyyy') ) <> nvl( :NEW.INSTALLMENT_ADVANCED_REPAYMENT , to_date('01.01.1900','dd.mm.yyyy') )
OR nvl( :OLD.GROUP_ID , -1 ) <> nvl( :NEW.GROUP_ID , -1 )
OR nvl( :OLD.BALANCE_BLOCK_HAND_BLOCK , -1 ) <> nvl( :NEW.BALANCE_BLOCK_HAND_BLOCK , -1 )
OR nvl( :OLD.BALANCE_NOTICE_HAND_BLOCK , -1 ) <> nvl( :NEW.BALANCE_NOTICE_HAND_BLOCK , -1 )
OR nvl( :OLD.MN_ROAMING , -1 ) <> nvl( :NEW.MN_ROAMING , -1 )
OR nvl( :OLD.CURR_TARIFF_ID , -1 ) <> nvl( :NEW.CURR_TARIFF_ID , -1 )
OR nvl( :OLD.USER_PASSWORD , '-1' ) <> nvl( :NEW.USER_PASSWORD , '-1' )
OR nvl( :OLD.OPTION_GROUP_ID , -1 ) <> nvl( :NEW.OPTION_GROUP_ID , -1 )
OR nvl( :OLD.PARAMDISABLE_SMS , '-1' ) <> nvl( :NEW.PARAMDISABLE_SMS , '-1' )
THEN
INSERT INTO SH_CONTRACTS
( CONTRACT_ID, CONTRACT_NUM, CONTRACT_DATE, FILIAL_ID, OPERATOR_ID, PHONE_NUMBER_FEDERAL, PHONE_NUMBER_CITY, PHONE_NUMBER_TYPE, TARIFF_ID, SIM_NUMBER, SERVICE_ID, DISCONNECT_LIMIT, CONFIRMED, USER_CREATED, DATE_CREATED, USER_LAST_UPDATED, DATE_LAST_UPDATED, ABONENT_ID, RECEIVED_SUM, START_BALANCE, GOLD_NUMBER_SUM, HAND_BLOCK, CONNECT_LIMIT, IS_CREDIT_CONTRACT, COMMENTS, SEND_ACTIV, HAND_BLOCK_DATE_END, DOP_STATUS, DEALER_KOD, ABON_TP_DISCOUNT, INSTALLMENT_PAYMENT_DATE, INSTALLMENT_PAYMENT_SUM, INSTALLMENT_PAYMENT_MONTHS, INSTALLMENT_ADVANCED_REPAYMENT, GROUP_ID, BALANCE_BLOCK_HAND_BLOCK, BALANCE_NOTICE_HAND_BLOCK, MN_ROAMING, CURR_TARIFF_ID, USER_PASSWORD, OPTION_GROUP_ID, PARAMDISABLE_SMS, update_user, update_time)
VALUES
( :OLD.CONTRACT_ID, :OLD.CONTRACT_NUM, :OLD.CONTRACT_DATE, :OLD.FILIAL_ID, :OLD.OPERATOR_ID, :OLD.PHONE_NUMBER_FEDERAL, :OLD.PHONE_NUMBER_CITY, :OLD.PHONE_NUMBER_TYPE, :OLD.TARIFF_ID, :OLD.SIM_NUMBER, :OLD.SERVICE_ID, :OLD.DISCONNECT_LIMIT, :OLD.CONFIRMED, :OLD.USER_CREATED, :OLD.DATE_CREATED, :OLD.USER_LAST_UPDATED, :OLD.DATE_LAST_UPDATED, :OLD.ABONENT_ID, :OLD.RECEIVED_SUM, :OLD.START_BALANCE, :OLD.GOLD_NUMBER_SUM, :OLD.HAND_BLOCK, :OLD.CONNECT_LIMIT, :OLD.IS_CREDIT_CONTRACT, :OLD.COMMENTS, :OLD.SEND_ACTIV, :OLD.HAND_BLOCK_DATE_END, :OLD.DOP_STATUS, :OLD.DEALER_KOD, :OLD.ABON_TP_DISCOUNT, :OLD.INSTALLMENT_PAYMENT_DATE, :OLD.INSTALLMENT_PAYMENT_SUM, :OLD.INSTALLMENT_PAYMENT_MONTHS, :OLD.INSTALLMENT_ADVANCED_REPAYMENT, :OLD.GROUP_ID, :OLD.BALANCE_BLOCK_HAND_BLOCK, :OLD.BALANCE_NOTICE_HAND_BLOCK, :OLD.MN_ROAMING, :OLD.CURR_TARIFF_ID, :OLD.USER_PASSWORD, :OLD.OPTION_GROUP_ID, :OLD.PARAMDISABLE_SMS, user, sysdate );
END IF;
end if;
IF INSERTING THEN
vSTART:=TO_NUMBER(TO_CHAR(:NEW.contract_date, 'YYYYMM'));
vEND:=TO_NUMBER(TO_CHAR(SYSDATE, 'YYYYMM'));
FOR I IN TRUNC(vSTART/100)..TRUNC(vEND/100)
LOOP
FOR J IN 1..12
LOOP
IF (I*100 + J >= vSTART) AND (I*100 + J <= vEND) THEN
INSERT INTO QUEUE_ABONENT_PER_REBILD(YEAR_MONTH, PHONE_NUMBER)
VALUES(I*100 + J, :NEW.phone_number_federal);
END IF;
END LOOP;
END LOOP;
END IF;
END;
ALTER TRIGGER "SIM_TRADE"."TIU_CONTRACTS" ENABLE | true |
8fe62a0e3b9af77eba1772a1aa3ad32ae497285c | SQL | Ramonrune/database-sample | /20171004/EXERCICIOS_FUNCOES.sql | WINDOWS-1252 | 11,588 | 3.703125 | 4 | [] | no_license | /* -------------------------------------------------------
Algumas funes:
-----------------------------------
CONVERSO DE TIPOS: http://www.firebirdsql.org/refdocs/langrefupd20-cast.html
-----------------------------------
CAST (<atributo> AS <tipo>)
------------------------------------------------------- */
-- 02.01. Mostrar as datas de lanamento como configuradas (dd/mm/aaaa):
select lancamento from Livro
-----------------------------------------------------------
-- 02.02. Mostrar as datas de lanamento como strings:
select CAST (lancamento AS char (08)) from Livro
-- ERRO! Faltam as barras ("?")
select CAST (lancamento AS char (10)) from Livro
-----------------------------------------------------------
/* -------------------------------------------------------
Quantidade de caracteres em string:
CHAR_LENGTH (<atributo_String>)
------------------------------------------------------- */
-- 02.03. Mostrar os ttulos dos livros e a quantidade de caracteres em cada
select titulo, CHAR_LENGTH (titulo)
from Livro
-----------------------------------------------------------
/* -------------------------------------------------------
Trecho de uma string:
SUBSTRING (<atributo_string> FROM <1_posio> FOR <qtd_caracteres>)
------------------------------------------------------- */
-- 02.04. Mostrar apenas os primeiros 10 caracteres dos ttulos dos livros
select titulo, SUBSTRING (titulo FROM 1 FOR 10)
from Livro
-- 02.04b. Mostrar apenas os primeiros 10 caracteres dos ttulos dos livros, a partir do 3
select titulo, SUBSTRING (titulo FROM 3 FOR 10)
from Livro
-----------------------------------------------------------
-- 02.05. Mostrar os ltimos 10 caracteres dos ttulos dos livros
select titulo,
SUBSTRING (titulo FROM CHAR_LENGTH (titulo) - 10 FOR CHAR_LENGTH (titulo))
from Livro
-- Oops! Mostrou os 11 caracteres finais!
select titulo,
SUBSTRING (titulo FROM CHAR_LENGTH (titulo) - 9 FOR CHAR_LENGTH (titulo))
from Livro
--
select titulo,
SUBSTRING (titulo FROM CHAR_LENGTH (titulo) - 10 FOR 10)
from Livro
-- Oops! Faltou mostrar o ltimo caractere!
select titulo,
SUBSTRING (titulo FROM CHAR_LENGTH (titulo) - 9 FOR 10)
from Livro
/* -------------------------------------------------------
Funes de data:
DATE, CURRENT_DATE, 'TODAY'
------------------------------------------------------- */
-- 02.06. Mostrar a data de hoje:
select CURRENT_DATE from RDB$DATABASE
-----------------------------------------------------------
-- 02.07. Mostrar a diferena (em dias) entre duas datas -> (mm/dd/aaaa):
select '28/09/2017' - '01/09/2017'
from RDB$DATABASE
-- ERRO! Est tentando subtrair duas strings!
select CAST ('28/09/2017' AS DATE) - CAST ('01/09/2017' AS DATE)
from RDB$DATABASE
-- ERRO! As datas deveriam ser expressas em 'mm/dd/aaaa' ou 'aaaa/mm/dd'!
select CAST ('09/28/2017' AS DATE) - CAST ('09/01/2017' AS DATE)
from RDB$DATABASE
-- OU
select CAST ('2017/09/28' AS DATE) - CAST ('2017/09/01' AS DATE)
from RDB$DATABASE
-----------------------------------------------------------
-- 02.08. Mostrar a quantidade de dias decorridos de uma data at hoje
select CURRENT_DATE - 01/10/2017
from RDB$DATABASE
select CURRENT_DATE - '01/10/2017'
from RDB$DATABASE
select CURRENT_DATE - CAST ('01/10/2017' AS DATE)
from RDB$DATABASE
-- Oops!
select CURRENT_DATE - CAST ('10/01/2017' AS DATE)
from RDB$DATABASE
select CURRENT_DATE - CAST ('2017/10/01' AS DATE)
from RDB$DATABASE
-----------------------------------------------------------
-- 02.09. Mostrar quantos dias tens de vida
select CURRENT_DATE - CAST ('1996/10/31' AS DATE)
from RDB$DATABASE
-----------------------------------------------------------
-- 02.10. Mostrar tua idade atual (aproximadamente; divida os dias por 365)
select (CURRENT_DATE - CAST ('1996/10/31' AS DATE)) / 365
from RDB$DATABASE
-----------------------------------------------------------
-- 02.11. Mostrar, separadamente, o dia, ms, ano, dia da semana e do ano das datas de lanamento dos livros
select lancamento,
EXTRACT (DAY FROM lancamento) "dia",
EXTRACT (MONTH FROM lancamento) "ms",
EXTRACT (YEAR FROM lancamento) "ano",
EXTRACT (WEEKDAY FROM lancamento) "dia sem",
EXTRACT (YEARDAY FROM lancamento) "dia ano"
from Livro
where lancamento IS NOT NULL
-----------------------------------------------------------
-- 02.12. Idem ao anterior, porm usando tua data de nascimento, ao invs de data de lanamento do livro
select CAST ('1885/10/31' AS DATE) "Nascim",
EXTRACT (DAY FROM CAST ('1885/10/31' AS DATE)) "dia",
EXTRACT (MONTH FROM CAST ('1885/10/31' AS DATE)) "ms",
EXTRACT (YEAR FROM CAST ('1885/10/31' AS DATE)) "ano",
EXTRACT (WEEKDAY FROM CAST ('1885/10/31' AS DATE)) "dia sem",
EXTRACT (YEARDAY FROM CAST ('1885/10/31' AS DATE)) "dia ano"
from RDB$DATABASE
-----------------------------------------------------------
-- 02.13. Idem ao anterior, todavia com ttulos apropriados
/* -------------------------------------------------------
Clusula CASE:
SELECT <atributo_1>, , <atributo_n>,
CASE
when <condio1> then <informao1>
when <condioN> then <informaoN>
else <informao3>
END [[AS] "<nome para este campo>"]
From <Relao>
------------------------------------------------------- */
-- 02.14. Projete os nomes e preos dos livros e, em uma nova coluna, quando tiverem o seu preo superior a R$110, informe "Caro"; quando inferiores a R$80, informe "Barato"; seno, informe "Normal".
select titulo, preco
from Livro
select titulo, preco,
CASE
WHEN preco > 110 THEN 'Caro'
WHEN preco < 80 THEN 'Barato'
ELSE 'Normal'
END "Opinio"
from Livro
-----------------------------------------------------------
-- 02.15. Projete as datas vlidas de lanamento e seus nomes de dias de semana
select lancamento
from Livro
where lancamento IS NOT NULL
select lancamento,
CASE
WHEN EXTRACT (WEEKDAY FROM lancamento) = 0 then 'Domingo'
WHEN EXTRACT (WEEKDAY FROM lancamento) = 1 then 'Segunda-feira'
WHEN EXTRACT (WEEKDAY FROM lancamento) = 2 then 'Tera-feira'
WHEN EXTRACT (WEEKDAY FROM lancamento) = 3 then 'Quarta-feira'
WHEN EXTRACT (WEEKDAY FROM lancamento) = 4 then 'Quinta-feira'
WHEN EXTRACT (WEEKDAY FROM lancamento) = 5 then 'Sexta-feira'
ELSE 'Sbado'
END "Dia de semana"
from Livro
where lancamento IS NOT NULL
/* -------------------------------------------------------
Clusula COALESCE:
COALESCE (<atributo_1> , Informao, se <atributo_1> for nulo)
------------------------------------------------------- */
-- 02.16. Mostrar o ttulo e data de lanamento de cada livro, porm se estiver vazia, o cdigo da editora e, se ambos vazios, vazio:
select titulo, lancamento
from Livro
select titulo, COALESCE (lancamento , 'No lanado')
from Livro
--
select titulo, COALESCE (CAST(lancamento AS CHAR (10)) , codedit)
from Livro
--
select titulo, COALESCE (CAST(lancamento AS CHAR (10)) ,
COALESCE (codedit , 'Nem foi aceito'))
from Livro
-----------------------------------------------------------
-- 02.17. Mostrar o ttulo do livro e o cdigo da editora, porm se estiver vazio, a data de lanamento e, se ambos vazios, "No foi aceito":
select titulo, codedit
from Livro
--
select titulo, COALESCE (codedit ,
COALESCE (CAST (lancamento AS CHAR (10)) , 'No foi aceito'))
from Livro
/* -------------------------------------------------------
Funes de agregao:
COUNT (<atrib>) -> quantidade, contagem de <atrib>
SUM (<atrib>) -> soma de valores de <atrib>
AVG (<atrib>) -> mdia aritmtica de <atrib>
MIN (<atrib>) -> menor valor de <atrib>
MAX (<atrib>) -> maior valor de <atrib>
GROUP BY <atributo_no_agregado>
------------------------------------------------------- */
-- 02.18. Mostrar quantos livros esto cadastrados
-----------------------------------------------------------
-- 02.19. Mostrar quantos livros foram aceitos por editoras
-----------------------------------------------------------
-- 02.20. Mostrar a soma dos preos dos livros
-----------------------------------------------------------
-- 02.21. Mostrar o preo mdio dos livros
-----------------------------------------------------------
-- 02.22. Mostrar quantos livros h, qual a soma de seus preos e o preo mdio
--
-----------------------------------------------------------
-- 02.23. Mostrar o menor preo, bem como o maior, o mdio e a quantidade de livros (embora no signifique nada aqui, acrescente a soma):
--
-----------------------------------------------------------
-- 02.24. Mostrar cada assunto, em ordem inversa, e quantos livros h de cada
--
-----------------------------------------------------------
-- 02.25. Mostrar quantos livros foram aceitos por cada editora
--
-----------------------------------------------------------
-- 02.26. Mostrar quantos livros foram lanados por ano
--
-----------------------------------------------------------
-- 02.27. Inserir o livro "Sistemas Operacionais", cujo cdigo o imediatamente posterior ao ltimo, aceito, mas no lanado pela Editora de cdigo = 11, e com assunto Sistemas Operacionais
-----------------------------------------------------------
-- 1) Mostrar o ltimo cdigo de livro:
-- 2) Mostrar o ltimo cdigo de livro, +1:
-- 2) Inserir o novo livro, com este cdigo encontrado:
-----------------------------------------------------------
-- 02.27b. Inserir o livro "Sistemas Operacionais Robustos", cujo cdigo o imediatamente posterior ao ltimo, com preo R$ 20,00 acima do preo mdio dos livros, aceito, mas no lanado pela Editora Brasport Editora, e assunto de Sistemas Operacionais
-----------------------------------------------------------
-- 1) Encontre o preo mdio, adicionado a R$ 20,00
-- 2) Encontre o cdigo da editora "Brasport Editora"
-- 3) Encontre a sigla do assunto "Sistemas Operacionais"
-- 4) Junte tudo e sirva com queijo parmeso ralado na hora...
/* -------------------------------------------------------
SUBSELECT --> select de select
SELECT <atributo_1>, , <atributo_n>
FROM <Relao>
WHERE <atributo_x> [NOT] IN / <operador_lgico>
(SELECT )
------------------------------------------------------- */
-- 02.28. Mostrar os ttulos e preos dos livros, cujo preos sejam superiores ao preo mdio
--
-- 1) Encontrar o preo mdio
--
-- 2) Mostrar, em funo deste preo mdio encontrado
--
------------------------------------------------------- */
-- 02.28b. Mostrar os ttulos e preos dos livros, cujos livros tenham sido aceitos pela editora "Pearson Education"
--
------------------------------------------------------- */
-- 02.28c. Mostrar os ttulos e preos dos livros, aceitos por alguma editora, cujo nome contm a palavra "Editora" em alguma posio, em qualquer caso.
--
-----------------------------------------------------------
-- 02.29. Mostrar os dados dos livros lanados aps o livro, cujo nome ser informado externamente
--
-----------------------------------------------------------
-- 02.30. Mostrar os dados dos livros lanados aps o livro, cujo trecho de nome ser informado
--
-----------------------------------------------------------
| true |
3a641d3f62059da1c61dd9eb19a9c825c90d62ab | SQL | rishi871/MyCheatSheet | /sqlscript/grades.sql | UTF-8 | 506 | 3.40625 | 3 | [] | no_license | --explain explained
-- make sure to run the container with at least 1gb shared memory
-- docker run --name pg —shm-size=1g -e POSTGRES_PASSWORD=postgres —name pg postgres
create table grades (
id serial primary key,
g int,
name text
);
insert into grades (g,
name )
select
random()*100,
substring(md5(random()::text ),0,floor(random()*31)::int)
from generate_series(0, 500);
vacuum (analyze, verbose, full);
explain analyze select id,g from grades where g > 80 and g < 95 order by g;
| true |
532faa48e6bb3a5fb2e5b1b79dc526e972fe901d | SQL | veromejia/holbertonschool-higher_level_programming | /0x0D-SQL_introduction/103-max_state.sql | UTF-8 | 244 | 3.421875 | 3 | [] | no_license | -- Write a script that displays the max temperature of each state (ordered by State name).
-- Results should display the state and the max_temp (in this order)
SELECT state, MAX(value) max_temp FROM temperatures GROUP BY state ORDER BY state;
| true |
73573af5531ec02e0c0870438380225797847cca | SQL | Leonarden/research | /emorobots/src/main/resources/sql/create_REV1.sql | UTF-8 | 15,586 | 3.890625 | 4 | [] | no_license | drop database if exists emorobots;
create database emorobots;
use emorobots;
##123456789-TOKEN-12
drop table if exists WeightNorm;
##123456789-TOKEN-13
create table WeightNorm(
/*weightNormId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,*/
entityNormId BIGINT UNSIGNED NOT NULL,
entityName Varchar(30) NOT NULL,
fear FLOAT NOT NULL DEFAULT 0,
happy FLOAT NOT NULL DEFAULT 0,
anger FLOAT NOT NULL DEFAULT 0,
sad FLOAT NOT NULL DEFAULT 0,
peace FLOAT NOT NULL DEFAULT 0,
love FLOAT NOT NULL DEFAULT 0,
lastAccess DATETIME NOT NULL,
PRIMARY KEY(entityNormId,entityName)
);
###123456789-TOKEN-0
drop table if exists Word;
###123456789-TOKEN-1
create table Word(
wordId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
text Varchar(20),
entityName Varchar(30) NOT NULL DEFAULT 'WORD',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
CONSTRAINT WeightNorm_Word_WeightNorm FOREIGN KEY (wordId,entityName)
REFERENCES WeightNorm(entityNormId,entityName) ON DELETE CASCADE
);
###123456789-TOKEN-0
drop table if exists Symbol;
###123456789-TOKEN-1
create table Symbol(
symbolId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
text Varchar(20),
entityName Varchar(30) NOT NULL DEFAULT 'SYMBOL',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess Datetime,
CONSTRAINT WeightNorm_SY_WeightNorm FOREIGN KEY (symbolId,entityName)
REFERENCES WeightNorm(entityNormId,entityName) ON DELETE CASCADE
);
###123456789-TOKEN-0
drop table if exists Sentence;
###123456789-TOKEN-1
create table Sentence(
sentenceId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
text Varchar(300),
entityName Varchar(30) NOT NULL DEFAULT 'SENTENCE',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess Datetime,
CONSTRAINT WeightNorm_SE_WeightNorm FOREIGN KEY (sentenceId,entityName)
REFERENCES WeightNorm(entityNormId,entityName) ON DELETE CASCADE
);
###123456789-TOKEN-0
drop table if exists Sentence2Sentence;
###123456789-TOKEN-1
create table Sentence2Sentence(
sentence2sentenceId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
sentenceId BIGINT UNSIGNED NOT NULL ,
sentence2Id BIGINT UNSIGNED NOT NULL ,
text Varchar(20),
entityName Varchar(30) NOT NULL DEFAULT 'Sentence2Sentence',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess Datetime,
CONSTRAINT WeightNorm_SE2SE_WeightNorm FOREIGN KEY (sentence2sentenceId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT s_Sentence21Sentence_s FOREIGN KEY (sentenceId)
REFERENCES Sentence(sentenceId) ON DELETE CASCADE,
CONSTRAINT s_Sentence2Sentence_s FOREIGN KEY (sentence2Id)
REFERENCES Sentence(sentenceId) ON DELETE CASCADE
);
###123456789-TOKEN-0
drop table if exists Problem;
###123456789-TOKEN-1
create table Problem(
problemId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
text Varchar(200),
entityName Varchar(30) NOT NULL DEFAULT 'Problem',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess Datetime,
CONSTRAINT WeightNorm_SE2SE_WeightNorm FOREIGN KEY (problemId,entityName)
REFERENCES WeightNorm(entityNormId,entityName)
);
###123456789-TOKEN-0
drop table if exists Definition;
###123456789-TOKEN-1
create table Definition(
definitionId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
problemId BIGINT UNSIGNED NOT NULL,
text Varchar(200),
entityName Varchar(30) NOT NULL DEFAULT 'Definition',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess Datetime,
CONSTRAINT WeightNorm_def_WeightNorm FOREIGN KEY (definitionId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT de_p_de FOREIGN KEY (problemId)
REFERENCES Problem(problemId) ON DELETE CASCADE
);
###123456789-TOKEN-0
drop table if exists Solution;
###123456789-TOKEN-1
create table Solution(
solutionId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
problemId BIGINT UNSIGNED NOT NULL,
text Varchar(200),
entityName Varchar(30) NOT NULL DEFAULT 'SOLUTION',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess Datetime,
CONSTRAINT WeightNorm_sol_WeightNorm FOREIGN KEY (solutionId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT p_s_p FOREIGN KEY (problemId)
REFERENCES Problem(problemId)
);
###123456789-TOKEN-10
drop table if exists Problem2Problem;
###123456789-TOKEN-11
create table Problem2Problem(
problem2problemId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
problemId BIGINT UNSIGNED NOT NULL,
problem2Id BIGINT UNSIGNED NOT NULL,
entityName Varchar(50) default 'problem2problem',
text Varchar(300) ,
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
PRIMARY KEY(problem2problemId),
CONSTRAINT WeightNorm_sol_WeightNorm FOREIGN KEY (problem2problemId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT p_p2p_p FOREIGN KEY (problemId)
REFERENCES Problem(problemId),
CONSTRAINT p_p22p_p FOREIGN KEY (problem2Id)
REFERENCES Problem(problemId)
);
###123456789-TOKEN-10
drop table if exists Definition2Definition;
###123456789-TOKEN-11
create table Definition2Definition(
definition2definitionId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
definitionId BIGINT UNSIGNED NOT NULL,
definition2Id BIGINT UNSIGNED NOT NULL,
text Varchar(300) ,
entityName Varchar(50) NOT NULL DEFAULT 'definition2definition',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
CONSTRAINT WeightNorm_de2de_WeightNorm FOREIGN KEY (definition2definitionId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT d_de2de_d FOREIGN KEY (definitionId)
REFERENCES Definition(definitionId) ,
CONSTRAINT d_de2de_d FOREIGN KEY (definition2Id)
REFERENCES Definition(definitionId)
);
###123456789-TOKEN-10
drop table if exists Solution2Solution;
###123456789-TOKEN-11
create table Solution2Solution(
solution2solutionId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
solutionId BIGINT UNSIGNED NOT NULL,
solution2Id BIGINT UNSIGNED NOT NULL,
text Varchar(300) ,
entityName Varchar(50) NOT NULL DEFAULT 'solution2solution',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
CONSTRAINT WeightNorm_so2so_WeightNorm FOREIGN KEY (solution2solutionId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT s_so2so_s FOREIGN KEY (solution2Id)
REFERENCES Solution(solutionId) ,
CONSTRAINT s_so2so1_s FOREIGN KEY (solutionId)
REFERENCES Solution(solutionId)
);
###123456789-TOKEN-0
drop table if exists Subject;
###123456789-TOKEN-1
create table Subject(
subjectId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
applicationId BIGINT UNSIGNED,
text Varchar(20),
entityName Varchar(30) NOT NULL DEFAULT 'subject',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess Datetime,
CONSTRAINT WeightNorm_sub_WeightNorm FOREIGN KEY (subjectId,entityName)
REFERENCES WeightNorm(entityNormId,entityName)
);
###123456789-TOKEN-0
drop table if exists Observer;
###123456789-TOKEN-1
create table Observer(
observerId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
subjectId BIGINT UNSIGNED NOT NULL,
text Varchar(20),
entityName Varchar(50) NOT NULL DEFAULT 'observer',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess Datetime,
CONSTRAINT WeightNorm_obs_WeightNorm FOREIGN KEY (observerId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT o_s_o FOREIGN KEY (subjectId)
REFERENCES Subject(subjectId)
);
###123456789-TOKEN-0
drop table if exists Command;
###123456789-TOKEN-1
create table Command(
commandId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
observerId BIGINT UNSIGNED NOT NULL,
text Varchar(20),
entityName Varchar(30) NOT NULL DEFAULT 'command',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess Datetime,
CONSTRAINT WeightNorm_com_WeightNorm FOREIGN KEY (commandId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT c_o_c FOREIGN KEY (observerId)
REFERENCES Observer(observerId)
);
###123456789-TOKEN-0
drop table if exists Action;
###123456789-TOKEN-1
create table Action(
actionId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
commandId BIGINT UNSIGNED NOT NULL,
text Varchar(20),
entityName Varchar(30) NOT NULL DEFAULT 'action',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess Datetime,
CONSTRAINT WeightNorm_act_WeightNorm FOREIGN KEY (actionId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT a_c_a FOREIGN KEY (commandId)
REFERENCES Command(commandId)
);
##123456789-TOKEN-10
drop table if exists SubjectProblem;
##123456789-TOKEN-11
create table SubjectProblem(
subjectproblemId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
subjectId BIGINT UNSIGNED NOT NULL,
problemId BIGINT UNSIGNED NOT NULL,
text Varchar(300) ,
entityName Varchar(50) NOT NULL DEFAULT 'subjectproblem',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
CONSTRAINT WeightNorm_sp_WeightNorm FOREIGN KEY (subjectproblemId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT p_sp_p FOREIGN KEY (problemId)
REFERENCES Problem(problemId) ON DELETE CASCADE,
CONSTRAINT s_sp_s FOREIGN KEY (subjectId)
REFERENCES Subject(subjectId) ON DELETE CASCADE
);
##123456789-TOKEN-10
drop table if exists ObserverProblem;
##123456789-TOKEN-11
create table ObserverProblem(
observerproblemId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
observerId BIGINT UNSIGNED NOT NULL,
problemId BIGINT UNSIGNED NOT NULL,
text Varchar(300) ,
entityName Varchar(50) NOT NULL DEFAULT 'Observerproblem',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
CONSTRAINT WeightNorm_obs_WeightNorm FOREIGN KEY (observerproblemId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT p_op_p FOREIGN KEY (problemId)
REFERENCES Problem(problemId) ON DELETE CASCADE,
CONSTRAINT s_op_s FOREIGN KEY (ObserverId)
REFERENCES Observer(ObserverId) ON DELETE CASCADE
);
##123456789-TOKEN-10
drop table if exists CommandProblem;
##123456789-TOKEN-11
create table CommandProblem(
commandproblemId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
commandId BIGINT UNSIGNED NOT NULL,
problemId BIGINT UNSIGNED NOT NULL,
text Varchar(300) ,
entityName Varchar(50) NOT NULL DEFAULT 'Commandproblem',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
CONSTRAINT WeightNorm_comp_WeightNorm FOREIGN KEY (commandproblemId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT p_comp_p FOREIGN KEY (problemId)
REFERENCES Problem(problemId) ON DELETE CASCADE,
CONSTRAINT s_cp_s FOREIGN KEY (CommandId)
REFERENCES Command(CommandId) ON DELETE CASCADE
);
##123456789-TOKEN-10
drop table if exists ActionProblem;
##123456789-TOKEN-11
create table ActionProblem(
actionproblemId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
actionId BIGINT UNSIGNED NOT NULL,
problemId BIGINT UNSIGNED NOT NULL,
text Varchar(300) ,
entityName Varchar(50) NOT NULL DEFAULT 'Actionproblem',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
CONSTRAINT WeightNorm_comp_WeightNorm FOREIGN KEY (actionproblemId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT p_comp_p FOREIGN KEY (problemId)
REFERENCES Problem(problemId) ON DELETE CASCADE,
CONSTRAINT s_cp_s FOREIGN KEY (ActionId)
REFERENCES Action(ActionId) ON DELETE CASCADE
);
##123456789-TOKEN-10
drop table if exists SubjectProblem2SubjectProblem;
##123456789-TOKEN-11
create table SubjectProblem2SubjectProblem(
subjectproblem2subjectproblemId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
subjectproblemId BIGINT UNSIGNED NOT NULL,
subjectproblem2Id BIGINT UNSIGNED NOT NULL,
text Varchar(300) ,
entityName Varchar(50) NOT NULL DEFAULT 'SubjectProblem2SubjectProblem',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
CONSTRAINT WeightNorm_sp2sp_WeightNorm FOREIGN KEY (subjectproblem2subjectproblemId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT sp_sp2sp_sp FOREIGN KEY (subjectproblemId)
REFERENCES SubjectProblem(subjectproblemId) ON DELETE CASCADE,
CONSTRAINT sp1_sp2sp_sp1 FOREIGN KEY (subjectproblem2Id)
REFERENCES SubjectProblem(subjectproblemId) ON DELETE CASCADE
);
##123456789-TOKEN-10
drop table if exists ObserverProblem2ObserverProblem;
##123456789-TOKEN-11
create table ObserverProblem2ObserverProblem(
observerproblem2observerproblemId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
observerproblemId BIGINT UNSIGNED NOT NULL,
observerproblem2Id BIGINT UNSIGNED NOT NULL,
text Varchar(300) ,
entityName Varchar(50) NOT NULL DEFAULT 'ObserverProblem2ObserverProblem',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
CONSTRAINT WeightNorm_sp2sp_WeightNorm FOREIGN KEY (observerproblem2observerproblemId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT op_op2op_op FOREIGN KEY (observerproblemId)
REFERENCES ObserverProblem(observerproblemId) ON DELETE CASCADE,
CONSTRAINT op1_op2op_op1 FOREIGN KEY (observerproblem2Id)
REFERENCES ObserverProblem(observerproblemId) ON DELETE CASCADE
);
##123456789-TOKEN-10
drop table if exists CommandProblem2CommandProblem;
##123456789-TOKEN-11
create table CommandProblem2CommandProblem(
commandproblem2commandproblemId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
commandproblemId BIGINT UNSIGNED NOT NULL,
commandproblem2Id BIGINT UNSIGNED NOT NULL,
text Varchar(300) ,
entityName Varchar(50) NOT NULL DEFAULT 'CommandProblem2CommandProblem',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
CONSTRAINT WeightNorm_sp2sp_WeightNorm FOREIGN KEY (commandproblem2commandproblemId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT cp_cp2cp_cp FOREIGN KEY (commandproblemId)
REFERENCES CommandProblem(commandproblemId) ON DELETE CASCADE,
CONSTRAINT cp1_cp2sp_cp1 FOREIGN KEY (commandproblem2Id)
REFERENCES CommandProblem(commandproblemId) ON DELETE CASCADE
);
##123456789-TOKEN-10
drop table if exists ActionProblem2ActionProblem;
##123456789-TOKEN-11
create table ActionProblem2ActionProblem(
actionproblem2actionproblemId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
actionproblemId BIGINT UNSIGNED NOT NULL,
actionproblem2Id BIGINT UNSIGNED NOT NULL,
text Varchar(300) ,
entityName Varchar(50) NOT NULL DEFAULT 'ActionProblem2ActionProblem',
numaccess BIGINT UNSIGNED NOT NULL DEFAULT 0,
lastaccess DATETIME,
CONSTRAINT WeightNorm_ap2ap_WeightNorm FOREIGN KEY (actionproblem2actionproblemId,entityName)
REFERENCES WeightNorm(entityNormId,entityName),
CONSTRAINT ap_cp2ap_cp FOREIGN KEY (actionproblemId)
REFERENCES ActionProblem(actionproblemId) ON DELETE CASCADE,
CONSTRAINT ap1_cp2sp_cp1 FOREIGN KEY (actionproblem2Id)
REFERENCES ActionProblem(actionproblemId) ON DELETE CASCADE
);
| true |
203ae2b099b431e34082345bdf37bd8e3a0f4fda | SQL | CrystleJ/QueryBooksDatabase | /Booksdatabase/Booksdatabase_authors.sql | UTF-8 | 2,292 | 2.96875 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 8.0.12, for macos10.13 (x86_64)
--
-- Host: 127.0.0.1 Database: Booksdatabase
-- ------------------------------------------------------
-- Server version 8.0.12
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
SET NAMES utf8 ;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `Authors`
--
DROP TABLE IF EXISTS `Authors`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `Authors` (
`authorID` int(11) NOT NULL AUTO_INCREMENT,
`firstName` char(20) DEFAULT NULL,
`lastName` char(20) DEFAULT NULL,
PRIMARY KEY (`authorID`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Authors`
--
LOCK TABLES `Authors` WRITE;
/*!40000 ALTER TABLE `Authors` DISABLE KEYS */;
INSERT INTO `Authors` VALUES (1,'David','Mitchell'),(2,'Mary','Karr'),(3,'Thomas','Pyncho'),(4,'Margaret','Atwood'),(5,'Leo','Tolstoy'),(6,'Herman','Melville'),(7,'James','Joyce'),(8,'Carlos','Zafon'),(9,'J.R.R','Tolkien'),(10,'Philip','Pullman'),(11,'Joseph','Heller'),(12,'Louisa','Alcott'),(13,'Kathryn','Stockett'),(14,'George','Orwell'),(15,'Toni','Morrison');
/*!40000 ALTER TABLE `Authors` 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 2018-11-26 19:29:23
| true |
ef858e82aed4093aecc6ea80ced8fe66caf667b5 | SQL | mishellscripts/Cat-Adoption-Center | /sql/procedures.sql | UTF-8 | 3,416 | 4.125 | 4 | [] | no_license | DROP PROCEDURE IF EXISTS adopt_cat;
delimiter //
CREATE PROCEDURE adopt_cat(IN personID INT, IN catID INT)
BEGIN
INSERT INTO adoption(pID, cID) VALUES(personID, catID);
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS donate_cat;
delimiter //
CREATE PROCEDURE donate_cat(IN age INT, IN gender CHAR, IN breed VARCHAR(20), IN locID INT, IN cat_name VARCHAR(20))
BEGIN
INSERT INTO cat(cName, age, gender, breed, locID)
VALUES(cat_name, age, gender, breed, locID);
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS search_adoption_center;
delimiter //
CREATE PROCEDURE search_adoption_center(IN location VARCHAR(20))
BEGIN
SELECT * FROM adoption_center a WHERE a.location=location AND locID IN
(SELECT c.locID FROM adoption_center a, cat c GROUP BY c.locID HAVING(count(*)>0));
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS search_adoption_center_cats;
delimiter //
CREATE PROCEDURE search_adoption_center_cats(IN locID INT)
BEGIN
SELECT * FROM cat c WHERE c.locID=locID AND adopted=0;
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS search_adoption_center_records;
delimiter //
CREATE PROCEDURE search_adoption_center_records(IN locID INT)
BEGIN
SELECT cID, cName, age, gender, breed, disease
FROM cat c JOIN medical m USING(cID)
WHERE c.locID=locID AND adopted=0;
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS return_cat;
delimiter //
CREATE PROCEDURE return_cat(IN catID INT)
BEGIN
DELETE FROM adoption WHERE adoption.cID=catID;
UPDATE cat SET adopted=0 WHERE cat.cID=catID;
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS search_records;
delimiter //
CREATE PROCEDURE search_records()
BEGIN
SELECT c.cID, c.cName, c.age, c.gender, c.breed, m.disease, m.medical_fee
FROM cat c LEFT OUTER JOIN medical m USING(cID);
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS register_cat;
delimiter //
CREATE PROCEDURE register_cat(
IN uName VARCHAR(20),
IN uAge INT,
IN uGender VARCHAR(1),
IN uBreed VARCHAR(20),
IN uAdoption_fee DOUBLE,
IN uLocID INT
)
BEGIN
INSERT INTO cat (cName, age, gender, breed, adoption_fee, locID)
VALUES (uName, uAge, uGender, uBreed, uAdoption_fee, uLocID);
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS update_cat_medical_fee;
delimiter //
CREATE PROCEDURE update_cat_medical_fee(IN uCID INT, IN uDisease VARCHAR(20), IN uFee DOUBLE)
BEGIN
UPDATE medical SET medical_fee = uFee WHERE cID = uCID AND disease = uDisease;
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS remove_cat_medical_record;
delimiter //
CREATE PROCEDURE remove_cat_medical_record(IN uCID INT, IN uDisease VARCHAR(20))
BEGIN
DELETE FROM medical WHERE cID = uCID AND disease = uDisease;
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS register_cat_medical_record;
delimiter //
CREATE PROCEDURE register_cat_medical_record(IN uCID INT, IN uDisease VARCHAR(20), IN uFee DOUBLE)
BEGIN
INSERT INTO medical (cID, disease, medical_fee) VALUES (uCID, uDisease, uFee);
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS view_all_adoptions;
delimiter //
CREATE PROCEDURE view_all_adoptions()
BEGIN
SELECT * FROM
adoption JOIN cat
ON adoption.cID = cat.cID
JOIN person ON adoption.pID = person.pID;
END;
//
delimiter ;
DROP PROCEDURE IF EXISTS archive_adoptions;
delimiter //
CREATE PROCEDURE archive_adoptions(IN cutoff TIMESTAMP)
BEGIN
INSERT INTO archive (pID, cID, adoption_date) (
SELECT pID, cID, adoption_date FROM adoption WHERE updatedAt < cutoff);
DELETE FROM adoption WHERE updatedAt < cutoff;
END;
//
delimiter ; | true |
f91998dba79952bf3a156cc3f37f890a5a2f2e43 | SQL | deflaux/bigquery-examples | /1000genomes/sql/reproducing-vcfstats/snp-variant-counts-brca1.sql | UTF-8 | 358 | 3.375 | 3 | [
"Apache-2.0"
] | permissive | # Count SNPs by base pair transition across BRCA1.
SELECT
reference_bases,
alternate_bases AS allele,
COUNT(alternate_bases) AS num_snps
FROM
[genomics-public-data:1000_genomes.variants]
WHERE
reference_name = '17'
AND start BETWEEN 41196311
AND 41277499
AND vt ='SNP'
GROUP BY
reference_bases,
allele
ORDER BY
reference_bases,
allele | true |
ed579d3f2898a31cc8f3b5daa91610075a180205 | SQL | imanojkumar/mortgage-dashboard | /postgresql.sql | UTF-8 | 3,452 | 3 | 3 | [
"MIT"
] | permissive | CREATE TABLE "Acct_perf" (
"ACCT_NUM" int NOT NULL,
"PRD_CD" int NOT NULL,
"CREDIT_RISK_INDICATOR" varchar(20),
"TM_ON_BOOK" int,
"DAY_PST_DUE" int,
"RMNG_AMORT_PERIOD" int,
"DEFLT_INSUR_CD" varchar(20),
"CRNT_AUTH_LIMIT_AMT" decimal,
"OS_BAL_AMT" decimal,
"PRPTY_TYPE_CD" varchar(20),
"PRPTY_POSTAL_CD" char(6),
"CRNT_LTV_RATIO" FLOAT,
"MTH_END_DT" DATE,
"INSURANCE_FEE_INDICATOR" varchar(5),
PRIMARY KEY ("ACCT_NUM")
);
CREATE TABLE "DATA_PRODUCT_MAPPING_LKP" (
"PRD_CD" int NOT NULL,
"IB_CB_INDICATOR" char(2) NOT NULL,
"PRD_LVL1" varchar(100),
"PRD_LVL2" varchar(100),
"PRD_LVL3" varchar(100),
"PRD_LVL4" varchar(100),
"PRD_LVL5" varchar(100),
"EFF_FROM_DT" DATE,
"EFF_TO_DT" DATE,
"CRNT_F" char(1),
"INSRT_PROCESS_TMSTMP" decimal,
"UPDT_PROCESS_TMSTMP" decimal,
PRIMARY KEY ("PRD_CD")
);
ALTER TABLE "Acct_perf" ADD CONSTRAINT "Acct_perf_fk0" FOREIGN KEY ("PRD_CD") REFERENCES "DATA_PRODUCT_MAPPING_LKP"("PRD_CD");
-- after load data into above tables, create view VW_RESD_MTGE_OA_RISK :
-- 代码中的::相当于cast(xxx as int/varchar)
create view VW_RESD_MTGE_OA_RISK as
SELECT a."ACCT_NUM",
p."PRD_CD",
concat(
CASE
WHEN "substring"(a."MTH_END_DT"::character varying::text, 6, 2)::integer = ANY (ARRAY[1, 11, 12]) THEN 'Q1'::text
WHEN "substring"(a."MTH_END_DT"::character varying::text, 6, 2)::integer = ANY (ARRAY[2, 3, 4]) THEN 'Q2'::text
WHEN "substring"(a."MTH_END_DT"::character varying::text, 6, 2)::integer = ANY (ARRAY[5, 6, 7]) THEN 'Q3'::text
WHEN "substring"(a."MTH_END_DT"::character varying::text, 6, 2)::integer = ANY (ARRAY[8, 9, 10]) THEN 'Q4'::text
ELSE NULL::text
END, '-',
CASE
WHEN "substring"(a."MTH_END_DT"::character varying::text, 6, 2)::integer = ANY (ARRAY[11, 12]) THEN (("substring"(a."MTH_END_DT"::character varying::text, 3, 2)::integer + 1)::character varying)::text
ELSE "substring"(a."MTH_END_DT"::character varying::text, 3, 2)
END) AS "QUARTER_YEAR",
CASE
WHEN "substring"(a."PRPTY_POSTAL_CD"::text, 1, 1) = ANY (ARRAY['T'::text, 'S'::text, 'R'::text]) THEN 'Prairies'::text
WHEN "substring"(a."PRPTY_POSTAL_CD"::text, 1, 1) = ANY (ARRAY['A'::text, 'B'::text, 'C'::text, 'E'::text]) THEN 'Atlantic'::text
WHEN "substring"(a."PRPTY_POSTAL_CD"::text, 1, 1) = ANY (ARRAY['H'::text, 'G'::text, 'J'::text]) THEN 'Quebec'::text
WHEN "substring"(a."PRPTY_POSTAL_CD"::text, 1, 1) = ANY (ARRAY['P'::text, 'L'::text, 'N'::text, 'K'::text]) THEN 'Ontario'::text
WHEN "substring"(a."PRPTY_POSTAL_CD"::text, 1, 1) = 'V'::text THEN 'BC'::text
WHEN "substring"(a."PRPTY_POSTAL_CD"::text, 1, 1) = 'M'::text THEN 'Toronto'::text
WHEN "substring"(a."PRPTY_POSTAL_CD"::text, 1, 1) = ANY (ARRAY['X'::text, 'Y'::text]) THEN 'Other'::text
ELSE 'Ontario'::text
END AS "REGION",
a."DAY_PST_DUE",
a."DEFLT_INSUR_CD",
a."PRPTY_TYPE_CD",
a."OS_BAL_AMT",
a."CRNT_LTV_RATIO",
round(a."OS_BAL_AMT"::double precision / a."CRNT_LTV_RATIO") AS "CRNT_PRPTY_VAL_AMT",
p."PRD_LVL4" AS "PRD_TYPE",
p."EFF_FROM_DT" AS "PRD_EFF_FROM_DT",
p."EFF_TO_DT" AS "PRD_EFF_TO_DT"
FROM "Acct_perf" a
JOIN "DATA_PRODUCT_MAPPING_LKP" p ON a."PRD_CD" = p."PRD_CD"
WHERE p."PRD_LVL4"::text = 'Standard Mortgages'::text
ORDER BY a."ACCT_NUM"; | true |
258528bda62f976b350316930702c06316d82b44 | SQL | cmu-delphi/github-deploy-repo | /src/ddl/github_deploy_repo.sql | UTF-8 | 1,381 | 3.625 | 4 | [
"MIT"
] | permissive | /*
`github_deploy_repo` is the table where repo information is stored.
+----------+--------------+------+-----+---------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| repo | varchar(128) | NO | UNI | NULL | |
| commit | char(40) | NO | | 0000[...]0000 | |
| datetime | datetime | NO | | NULL | |
| status | int(11) | NO | | 0 | |
+----------+--------------+------+-----+---------------+----------------+
- `id`
unique identifier for each record
- `repo`
the name of the github repo (in the form of "owner/name/branch")
- `commit`
hash of the latest commit
- `datetime`
the date and time of the last status update
- `status`
one of 0 (queued), 1 (success), 2 (skipped), or -1 (failed)
*/
CREATE TABLE `github_deploy_repo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`repo` varchar(128) NOT NULL,
`commit` char(40) NOT NULL DEFAULT '0000000000000000000000000000000000000000',
`datetime` datetime NOT NULL,
`status` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `repo` (`repo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
| true |
ee66c90917f986acc5b1fcf320cded7b32992c64 | SQL | cjx1996/Java_Learning | /2_MySQL/2_代码/day02/8. 【案例讲解】分组查询.sql | UTF-8 | 1,003 | 4.1875 | 4 | [] | no_license | USE myemployees;
#1. 查询各job_id的员工工资的最大值、最小值、平均值、总和,并按job_id升序
SELECT
MAX(salary) maximum,
MIN(salary) minimum,
AVG(salary) average,
SUM(salary) 'sum' ,
job_id
FROM
employees
GROUP BY job_id
ORDER BY job_id ASC ;
#2. 查询员工最高工资和最低工资的差距
SELECT
MAX(salary) - MIN(salary) difference
FROM
employees ;
#3. 查询各个管理者手下员工的最低工资,其中最低工资不能低于6000,没有管理者的员工不计算在内
SELECT MIN(salary) minimum,manager_id
FROM employees
WHERE manager_id IS NOT NULL
GROUP BY manager_id
HAVING MIN(salary) >= 6000;
#4. 查询所有部门的编号,员工数量和工资平均值,并按平均值工资降序
SELECT COUNT(*) counts,ROUND(AVG(salary),2)AS average,department_id
FROM employees
GROUP BY department_id
ORDER BY AVG(salary) DESC;
#选择具有各个job_id的员工人数
SELECT COUNT(*) counts,job_id
FROM employees
GROUP BY job_id;
| true |
f20035522da202c84dbd148e507f6b3b964e0ef2 | SQL | MartinHolding/CodecademyProjects | /Twitch Data Project/sqlQueries.sql | UTF-8 | 1,756 | 4.4375 | 4 | [] | no_license | /* Check what data we have */
SELECT *
FROM stream
LIMIT 20;
SELECT *
FROM chat
LIMIT 20;
/* What distinct games do we have */
SELECT DISTINCT game
FROM stream;
SELECT DISTINCT channel
FROM stream;
/* Get a count of the viewers for each game */
SELECT game, COUNT(*)
FROM stream
GROUP BY game
ORDER BY COUNT(*) DESC;
/* Get a count of the streams of LoL for each country */
SELECT country, COUNT(country)
FROM stream
WHERE game = 'League of Legends'
GROUP BY country
ORDER BY COUNT(country) DESC;
/*Get a count of how many users use that playing device to view streams */
SELECT player, COUNT(player)
FROM stream
GROUP BY player
ORDER BY COUNT(player) DESC;
/*Create new column of genre of each game */
SELECT game,
CASE
WHEN game = 'League of Legends'
THEN 'MOBA'
WHEN game = 'DOTA 2'
THEN 'MOBA'
WHEN game = 'Heroes of the Storm'
THEN 'MOBA'
WHEN game = 'Counter-Strike: Global Offensive'
THEN 'FPS'
WHEN game = 'DayZ'
THEN 'Survival'
WHEN game = 'ARK: Survival Evolved'
THEN 'Survival'
ELSE 'Other'
END AS 'genre',
COUNT(*)
FROM stream
GROUP BY game
ORDER BY COUNT(*) DESC;
/* Look at the change in view count across the day */
SELECT time
FROM stream
LIMIT 10;
/* Return a table of each hour in the day and view count of that hour in the UK*/
SELECT strftime('%H', time) AS hour, COUNT(*), country
FROM stream
WHERE country = 'GB'
GROUP BY hour
ORDER BY COUNT(*) DESC;
/* Do an inner join on device_id */
SELECT *
FROM stream
INNER JOIN chat ON stream.device_id = chat.device_id;
/* Now review how chat and game users vary by country*/
SELECT country, COUNT(*)
FROM stream
GROUP BY country
ORDER BY COUNT(*) DESC;
SELECT country, COUNT(*)
FROM chat
GROUP BY country;
| true |
0b869cd322b51e09b13288e61ceeae1435a90a12 | SQL | qingyuan1017/emory_hw | /EMORY_CS_HW/cs377/project5/5.sql | UTF-8 | 103 | 2.796875 | 3 | [] | no_license | select distinct jnum A
from spj
where pnum in
(select pnum
from spj
where spj.snum = 's4')
order by A
| true |
879ffd07894cddc2a7ae2271d23f1301fb00d15d | SQL | glennoph/mysql-data-analytics | /sql/storedprocedure/02-storedprocedure-with-output.sql | UTF-8 | 789 | 3.890625 | 4 | [] | no_license | -- storedprocedure-with-output
use employees;
select * from employees;
select emp_no
from employees
where first_name = 'Mary'
and last_name = 'Sluis';
-- Create a procedure called ‘emp_info’
-- that uses as parameters the first and the last name of an individual, and
-- returns their employee number.
drop procedure if exists emp_info;
delimiter $$
create procedure emp_info(in p_first_name varchar(20), in p_last_name varchar(20),
out p_emp_no int)
begin
select emp_no into p_emp_no
from employees
where first_name = p_first_name
and last_name = p_last_name;
end$$
delimiter ;
-- variable @p_emp_no
set @p_emp_no = 0;
call emp_info('Mary', 'Sluis', @p_emp_no) ;
select @p_emp_no;
set @p_emp_no = 0;
call emp_info('Aruna', 'Journel', @p_emp_no) ;
select @p_emp_no;
| true |
8d4117ef45f52be8467e807b7086f09d332bd9a1 | SQL | chosemove/University-of-homework | /数据库大实习/数据库代码/animalSystem/procedure/create_procedure_pr_insert_into_animal.sql | GB18030 | 899 | 2.984375 | 3 | [] | no_license | CREATE OR REPLACE
PROCEDURE pr_insert_into_animal
/*
洢pr_insert_into_animal
ڶANIMALв룬ͼƬǷƶطţڴ˴
룺
P_ANIMAL_ID in VARCHAR2,
P_ANIMAL_NAME in VARCHAR2,
p_ANIMAL_SPECIES in VARCHAR2,
P_ANIMAL_AGE in Number,
P_SHELTER_ID in VARCHAR2,
p_out_resulutΪʾǷɹ
*/
(
P_ANIMAL_ID in VARCHAR2,
P_ANIMAL_NAME in VARCHAR2,
p_ANIMAL_SPECIES in VARCHAR2,
P_ANIMAL_AGE in Number,
P_SHELTER_ID in VARCHAR2,
p_out_resulut out int
)AS
BEGIN
INSERT INTO "ANIMAL"("ANIMAL_ID", "ANIMAL_NAME", "ANIMAL_SPECIES", "ANIMAL_AGE", "ANIMAL_IMAGE", "SHELTER_ID")
VALUES (P_ANIMAL_ID, P_ANIMAL_NAME, p_ANIMAL_SPECIES, P_ANIMAL_AGE, NULL, P_SHELTER_ID);
p_out_resulut:=1;
exception
when others then
p_out_resulut:=0;
END pr_insert_into_animal;
| true |
122d53fe9a964e27a553a93fb7fb5da0129344a6 | SQL | amandar8/killbase | /killbase.sql | UTF-8 | 2,905 | 3.78125 | 4 | [] | no_license | DROP DATABASE IF EXISTS killbase;
CREATE DATABASE killbase;
\c killbase
CREATE TABLE assassins (id serial primary key, full_name text, weapon text, age integer, price integer, rating numeric (2,1), kills integer);
INSERT INTO assassins (full_name, weapon, age, price, rating, kills)
VALUES
('Alexander Duggan','Sniper Rifle', 31, 45, 7.5, 28),
('Anton Chigurh', 'Pneumatic bolt gun', 52, 40, 9, 72),
(null, 'Pistol', 28, 20, 6.5, 35),
('Jason Bourne', 'Parkour', 27, 25, 7, 48),
('John Wick', 'Lots of guns', 35, 50, 9.5, 433),
('Jules Winnfield', 'Pistol', 26, 15, 6.5, 13),
('Leon', 'Everything', 41, 30, 8.5, 87),
('Nikita Mears', 'Silenced pistols', 28, 30, 7, 32),
('Pickle Rick', 'Lasers and office supplies', 60, 0, 8, 24);
CREATE TABLE code_names (assassins_id integer references assassins (id), code_names text);
INSERT INTO code_names (assassins_id, code_names)
VALUES
(1, 'The Jackal'),
(2, 'Old Man'),
(3, 'Ghost Dog'),
(5, 'Baba Yaga'),
(7, 'The Professional'),
(8, 'Nikita'),
(8, 'La Femme Nikita'),
(9, 'Solenya');
CREATE TABLE clients (id serial primary key, client_name text);
INSERT INTO clients (client_name)
VALUES
('Marcellus Wallace'),
('Concerto'),
('Mathilda'),
('Winston'),
('Ray Vargo');
CREATE TABLE targets (id serial primary key, target_name text, target_location text, target_photo text, target_security integer);
INSERT INTO targets (target_name, target_location, target_photo, target_security)
VALUES
('Butch Coolidge', 'Los Angeles', 'https://goo.gl/LCquZj', 3),
('The Jaguar', 'Russian Embassy', 'https://goo.gl/6JWsiv', 9),
('Norman Stansfield', 'Manhattan', 'https://i.imgur.com/mdIk33E.jpg', 7),
('Santino D''Antonio', 'Continental Hotel', 'https://goo.gl/fUPkYy', 10),
('Sonny Valerio', 'Queens', 'https://goo.gl/8DHYUS', 4);
CREATE TABLE contracts (id serial primary key, client_id integer references clients (id), budget integer, target_id integer references targets (id), completed boolean, assassins_id integer references assassins (id));
INSERT INTO contracts (client_id, budget, target_id, completed, assassins_id)
VALUES
(1, 40, 1, false, null),
(2, 70, 2, false, null),
(3, 35, 3, false, null),
(4, 25, 4, false, null),
(5, 10, 5, false, null);
CREATE TABLE assassins_contracts (assassins_id integer references assassins (id), contract_id integer references contracts (id));
INSERT INTO assassins_contracts (assassins_id, contract_id)
VALUES
(6, 1),
(1, 2),
(5, 2),
(7, 3),
(9, 5),
(6, 4),
(8, 3),
(3, 1);
SELECT * FROM assassins;
SELECT * FROM code_names;
SELECT * FROM clients;
SELECT * FROM contracts;
SELECT * FROM targets;
SELECT * FROM assassins_contracts;
SELECT * FROM assassins ORDER BY kills DESC;
SELECT * FROM assassins WHERE age>30;
SELECT * FROM contracts WHERE budget>=30;
SELECT * FROM assassins WHERE rating>=7;
SELECT SUM(price) FROM assassins;
SELECT COUNT(*) FROM assassins_contracts;
INSERT INTO targets (target_name, target_location, target_photo, target_security)
VALUES
('Snake Plissken', 'New York', 'https://imgur.com/gallery/kEuzp', 5);
| true |
05425e041733ea39ca1dd22010cffd3a343a08e1 | SQL | Devipurwita24/belajar-bootstrap | /belajarbootstrap.sql | UTF-8 | 2,451 | 2.84375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 21 Mar 2020 pada 07.05
-- Versi server: 10.4.6-MariaDB
-- Versi PHP: 7.3.9
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: `belajarbootstrap`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `data_penduduk`
--
CREATE TABLE `data_penduduk` (
`nik` int(20) NOT NULL,
`nama` varchar(50) NOT NULL,
`daerah` varchar(50) NOT NULL,
`asal_daerah` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `data_penduduk`
--
INSERT INTO `data_penduduk` (`nik`, `nama`, `daerah`, `asal_daerah`) VALUES
(99, 'devi', 'malang', 'sidoarjo'),
(9899, 'devi', 'malang', 'sidoarjo'),
(9975, 'devi', 'malang', 'sidoarjo'),
(11111, 'devi', 'malang', 'sidoarjo'),
(12345, 'jdbfhd', 'malang', 'sidoarjo'),
(99758, 'hmm', 'malang', 'sidoarjo'),
(11111111, 'fff', 'malang', 'sidoarjo'),
(56555656, 'jdbfhd', 'malang', 'sidoarjo');
-- --------------------------------------------------------
--
-- Struktur dari tabel `login`
--
CREATE TABLE `login` (
`username` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `login`
--
INSERT INTO `login` (`username`, `password`) VALUES
('devi', 'devi');
-- --------------------------------------------------------
--
-- Struktur dari tabel `peternakanpertanian`
--
CREATE TABLE `peternakanpertanian` (
`daerah` varchar(50) NOT NULL,
`perkebunan` int(50) NOT NULL,
`pertanian` int(50) NOT NULL,
`peternakan` int(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indeks untuk tabel `data_penduduk`
--
ALTER TABLE `data_penduduk`
ADD PRIMARY KEY (`nik`);
--
-- Indeks untuk tabel `peternakanpertanian`
--
ALTER TABLE `peternakanpertanian`
ADD PRIMARY KEY (`pertanian`);
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 |
669271421667a06a644d25ad17022e319170b5aa | SQL | zhaoy1992/xtbg-whtjy-new | /db/公文管理/更新记录/word模板管理表.sql | UTF-8 | 5,758 | 3.8125 | 4 | [] | no_license | -- Add/modify columns
alter table OA_FLOW_BASEINFO add flow_tyle CHAR(1) default '1';
alter table OA_FLOW_BASEINFO add TEMPLATE_ID VARCHAR2(50);
-- Add comments to the columns
comment on column OA_FLOW_BASEINFO.flow_tyle
is '流程类型(1:表单 ,2: word)';
comment on column OA_FLOW_BASEINFO.TEMPLATE_ID
is 'word模板ID';
ALTER TABLE OA_WORD_TEXTINPUT
DROP CONSTRAINT FK_OA_WORD__REFERENCE_OA_WORD_;
DROP TABLE OA_WORD_TEMPLATE CASCADE CONSTRAINTS;
/*==============================================================*/
/* Table: OA_WORD_TEMPLATE */
/*==============================================================*/
CREATE TABLE OA_WORD_TEMPLATE
(
TEMPLATE_ID VARCHAR2(50) NOT NULL,
TEMPLATE_NAME VARCHAR2(500) NOT NULL,
TEMPLATE_CREATORTIME DATE DEFAULT SYSDATE NOT NULL,
TEMPLATE_USERID VARCHAR2(50),
TEMPLATE_USERNAME VARCHAR2(50),
ORG_ID VARCHAR2(100),
ORG_NAME VARCHAR2(100),
TEMPLATE_REMARK VARCHAR2(500),
IS_COMMON VARCHAR2(2) DEFAULT 'Y' NOT NULL,
LASTMODIFYTIME DATE NOT NULL,
TEMPLATE_SN NUMBER,
CONSTRAINT PK_OA_WORD_TEMPLATE PRIMARY KEY (TEMPLATE_ID)
);
COMMENT ON TABLE OA_WORD_TEMPLATE IS
'word模板表';
COMMENT ON COLUMN OA_WORD_TEMPLATE.TEMPLATE_ID IS
'模板主键';
COMMENT ON COLUMN OA_WORD_TEMPLATE.TEMPLATE_NAME IS
'模板名称';
COMMENT ON COLUMN OA_WORD_TEMPLATE.TEMPLATE_CREATORTIME IS
'创建时间';
COMMENT ON COLUMN OA_WORD_TEMPLATE.TEMPLATE_USERID IS
'创建者主键';
COMMENT ON COLUMN OA_WORD_TEMPLATE.TEMPLATE_USERNAME IS
'创建者';
COMMENT ON COLUMN OA_WORD_TEMPLATE.ORG_ID IS
'机构id';
COMMENT ON COLUMN OA_WORD_TEMPLATE.ORG_NAME IS
'机构名称';
COMMENT ON COLUMN OA_WORD_TEMPLATE.TEMPLATE_REMARK IS
'模版说明';
COMMENT ON COLUMN OA_WORD_TEMPLATE.IS_COMMON IS
'是否通用模板';
COMMENT ON COLUMN OA_WORD_TEMPLATE.LASTMODIFYTIME IS
'最后修改时间';
COMMENT ON COLUMN OA_WORD_TEMPLATE.TEMPLATE_SN IS
'序号';
ALTER TABLE OA_WORD_TEXTINPUT
DROP CONSTRAINT FK_OA_WORD__REFERENCE_OA_WORD_;
DROP TABLE OA_WORD_TEXTINPUT CASCADE CONSTRAINTS;
/*==============================================================*/
/* Table: OA_WORD_TEXTINPUT */
/*==============================================================*/
CREATE TABLE OA_WORD_TEXTINPUT
(
TEXTINPUT_ID VARCHAR2(50) NOT NULL,
TEMPLATE_ID VARCHAR2(50),
TEXTINPUT_NAME VARCHAR2(255) NOT NULL,
TABLE_ID VARCHAR2(40),
COLUMN_ID VARCHAR2(40),
TEXTINPUT_VALUE_TYPE VARCHAR2(2) NOT NULL,
TEXTINPUT_VALUE VARCHAR2(255),
TEXTINPUT_HELP VARCHAR2(500),
TEXTINPUT_FLAG VARCHAR2(500),
TEXTINPUT_REMARK VARCHAR2(500),
CONSTRAINT PK_TA_OA_WORD_TEXTINPUT1 PRIMARY KEY (TEXTINPUT_ID)
);
COMMENT ON TABLE OA_WORD_TEXTINPUT IS
'word中输入文本数据表';
COMMENT ON COLUMN OA_WORD_TEXTINPUT.TEXTINPUT_ID IS
'输入文本ID';
COMMENT ON COLUMN OA_WORD_TEXTINPUT.TEMPLATE_ID IS
'模板主键';
COMMENT ON COLUMN OA_WORD_TEXTINPUT.TEXTINPUT_NAME IS
'名称';
COMMENT ON COLUMN OA_WORD_TEXTINPUT.TABLE_ID IS
'对应表名';
COMMENT ON COLUMN OA_WORD_TEXTINPUT.COLUMN_ID IS
'对应字段名';
COMMENT ON COLUMN OA_WORD_TEXTINPUT.TEXTINPUT_VALUE_TYPE IS
'1,变量 ';
COMMENT ON COLUMN OA_WORD_TEXTINPUT.TEXTINPUT_VALUE IS
'默认值';
COMMENT ON COLUMN OA_WORD_TEXTINPUT.TEXTINPUT_HELP IS
'帮助';
COMMENT ON COLUMN OA_WORD_TEXTINPUT.TEXTINPUT_FLAG IS
'状态';
COMMENT ON COLUMN OA_WORD_TEXTINPUT.TEXTINPUT_REMARK IS
'备注';
ALTER TABLE OA_WORD_TEXTINPUT
ADD CONSTRAINT FK_OA_WORD__REFERENCE_OA_WORD_ FOREIGN KEY (TEMPLATE_ID)
REFERENCES OA_WORD_TEMPLATE (TEMPLATE_ID);
DROP TABLE OA_OCTL_TEMPLATE_FILE CASCADE CONSTRAINTS;
/*==============================================================*/
/* Table: OA_OCTL_TEMPLATE_FILE */
/*==============================================================*/
CREATE TABLE OA_OCTL_TEMPLATE_FILE
(
TEMPLATEID VARCHAR2(50) NOT NULL,
RECORDID VARCHAR2(50) NOT NULL,
FILENAME VARCHAR2(254),
FILETYPE VARCHAR2(50),
FILESIZE NUMBER(10),
FILEDATE DATE,
FILEBODY BLOB,
FILEPATH VARCHAR2(255),
USERNAME VARCHAR2(64),
DESCRIPT VARCHAR2(255),
ORG_ID VARCHAR2(50),
RECORD_SN NUMBER(10)
);
COMMENT ON TABLE OA_OCTL_TEMPLATE_FILE IS
'通用模板表';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.TEMPLATEID IS
'自动编号';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.RECORDID IS
'模板编号';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.FILENAME IS
'模板名称';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.FILETYPE IS
'模板类型';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.FILESIZE IS
'模板大小';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.FILEDATE IS
'模板日期';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.FILEBODY IS
'模板内容';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.FILEPATH IS
'模板所在路径';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.USERNAME IS
'用户名称';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.DESCRIPT IS
'模板描述';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.ORG_ID IS
'该模板所属的机构id';
COMMENT ON COLUMN OA_OCTL_TEMPLATE_FILE.RECORD_SN IS
'模板排序号';
| true |
df6d9fe64180f3070c2d9fde73942e4590508b92 | SQL | sbmorvant/EPBI414 | /EPBI414/Week 6/sql_Examples.sql | UTF-8 | 2,545 | 4.40625 | 4 | [] | no_license | -- +--------------------------------+
-- | |
-- | EPBI414 Unit 6 SQL Examples |
-- | sql_EPBI414_Unit6_Examples.sql |
-- | |
-- | Author: Thomas A. Rehman |
-- | tar9@case.edu |
-- | |
-- +--------------------------------+
-- Basic SELECT Example
SELECT dept_name FROM epbi414_employee_data.departments;
-- USE and LIMIT Examples
USE epbi414_employee_data;
SELECT first_name,last_name FROM employees LIMIT 10;
-- Using WHERE and ORDER BY
-- Note how this will work, but the next will not
SELECT *
FROM employees
WHERE gender = 'F'
ORDER BY birth_date
LIMIT 10;
SELECT *
FROM employees
ORDER BY birth_date
WHERE gender = 'F'
LIMIT 10;
-- Here is an example of using DESC
SELECT *
FROM employees
ORDER BY hire_date DESC
LIMIT 10;
-- More Complicated Logics
-- Here is a query which selects all the employees who were either
-- a) born between 1950 and 1953 and have employee numbers
-- less than 10050 or greater than 11000, or
-- b) Have a name that starts with Chir
SELECT *
FROM employees
WHERE (birth_date BETWEEN '1950-01-01'
AND '1953-12-31'
AND (emp_no < 10050 OR emp_no > 11000))
OR first_name LIKE 'Chir%';
-- Here is a query that finds all the current Engineers and Senior Engineers
SELECT *
FROM titles
WHERE title IN ('Engineer','Senior Engineer')
AND to_date = '9999-01-01';
-- Wildcards
-- Here are some query examples illustrating wildcards
-- First, using the % sign
SELECT first_name,
last_name
FROM employees
WHERE first_name LIKE 'Geoff%y'
LIMIT 3;
-- Now, using the _
SELECT first_name,
last_name
FROM employees
WHERE last_name like "___sen"
LIMIT 3;
-- Simple Inner Join
-- See how we create a subquery that filters the salaries to
-- only include those with the to_date being 9999-01-01?
-- This prevents us from getting the salaries of past or discharged employees
SELECT e.emp_no,
e.first_name,
e.last_name,
e.hire_date,
e.gender,
s.salary
FROM employees AS e
INNER JOIN
(
SELECT emp_no,
salary
FROM salaries
WHERE to_date = '9999-01-01'
) AS s
ON e.emp_no = s.emp_no
LIMIT 10; | true |
63577cf233a162661a99450a14836293cdab02a6 | SQL | labradorsabrina/SQL | /Pets/PetrescueQueries.sql | UTF-8 | 1,980 | 4.6875 | 5 | [] | no_license | --function that calculates the total cost of all animal rescues in the PETRESCUE table
SELECT SUM(cost)
FROM PETRESCUE;
--function that displays the total cost of all animal rescues in the PETRESCUE table in a column called SUM_OF_COST
SELECT SUM(cost) as SUM_OF_COST
FROM PETRESCUE;
--function that displays the maximum quantity of animals rescued
SELECT MAX(quantity)
FROM PETRESCUE;
--function that displays the average cost of animals rescued
SELECT animal, AVG(cost) as AVG_COST
FROM PETRESCUE
GROUP BY animal;
--function that displays the average cost of rescuing a dog
SELECT animal, AVG(cost) as AVG_COST
FROM PETRESCUE
GROUP BY animal
HAVING animal = 'Dog';
--function that displays the rounded cost of each rescue.
SELECT ROUND(cost)
FROM PETRESCUE;
--function that displays the animal name in each rescue in uppercase.
SELECT UPPER(animal)
FROM PETRESCUE;
--function that displays the animal name in each rescue in uppercase without duplications.
SELECT DISTINCT UPPER(animal)
FROM PETRESCUE;
--query that displays all the columns from the PETRESCUE table, where the animal(s) rescued are cats. Use cat in lower case in the query
SELECT *
FROM PETRESCUE
WHERE animal = 'Cat';
--function that displays the day of the month when cats have been rescued
SELECT animal, DAY(RESCUEDATE) as Day_Rescue
FROM PETRESCUE;
--function that displays the number of rescues on the 5th month
SELECT SUM(QUANTITY)
FROM PETRESCUE
WHERE MONTH(RESCUEDATE) = 5;
--function that displays the number of rescues on the 14th day of the month.
SELECT SUM(QUANTITY)
FROM PETRESCUE
WHERE DAY(RESCUEDATE) = 14;
--Animals rescued should see the vet within three days of arrivals. Enter a function that displays the third day from each rescue.
SELECT (RESCUEDATE + 3 DAYS)
FROM PETRESCUE;
--function that displays the length of time the animals have been rescued; the difference between today’s date and the recue date.
SELECT CURRENT_DATE - RESCUEDATE
FROM PETRESCUE; | true |
ce1ebc765bd5bdc7b1d47c99e1b8f1ca79f30876 | SQL | Mighty-Mesquite/Reviews_Api | /schemas/schema.sql | UTF-8 | 1,477 | 3.8125 | 4 | [] | no_license | DROP DATABASE IF EXISTS reviewsapi;
CREATE DATABASE reviewsapi;
USE reviewsapi;
CREATE TABLE reviewer (
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
reviewer_name varchar(50) NOT NULL
);
CREATE TABLE products (
product_id INT NOT NULL PRIMARY KEY
);
CREATE TABLE reviews (
review_id int NOT NULL PRIMARY KEY,
product_id int NOT NULL,
rating int NOT NULL,
date DATE NOT NULL,
summary varchar(255),
body varchar(255) NOT NULL,
recommend boolean DEFAULT 0,
reported boolean DEFAULT 0,
reviewer_id INT NOT NULL,
reviewer_email varchar(100) NOT NULL,
response varchar(255),
helpfulness INT DEFAULT 0,
FOREIGN KEY (reviewer_id) REFERENCES reviewer(id),
FOREIGN KEY (product_id) REFERENCES products(product_id)
);
CREATE TABLE photos (
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
fromReview int not null,
url varchar(255),
FOREIGN KEY (fromReview) REFERENCES reviews(review_id)
);
CREATE TABLE characteristics_products (
characteristic_id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
product_id INT NOT NULL,
characteristic_name varchar(50) NOT NULL,
FOREIGN KEY (product_id) REFERENCES products(product_id)
);
CREATE TABLE characteristics_and_reviews (
id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
characteristic_id INT NOT NULL,
review_id INT NOT NULL,
score INT NOT NULL,
FOREIGN KEY (review_id) REFERENCES reviews(review_id),
FOREIGN KEY (characteristic_id) REFERENCES characteristics_products(characteristic_id)
); | true |
853d4bae3da76f439c18970dca97887cb1adbd46 | SQL | gmicheva/SoftUni | /MsSQL/04.Built-in-Functions-Exercises/07.Find-Towns-Not-Starting-With.sql | UTF-8 | 127 | 3.390625 | 3 | [] | no_license | --Problem 7. Find Towns Not Starting With
SELECT * FROM Towns
WHERE LEFT(Name, 1) NOT IN ('R', 'B', 'D')
ORDER BY Name ASC | true |
480349e058a1d22cd2b30e6ad150457f9fe6429f | SQL | Alxbry28/AhrisPH | /ahrisph.sql | UTF-8 | 13,790 | 3 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Oct 07, 2020 at 07:13 PM
-- Server version: 10.4.14-MariaDB
-- PHP Version: 7.4.10
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: `ahrisph`
--
-- --------------------------------------------------------
--
-- Table structure for table `failed_jobs`
--
CREATE TABLE `failed_jobs` (
`id` bigint(20) UNSIGNED NOT NULL,
`uuid` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
`queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
`payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `migrations`
--
CREATE TABLE `migrations` (
`id` int(10) UNSIGNED NOT NULL,
`migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `migrations`
--
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2014_10_12_000000_create_users_table', 1),
(2, '2014_10_12_100000_create_password_resets_table', 1),
(3, '2019_08_19_000000_create_failed_jobs_table', 1),
(4, '2020_10_07_090210_laratrust_setup_tables', 2),
(5, '2020_10_07_121853_add_info_to_users', 3),
(6, '2020_10_07_141114_add_jobtitle_to_users', 4);
-- --------------------------------------------------------
--
-- Table structure for table `password_resets`
--
CREATE TABLE `password_resets` (
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `password_resets`
--
INSERT INTO `password_resets` (`email`, `token`, `created_at`) VALUES
('alexbryanarellano2@gmail.com', '$2y$10$Ba05egPiGTtwFEfYddPnZ.mHCfKd6AWdOA292yssDHJ9V5pieOt/S', '2020-10-07 05:11:56');
-- --------------------------------------------------------
--
-- Table structure for table `permissions`
--
CREATE TABLE `permissions` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`display_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `permissions`
--
INSERT INTO `permissions` (`id`, `name`, `display_name`, `description`, `created_at`, `updated_at`) VALUES
(1, 'create-users', 'Create Users', 'Create Users', '2020-10-07 01:08:37', '2020-10-07 01:08:37'),
(2, 'read-users', 'Read Users', 'Read Users', '2020-10-07 01:08:37', '2020-10-07 01:08:37'),
(3, 'update-users', 'Update Users', 'Update Users', '2020-10-07 01:08:37', '2020-10-07 01:08:37'),
(4, 'delete-users', 'Delete Users', 'Delete Users', '2020-10-07 01:08:38', '2020-10-07 01:08:38'),
(5, 'create-acl', 'Create Acl', 'Create Acl', '2020-10-07 01:08:38', '2020-10-07 01:08:38'),
(6, 'read-acl', 'Read Acl', 'Read Acl', '2020-10-07 01:08:38', '2020-10-07 01:08:38'),
(7, 'update-acl', 'Update Acl', 'Update Acl', '2020-10-07 01:08:38', '2020-10-07 01:08:38'),
(8, 'delete-acl', 'Delete Acl', 'Delete Acl', '2020-10-07 01:08:38', '2020-10-07 01:08:38'),
(9, 'read-profile', 'Read Profile', 'Read Profile', '2020-10-07 01:08:38', '2020-10-07 01:08:38'),
(10, 'update-profile', 'Update Profile', 'Update Profile', '2020-10-07 01:08:38', '2020-10-07 01:08:38'),
(11, 'create-profile', 'Create Profile', 'Create Profile', '2020-10-07 01:08:40', '2020-10-07 01:08:40');
-- --------------------------------------------------------
--
-- Table structure for table `permission_role`
--
CREATE TABLE `permission_role` (
`permission_id` int(10) UNSIGNED NOT NULL,
`role_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `permission_role`
--
INSERT INTO `permission_role` (`permission_id`, `role_id`) VALUES
(1, 1),
(1, 2),
(2, 1),
(2, 2),
(3, 1),
(3, 2),
(4, 1),
(4, 2),
(5, 1),
(6, 1),
(7, 1),
(8, 1),
(9, 1),
(9, 2),
(9, 3),
(10, 1),
(10, 2),
(10, 3);
-- --------------------------------------------------------
--
-- Table structure for table `permission_user`
--
CREATE TABLE `permission_user` (
`permission_id` int(10) UNSIGNED NOT NULL,
`user_id` int(10) UNSIGNED NOT NULL,
`user_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `permission_user`
--
INSERT INTO `permission_user` (`permission_id`, `user_id`, `user_type`) VALUES
(9, 4, 'App\\User'),
(10, 4, 'App\\User'),
(11, 4, 'App\\User');
-- --------------------------------------------------------
--
-- Table structure for table `roles`
--
CREATE TABLE `roles` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`display_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `roles`
--
INSERT INTO `roles` (`id`, `name`, `display_name`, `description`, `created_at`, `updated_at`) VALUES
(1, 'superadministrator', 'Superadministrator', 'Superadministrator', '2020-10-07 01:08:37', '2020-10-07 01:08:37'),
(2, 'administrator', 'Administrator', 'Administrator', '2020-10-07 01:08:38', '2020-10-07 01:08:38'),
(3, 'user', 'User', 'User', '2020-10-07 01:08:39', '2020-10-07 01:08:39');
-- --------------------------------------------------------
--
-- Table structure for table `role_user`
--
CREATE TABLE `role_user` (
`role_id` int(10) UNSIGNED NOT NULL,
`user_id` int(10) UNSIGNED NOT NULL,
`user_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `role_user`
--
INSERT INTO `role_user` (`role_id`, `user_id`, `user_type`) VALUES
(1, 1, 'App\\User'),
(2, 2, 'App\\User'),
(3, 3, 'App\\User'),
(3, 7, 'App\\User'),
(3, 8, 'App\\User'),
(3, 9, 'App\\User');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` bigint(20) UNSIGNED NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`firstname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`lastname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`phonenumber` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`birthday` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`username` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`facebook` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`linkedin` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`twitter` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`city` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`province` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`zip_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_me` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`job_title` text COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`, `firstname`, `lastname`, `phonenumber`, `birthday`, `username`, `facebook`, `linkedin`, `twitter`, `address`, `city`, `province`, `zip_code`, `about_me`, `job_title`) VALUES
(1, 'superadministrator@app.com', NULL, '$2y$10$Zed8hfaLbLzzAiLa73L3B.DOr8VXzdfS0qE1HsqNUJFfzQE5SECf.', NULL, '2020-10-07 01:08:38', '2020-10-07 01:08:38', 'super', 'admin', '09123456789', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(2, 'administrator@app.com', NULL, '$2y$10$0hldZEROXs45FV7flXfZs.w7QmQnrCVWiX063yyjmHX40zsGlrJF6', NULL, '2020-10-07 01:08:39', '2020-10-07 01:08:39', 'basic', 'admin', '09123456789', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(3, 'user@app.com', NULL, '$2y$10$Umw5hRGNV1sE2DCVr9ZBEOprRDwKjaYtXeQcI3HDRQdyJekXOCVQ.', NULL, '2020-10-07 01:08:40', '2020-10-07 01:08:40', 'basic', 'user', '09123456789', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(4, 'cru_user@app.com', NULL, '$2y$10$Kg5hdsSK0tvYN4CwxpLXwuhMe.6AyFDSaSqHY92Yata0y0j6F214i', 'i5Nuiqq6Av', '2020-10-07 01:08:40', '2020-10-07 01:08:40', 'basic', 'cru_user', '09123456789', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(7, 'alexbryanarellano2@gmail.com', '2020-10-07 02:40:38', '$2y$10$hV3ZqpfIB7VnKuVipt1gIurv06v6nL2ZD9Oe0DX1Inv5tPC7Uf4jO', 'xoUCq749wcLfogzkJbw8gTylfNqx1fwOSYIoNA5kgXgqkCoCrf2zEuFPjO59', '2020-10-07 02:36:18', '2020-10-07 03:05:45', 'Alex', 'Arellano', '09123456789', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(8, 'alexbryanarellano2898@gmail.com', '2020-10-07 06:03:05', '$2y$10$12eDT/WtWelYfn1sEvJdiubJj61XD19DiJzM3r7eby81v9wCGDghy', 'hBmyDNOQHNFh5otYjkG4BjyjebwYv3YvK4UaAr1YQ0UTh5iAaDzYnKo7UqRL', '2020-10-07 05:25:25', '2020-10-07 06:53:12', 'admin', 'nerves', '09474576403', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(9, 'seregoj478@zuperholo.com', '2020-10-07 08:54:43', '$2y$10$weZY//AKcSJbyv8P8s2pM.l6JD/QSokD7B3ic56nSd1DafObZ2t5a', 'wLYhVk6PyYPIThqFtSg8EvMkN2kdWI1HkOljpMkw8ChgvD6qs4lKusc0faxx', '2020-10-07 08:54:05', '2020-10-07 09:10:20', 'juan', 'dela cruz', '09234343223', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);
--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`);
--
-- Indexes for table `permissions`
--
ALTER TABLE `permissions`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `permissions_name_unique` (`name`);
--
-- Indexes for table `permission_role`
--
ALTER TABLE `permission_role`
ADD PRIMARY KEY (`permission_id`,`role_id`),
ADD KEY `permission_role_role_id_foreign` (`role_id`);
--
-- Indexes for table `permission_user`
--
ALTER TABLE `permission_user`
ADD PRIMARY KEY (`user_id`,`permission_id`,`user_type`),
ADD KEY `permission_user_permission_id_foreign` (`permission_id`);
--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `roles_name_unique` (`name`);
--
-- Indexes for table `role_user`
--
ALTER TABLE `role_user`
ADD PRIMARY KEY (`user_id`,`role_id`,`user_type`),
ADD KEY `role_user_role_id_foreign` (`role_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `permissions`
--
ALTER TABLE `permissions`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `permission_role`
--
ALTER TABLE `permission_role`
ADD CONSTRAINT `permission_role_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `permission_role_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `permission_user`
--
ALTER TABLE `permission_user`
ADD CONSTRAINT `permission_user_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `role_user`
--
ALTER TABLE `role_user`
ADD CONSTRAINT `role_user_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
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 |
50d9d5b5dafa387ca724834f9c6f766096669e5a | SQL | tim0dd/PassTheBomb-Backend | /src/main/resources/data.sql | UTF-8 | 6,248 | 2.578125 | 3 | [] | no_license | insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('cc4cd298-a49e-4043-bea0-eaa5ec3a5a1f', '2020-12-15 16:23:17.661000', 'Make loud monkey noises!', 60);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('79c74f97-d902-4d68-86b6-4df02a38e067', '2020-12-15 16:24:31.834000',
'Name an animal whose name starts with "I"!', 30);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('6a174aaa-28e4-4d35-a2d4-262116434a23', '2020-12-15 16:25:57.628000', 'Bark like a dog!', 30);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('9787a6ff-a6ac-4648-8aad-377d17246e40', '2020-12-15 16:26:26.127000', 'Name four types of bears!', 60);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('9925047d-7e07-4dc2-b2ec-7dde09919f14', '2020-12-15 16:31:46.462000', 'Imitate a bunny!', 30);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('a55d6926-e894-4f1e-8478-691995fc55af', '2020-12-15 16:32:36.972000', 'Imitate a tiger!', 30);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('02d4fea2-18a3-46df-9c76-ada34b5b3edc', '2020-12-15 16:33:20.438000',
'Name the largest animal you know! If other players know a larger one, you lose.', 60);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('a32c5160-c121-465c-9609-7a8fdba40719', '2020-12-15 16:34:37.669000', 'Name 3 Animals starting with "T"!', 60);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('5b8604ea-4dd5-4a08-933b-a64002cd5a86', '2020-12-15 16:34:56.343000', 'Name 3 animals starting with "K"!', 60);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('54a51558-e7ed-4055-9bda-d148f0536bee', '2020-12-15 16:39:56.778000', 'What is 34+545+18+23-43?', 25);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('3917e214-c021-40b0-ad46-032c27746444', '2020-12-15 16:40:28.591000', 'What is the square root of 441?', 60);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('1ff996cc-414c-4eb2-a3c8-0eca3d2d9c94', '2020-12-15 16:42:08.722000', 'What is 150 ÷ (6 + 3 x 8) - 5 ?', 60);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('ff286e38-b551-4f31-912b-330f5b5299bd', '2020-12-15 16:43:24.267000',
'What is the first prime number after 23?', 45);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('6d8cb4e9-5386-44bf-986e-a3beaabf8506', '2020-12-15 16:44:09.789000', 'How many surfaces are there on a cube?',
30);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('5e7939bc-c5e7-4963-b0cc-3dc6f4a3b0f1', '2020-12-15 16:46:08.498000', 'What is 4.16 × 0.75?', 100);
insert into PUBLIC.CHALLENGE (ID, CREATED_DATE, TEXT, TIME_LIMIT)
values ('f5107d1c-6ffb-41ce-a4f1-ce95b32bdbba', '2020-12-15 16:46:48.039000',
'What percentage should be added to 40 to make it 46?', 35);
insert into PUBLIC.CHALLENGE_SET (ID, CREATED_DATE, CREATOR_ID, DOWNLOADS, MODIFIED_DATE, NAME, UPLOADED_DATE)
values ('322bc80a-15dd-4a82-bbd6-90fa9d6fef80', '2020-12-15 16:23:14.873000', 'INITIAL', 0,
'2020-12-15 16:23:14.873000', 'Animals', '2020-12-15 17:18:44.473000');
insert into PUBLIC.CHALLENGE_SET (ID, CREATED_DATE, CREATOR_ID, DOWNLOADS, MODIFIED_DATE, NAME, UPLOADED_DATE)
values ('a1355f79-ca24-4b85-92a6-bad0be18d88a', '2020-12-15 16:39:54.522000', 'INITIAL', 0,
'2020-12-15 16:39:54.522000', 'Math', '2020-12-15 17:18:57.325000');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('322bc80a-15dd-4a82-bbd6-90fa9d6fef80', 'cc4cd298-a49e-4043-bea0-eaa5ec3a5a1f');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('322bc80a-15dd-4a82-bbd6-90fa9d6fef80', '79c74f97-d902-4d68-86b6-4df02a38e067');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('322bc80a-15dd-4a82-bbd6-90fa9d6fef80', '6a174aaa-28e4-4d35-a2d4-262116434a23');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('322bc80a-15dd-4a82-bbd6-90fa9d6fef80', '9787a6ff-a6ac-4648-8aad-377d17246e40');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('322bc80a-15dd-4a82-bbd6-90fa9d6fef80', '9925047d-7e07-4dc2-b2ec-7dde09919f14');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('322bc80a-15dd-4a82-bbd6-90fa9d6fef80', 'a55d6926-e894-4f1e-8478-691995fc55af');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('322bc80a-15dd-4a82-bbd6-90fa9d6fef80', '02d4fea2-18a3-46df-9c76-ada34b5b3edc');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('322bc80a-15dd-4a82-bbd6-90fa9d6fef80', 'a32c5160-c121-465c-9609-7a8fdba40719');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('322bc80a-15dd-4a82-bbd6-90fa9d6fef80', '5b8604ea-4dd5-4a08-933b-a64002cd5a86');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('a1355f79-ca24-4b85-92a6-bad0be18d88a', '54a51558-e7ed-4055-9bda-d148f0536bee');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('a1355f79-ca24-4b85-92a6-bad0be18d88a', '3917e214-c021-40b0-ad46-032c27746444');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('a1355f79-ca24-4b85-92a6-bad0be18d88a', '1ff996cc-414c-4eb2-a3c8-0eca3d2d9c94');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('a1355f79-ca24-4b85-92a6-bad0be18d88a', 'ff286e38-b551-4f31-912b-330f5b5299bd');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('a1355f79-ca24-4b85-92a6-bad0be18d88a', '6d8cb4e9-5386-44bf-986e-a3beaabf8506');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('a1355f79-ca24-4b85-92a6-bad0be18d88a', '5e7939bc-c5e7-4963-b0cc-3dc6f4a3b0f1');
insert into PUBLIC.CHALLENGE_SET_CHALLENGES (CHALLENGE_SET_ID, CHALLENGES_ID)
values ('a1355f79-ca24-4b85-92a6-bad0be18d88a', 'f5107d1c-6ffb-41ce-a4f1-ce95b32bdbba');
| true |
adb8c9a57dbbf8f0533327fed018f27f213f58ab | SQL | SOLA-TONGA/database_tonga | /extension/business_rules.sql | UTF-8 | 5,993 | 3.71875 | 4 | [] | no_license | -- Survey Fee Calculation Business Rules
INSERT INTO system.br (id, display_name, technical_type_code, feedback, description, technical_description)
SELECT 'calculate-survey-fee', 'Calculate Survey Fee', 'sql', null,
'Calculates the fee appliciable for the survey service based on the area of the parcel(s) to be surveyed',
'#{area} Area to calculate fee is required'
WHERE NOT EXISTS (SELECT id FROM system.br WHERE id = 'calculate-survey-fee');
-- Create business rule used to calculate the survey fee based on the area to be surveyed. See Schedule IV
-- document for the survey fee details.
INSERT INTO system.br_definition (br_id, active_from, active_until, body)
SELECT 'calculate-survey-fee', now(), 'infinity',
'SELECT CASE
WHEN #{area} IS NULL OR #{area} <= 0 THEN 0
WHEN #{area} BETWEEN 0 AND 2000 THEN 40
WHEN #{area} BETWEEN 2000 AND 13000 THEN 60
WHEN #{area} BETWEEN 13000 AND 35000 THEN 70
WHEN #{area} BETWEEN 35000 AND 60000 THEN 180
WHEN #{area} BETWEEN 60000 AND 80000 THEN 200
WHEN #{area} BETWEEN 80000 AND 400000 THEN 200 + (TRUNC((#{area} - 80000)/10000) * 7.60)
WHEN #{area} BETWEEN 400000 AND 800000 THEN 443.20 + (TRUNC((#{area} - 400000)/10000) * 5.60)
WHEN #{area} BETWEEN 800000 AND 2000000 THEN 667.20 + (TRUNC((#{area} - 800000)/10000) * 4.70)
WHEN #{area} BETWEEN 2000000 AND 4000000 THEN 1231.20 + (TRUNC((#{area} - 2000000)/10000) * 3.70)
ELSE 1971.20 + (TRUNC((#{area} - 4000000)/10000) * 1.90) END AS vl'
WHERE NOT EXISTS (SELECT br_id FROM system.br_definition WHERE br_id = 'calculate-survey-fee');
-- Number generation Sequences and business rules
-- *** Application Number
DROP SEQUENCE IF EXISTS application.application_nr_seq;
CREATE SEQUENCE application.application_nr_seq
INCREMENT 1
MINVALUE 10000
MAXVALUE 99999
START 10000
CACHE 3
CYCLE;
COMMENT ON SEQUENCE application.application_nr_seq
IS 'Allocates a 5 digit sequence number for application numbers';
UPDATE system.br_definition SET "body" =
'SELECT trim(to_char(nextval(''application.application_nr_seq''), ''00000'')) AS vl'
WHERE br_id = 'generate-application-nr';
-- *** Source Numbering
-- Reconfigure Source numbering so that it is based on the application number
DROP SEQUENCE IF EXISTS source.source_la_nr_seq;
CREATE SEQUENCE source.source_la_nr_seq
INCREMENT 1
MINVALUE 100000
MAXVALUE 999999
START 100000
CACHE 1;
UPDATE system.br_definition SET "body" = '
WITH app AS (
SELECT a.id AS app_id
FROM application.application a
WHERE CAST(#{refId} AS VARCHAR(40)) IS NOT NULL
AND a.id = #{refId}
UNION
SELECT ser.application_id AS app_id
FROM application.service ser,
transaction.transaction t
WHERE CAST(#{transactionId} AS VARCHAR(40)) IS NOT NULL
AND t.id = #{transactionId}
AND ser.id = t.from_service_id),
sources AS (
SELECT aus.source_id AS source_id
FROM application.application_uses_source aus,
app
WHERE aus.application_id = app.app_id
UNION
SELECT rs.source_id as source_id
FROM app,
application.service ser,
transaction.transaction t,
administrative.rrr r,
administrative.source_describes_rrr rs
WHERE ser.application_id = app.app_id
AND t.from_service_id = ser.id
AND r.transaction_id = t.id
AND rs.rrr_id = r.id)
SELECT CASE
WHEN (SELECT COUNT(app_id) FROM app) > 0 THEN
(SELECT a.nr || ''-'' || trim(to_char((SELECT COUNT(*) + 1 FROM sources), ''00''))
FROM app, application.application a WHERE a.id = app.app_id)
WHEN EXISTS (SELECT ba.id FROM administrative.ba_unit ba WHERE ba.id = #{refId} AND (SELECT COUNT(app_id) FROM app) = 0) THEN
(SELECT ba.name_firstpart || ''/'' || ba.name_lastpart FROM administrative.ba_unit ba WHERE ba.id = #{refId})
WHEN EXISTS (SELECT r.id FROM administrative.rrr r WHERE r.id = #{refId} AND (SELECT COUNT(app_id) FROM app) = 0) THEN
(SELECT r.nr FROM administrative.rrr r WHERE r.id = #{refId}) || ''-'' ||
trim(to_char((SELECT COUNT(*) + 1 FROM administrative.source_describes_rrr s WHERE s.rrr_id = #{refId}), ''00''))
ELSE trim(to_char(nextval(''source.source_la_nr_seq''), ''000000'')) END AS vl'
WHERE br_id = 'generate-source-nr';
-- *** RRR Numbering - RRR Numbers usually aren't displayed to the user so
-- just use a default numbering scheme
DROP SEQUENCE IF EXISTS administrative.rrr_nr_seq;
CREATE SEQUENCE administrative.rrr_nr_seq
INCREMENT 1
MINVALUE 100000
MAXVALUE 999999
START 100000
CACHE 3
CYCLE;
COMMENT ON SEQUENCE administrative.rrr_nr_seq
IS 'Allocates a 6 digit sequence number for RRRR numbers';
UPDATE system.br_definition SET "body" =
'SELECT trim(to_char(nextval(''administrative.rrr_nr_seq''), ''000000'')) AS vl'
WHERE br_id = 'generate-rrr-nr';
--- *** Notation Numbering. The notation number should be set to the application number.
-- The user can update if necessary through SOLA.
DROP SEQUENCE IF EXISTS administrative.notation_reference_nr_seq;
CREATE SEQUENCE administrative.notation_reference_nr_seq
INCREMENT 1
MINVALUE 200000
MAXVALUE 999999
START 200000
CACHE 3;
COMMENT ON SEQUENCE administrative.notation_reference_nr_seq
IS 'Allocates a 6 digit sequence number in the 200000 range for any Notations not linked to an application';
UPDATE system.br_definition SET "body" = '
SELECT CASE WHEN CAST(#{transactionId} AS VARCHAR(40)) IS NOT NULL THEN (
SELECT split_part(app.nr, ''/'', 1)
FROM application.application app
WHERE app.id IN ( SELECT ser.application_id
FROM application.service ser,
transaction.transaction t
WHERE t.id = #{transactionId}
AND ser.id = t.from_service_id))
ELSE (SELECT trim(to_char(nextval(''administrative.notation_reference_nr_seq''), ''000000''))) END AS vl'
WHERE br_id = 'generate-notation-reference-nr'; | true |
9de780a66de4c2fd874ec370ed5f5f08a0af832c | SQL | claudiomed/CursoPHP | /Practica/AprendiendoSQL/07- Ejercicios/Ejercicio25.sql | UTF-8 | 336 | 3.84375 | 4 | [] | no_license | #OBTENER UNA LISTA DE LOS NOMBRES DE LOS CLIENTES CON EL IMPORTE DE SUS ENCARGOS ACUMULADO#
SELECT cl.id AS 'ID CLIENTE', cl.nombre AS 'NOMBRE CLIENTE', (e.cantidad*co.precio) AS 'TOTAL DE COMPRA'
FROM clientes cl
INNER JOIN encargos e ON cl.id=e.cliente_id
INNER JOIN coches co ON co.id=e.coche_id
ORDER BY (e.cantidad*co.precio) ASC; | true |
446faec258105fda7106850adb1cb26b3b61a3a0 | SQL | jsbxyyx/seata_example | /script/init.sql | UTF-8 | 2,925 | 3.859375 | 4 | [] | no_license | CREATE DATABASE `test`;
CREATE TABLE `t_order` (
`user_id` int(11) NOT NULL,
`amount` decimal(10,2) NOT NULL,
`create_time` datetime NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `t_user` (
`id` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
`create_time` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `undo_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`branch_id` bigint(20) NOT NULL,
`context` varchar(128) NOT NULL,
`xid` varchar(100) NOT NULL,
`rollback_info` longblob NOT NULL,
`log_status` int(11) NOT NULL,
`log_created` datetime NOT NULL,
`log_modified` datetime NOT NULL,
`ext` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
CREATE TABLE test_uuid (
id VARCHAR(36) NOT NULL,
name VARCHAR(45) NULL,
PRIMARY KEY (id)
);
/******************* oracle **********************/
create table test_escape (
"sid" varchar2(50) primary key,
"param" varchar2(50),
"createTime" date
)
create table test_keyword(
"in" varchar2(50) primary key,
"desc" varchar2(50)
)
create table test_str(
id varchar(50) primary key,
name varchar(50)
)
create table test(
id number generated by default on null as identity primary key,
name varchar(50),
name2 varchar(50)
);
create table test1(
id int primary key,
name varchar(45),
name2 varchar(45)
);
create sequence test1_seq;
CREATE TABLE undo_log (
id number(20) NOT NULL,
branch_id number(20) NOT NULL,
xid varchar2(100) NOT NULL,
context varchar2(128) NOT NULL,
rollback_info blob NOT NULL,
log_status number(11) NOT NULL,
log_created timestamp NOT NULL,
log_modified timestamp NOT NULL,
ext varchar2(100) DEFAULT NULL,
PRIMARY KEY (id)
);
create unique index index_ux_undo_log on undo_log (xid, branch_id);
create sequence undo_log_seq;
create table "test_low" (
"id" number(10) primary key,
"name" varchar(50)
);
create sequence "test_low_seq";
insert into "test_low" values(2, 'xx');
/******************** oracle *********************/
/*************** mysql **********************/
create table test3 (
id int auto_increment primary key,
name varchar(50),
name2 varchar(50)
);
create table `test_low` (
`id` int primary key,
`name` varchar(50)
);
insert into `test_low` values(2, 'xx');
ALTER TABLE `test_low`
CHANGE COLUMN `id` `id` INT(11) NOT NULL AUTO_INCREMENT ;
CREATE TABLE test_keyword (
`in` VARCHAR(50) primary key,
`desc` VARCHAR(50)
)
create table test_escape (
`sid` varchar(50) primary key,
`param` varchar(50),
`createTime` date
)
create table test1(
id int auto_increment primary key,
name varchar(50)
)
/*************** mysql **********************/
/*************** postgresql ****************/
/*************** postgresql ****************/ | true |
c24fc66ade5d3e3ccfb5ca8a3cf122cd163234c8 | SQL | winjune/photo-map | /photo-map.sql | UTF-8 | 2,905 | 3.5 | 4 | [
"MIT"
] | permissive | /*
Navicat Premium Data Transfer
Source Server :
Source Server Type : MySQL
Source Server Version : 50646
Source Host :
Source Schema : photo_map
Target Server Type : MySQL
Target Server Version : 50646
File Encoding : 65001
Date: 12/12/2019 12:00:59
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for m_files
-- ----------------------------
DROP TABLE IF EXISTS `m_files`;
CREATE TABLE `m_files` (
`f_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '文件id',
`f_uid` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
`f_lng` varchar(20) NOT NULL DEFAULT '' COMMENT '经度',
`f_lat` varchar(20) NOT NULL DEFAULT '' COMMENT '纬度',
`f_url` varchar(255) NOT NULL DEFAULT '' COMMENT '文件路径',
`f_slurl` varchar(255) NOT NULL DEFAULT '' COMMENT '缩略图文件路径',
`f_wsysurl` varchar(255) NOT NULL DEFAULT '' COMMENT '无损压缩',
`f_caption` varchar(100) NOT NULL DEFAULT '' COMMENT '标题',
`f_event` varchar(500) NOT NULL DEFAULT '' COMMENT '记录事件',
`f_date_time` varchar(255) NOT NULL DEFAULT '' COMMENT '拍摄时间',
`f_towncode` varchar(255) NOT NULL DEFAULT '' COMMENT '区号',
`f_address` varchar(255) NOT NULL DEFAULT '' COMMENT '拍摄地点',
`f_isd` enum('1','0') NOT NULL DEFAULT '0' COMMENT '是否删除:1=删除,0=未删除',
`f_ctime` timestamp NULL DEFAULT NULL COMMENT '删除时间',
`f_video_url` varchar(255) NOT NULL DEFAULT '' COMMENT '视频文件路径',
PRIMARY KEY (`f_id`) USING BTREE,
KEY `idx_uid` (`f_uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='地图相册-文件表';
-- ----------------------------
-- Table structure for m_users
-- ----------------------------
DROP TABLE IF EXISTS `m_users`;
CREATE TABLE `m_users` (
`u_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
`u_love_uid` int(11) NOT NULL DEFAULT '0' COMMENT 'TA的用户ID',
`u_qq` varchar(20) NOT NULL DEFAULT '' COMMENT 'qq号',
`u_email` varchar(20) NOT NULL DEFAULT '' COMMENT 'qq邮箱',
`u_name` varchar(20) NOT NULL DEFAULT '' COMMENT '用户名',
`u_avatar` varchar(50) NOT NULL DEFAULT '' COMMENT '用户头像',
`u_google_auth` varchar(20) NOT NULL DEFAULT '' COMMENT '谷歌密钥',
`u_password` varchar(20) NOT NULL DEFAULT '' COMMENT '用户密码',
`u_code` varchar(20) NOT NULL COMMENT '关联密钥',
`u_love_code` varchar(20) NOT NULL DEFAULT '' COMMENT 'TA的关联密钥',
`u_love_time` timestamp NULL DEFAULT NULL COMMENT '关联时间',
`u_ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '添加时间',
PRIMARY KEY (`u_id`) USING BTREE,
KEY `u_id` (`u_id`) USING BTREE,
KEY `idx_qq` (`u_qq`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='地图相册-用户表';
SET FOREIGN_KEY_CHECKS = 1;
| true |
5ab9a51e91f3283aaf3a8439e268cd6787ed92c8 | SQL | kimkahunja/Inventory2 | /sql/20160429/post_adjustment.sql | UTF-8 | 1,066 | 3.125 | 3 | [] | no_license | DROP PROCEDURE IF EXISTS inventory.post_adjustment;
CREATE PROCEDURE inventory.`post_adjustment`(v_pdt_code INT,v_qty DOUBLE,v_location INT,OUT v_rtnVal VARCHAR(1000))
BEGIN
DECLARE v_prod_description VARCHAR(400);
DECLARE v_count_stock INTEGER;
SET autocommit = 0;
SELECT COUNT(*) INTO v_count_stock
FROM inv_stocks
WHERE stk_pdt_code=v_pdt_code
AND stk_loc_code=v_location;
IF v_count_stock=0 THEN
SELECT pdt_description INTO v_prod_description
FROM inv_products
WHERE pdt_code=v_pdt_code;
SET v_rtnVal = CONCAT('Stock not updated before...',v_prod_description);
-- signal sqlstate '45000' set message_text = v_prod_description; -- 'Stock not updated before';
ELSE
UPDATE inv_products SET pdt_current_qty=v_qty
WHERE pdt_code=v_pdt_code;
UPDATE inv_stocks SET stk_qty=v_qty
WHERE stk_pdt_code=v_pdt_code
AND stk_loc_code=v_location;
SET v_rtnVal="S";
END IF;
END;
| true |
1a2456b63ca6949ecf6dfd6be1aa06d82df8c879 | SQL | deniwerikmartins/financeiro | /financeiro.sql | UTF-8 | 3,188 | 3.171875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.4.15.10
-- https://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: 18-Jan-2019 às 10:31
-- Versão do servidor: 5.5.60-MariaDB
-- PHP Version: 7.2.11
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: `financeiro`
--
CREATE DATABASE IF NOT EXISTS `financeiro` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `financeiro`;
-- --------------------------------------------------------
--
-- Estrutura da tabela `backup`
--
CREATE TABLE IF NOT EXISTS `backup` (
`id` bigint(20) NOT NULL,
`linha` int(11) NOT NULL,
`hostname` varchar(255) NOT NULL,
`abbrev_tipo` varchar(255) NOT NULL,
`dia_x` varchar(255) NOT NULL,
`mes_3` float NOT NULL,
`mes_2` float NOT NULL,
`mes_1` float NOT NULL,
`validacao` varchar(255) NOT NULL,
`status` tinyint(4) NOT NULL,
`mes` int(11) NOT NULL,
`ano` year(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estrutura da tabela `planilha_consolidada`
--
CREATE TABLE IF NOT EXISTS `planilha_consolidada` (
`id` bigint(20) NOT NULL,
`hostname` varchar(255) NOT NULL,
`externalizacao` varchar(10) NOT NULL,
`diario1` float NOT NULL,
`diario2` float NOT NULL,
`diario3` float NOT NULL,
`diario4` float NOT NULL,
`diario5` float NOT NULL,
`diario6` float NOT NULL,
`semanal1` float NOT NULL,
`semanal2` float NOT NULL,
`semanal3` float NOT NULL,
`semanal4` float NOT NULL,
`mensal1` float NOT NULL,
`mensal2` float NOT NULL,
`mensal3` float NOT NULL,
`anual1` float NOT NULL,
`anual2` float NOT NULL,
`anual3` float NOT NULL,
`anual4` float NOT NULL,
`anual5` float NOT NULL,
`total` float NOT NULL,
`replicacao` varchar(10) NOT NULL,
`high_mes_atual` float NOT NULL,
`medium_mes_atual` float NOT NULL,
`priority` varchar(255) NOT NULL,
`obs` text NOT NULL,
`jobs` bigint(20) NOT NULL,
`high_mes_anterior` float NOT NULL,
`medium_mes_anterior` float NOT NULL,
`diferenca_high` float NOT NULL,
`diferenca_medium` float NOT NULL,
`descricao_validacao` text NOT NULL,
`mes` int(11) NOT NULL,
`ano` year(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `backup`
--
ALTER TABLE `backup`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `planilha_consolidada`
--
ALTER TABLE `planilha_consolidada`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `backup`
--
ALTER TABLE `backup`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `planilha_consolidada`
--
ALTER TABLE `planilha_consolidada`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
/*!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 |
8fab09120c9cfbdb522a7afa0e1bc4e6dfb098d9 | SQL | oehrlis/oradba | /sql/create_password_hash.sql | UTF-8 | 4,330 | 3.453125 | 3 | [
"UPL-1.0",
"Apache-2.0"
] | permissive | --------------------------------------------------------------------------------
-- OraDBA - Oracle Database Infrastructur and Security, 5630 Muri, Switzerland
--------------------------------------------------------------------------------
-- Name......: create_password_hash.sql
-- Author....: Stefan Oehrli (oes) stefan.oehrli@oradba.ch
-- Editor....: Stefan Oehrli
-- Date......: 2018.12.11
-- Revision..:
-- Purpose...: Callculate Oracle 10g Password Hash from Username and Password
-- Usage.....: @create_password_hash username password
-- Notes.....:
-- Reference.: execute DBMS_CRYPTO is required
-- License...: Licensed under the Universal Permissive License v 1.0 as
-- shown at http://oss.oracle.com/licenses/upl.
----------------------------------------------------------------------------
-- Modified..:
-- see git revision history for more information on changes/updates
----------------------------------------------------------------------------
-- Get parameters
define oh_user="&1"
define oh_password="&2"
SET SERVEROUTPUT ON
DECLARE
PasswordHashString VARCHAR2(30);
----------------------------------------------------------------------------
-- Function and Procedures ----------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-- Function..........: PasswordHash
-- Version...........: 1.2
-- Purpose...........: Function to create an oracle password hash (pre 11g)
-- Usage.............: hash_string := PasswordHash(username,<password>);
-- User parameters...: Username as VARCHAR2
-- Password as VARCHAR2 (DEFAULT = MANAGER)
-- Output parameters.: Unicode String as RAW
-- Notes.............: Callculate the Oracle password hash
-- 1. create an zero padded unicode string
-- 2. encrypt the unicode string with DES CBC and
-- 0123456789ABCDEF as the initial key
-- 3. take the last 8 byte as second key
-- 4. encrypt the unicode string with DES CBC and
-- use the last 8 byte created before
-- 5. take the last 8 byte from the second encryption
-- as password hash
---------------------------------------------------------------------------
FUNCTION PasswordHash(u IN VARCHAR2, pPassword IN VARCHAR2 := 'MANAGER') RETURN VARCHAR2
IS
vSecKey RAW(128);
vEncRAW RAW(2048);
vUniStr VARCHAR2(124) := '';
-- Define CONSTANT for the crypto type DES in CBC Mode with zero padding
cCryptoTyp CONSTANT PLS_INTEGER := DBMS_CRYPTO.ENCRYPT_DES + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_ZERO;
BEGIN
-- Build the new userpwd String as multibyte with the high byte set to 0 and convert the string into raw
FOR i IN 1..LENGTH(UPPER(u||pPassword)) LOOP vUniStr := vUniStr||CHR(0)||SUBSTR(UPPER(u||pPassword),i,1); END LOOP;
-- First DES encryption to create the second DES key
vEncRAW:= DBMS_CRYPTO.ENCRYPT(SRC=>UTL_RAW.CAST_TO_RAW(vUniStr), TYP => cCryptoTyp, KEY => HEXTORAW('0123456789ABCDEF'));
-- Get the last 8 Bytes as second key
vSecKey:= HEXTORAW(SUBSTR(vEncRAW,(LENGTH(vEncRAW)-16+1),16));
-- Second DES encryption to create the Hash
vEncRAW:= DBMS_CRYPTO.ENCRYPT(SRC=> UTL_RAW.CAST_TO_RAW(vUniStr), TYP => cCryptoTyp, KEY => vSecKey);
-- Return the last 8 bytes as Oracle Hash
RETURN(HEXTORAW(SUBSTR(vEncRAW,(LENGTH(vEncRAW)-16+1),16)));
END;
----------------------------------------------------------------------------
-- Main ----------------------
----------------------------------------------------------------------------
BEGIN
-- calculate oracle hash
PasswordHashString := PasswordHash('&oh_user','&oh_password');
-- Display the whole stuff
DBMS_OUTPUT.put_line('Username : &oh_user');
DBMS_OUTPUT.put_line('Password : &oh_password');
DBMS_OUTPUT.put_line('Hash : ' ||PasswordHashString);
DBMS_OUTPUT.put_line('SQL : alter user &oh_user identified by values '''|| PasswordHashString ||''';');
END;
/
-- EOF --------------------------------------------------------------------- | true |
23cef0a596256fb464a86848ab8ace7158940779 | SQL | juheon97/cs313-JS-node | /data/teamdata.sql | UTF-8 | 449 | 3.03125 | 3 | [] | no_license | DROP TABLE child;
DROP TABLE person;
CREATE TABLE person (
person_id SERIAL PRIMARY KEY,
person_first_name VARCHAR(30) NOT NULL,
person_last_name VARCHAR(30) NOT NULL,
birth DATE NOT NULL
);
CREATE TABLE child (
child_id SERIAL PRIMARY KEY,
child_first VARCHAR(30) NOT NULL,
child_last VARCHAR(30) NOT NULL,
birth DATE NOT NULL,
person_id INT NOT NULL REFERENCES person(person_id)
);
| true |
31d311cc04d5532ffe10432f7ceb4c7a43471835 | SQL | DesarrolladorHeber/PruebaCodigo | /listas_proveedores/Docs/2.tabla_lista_precios_proveedores.sql | UTF-8 | 1,461 | 3.46875 | 3 | [
"Apache-2.0"
] | permissive | CREATE TABLE lista_precios_proveedores (
cod_lista integer NOT NULL,
codigo_producto character varying(40) NOT NULL,
precio_bruto numeric(12,0) DEFAULT 0 NOT NULL,
iva numeric(3,0) DEFAULT 0,
precio_neto numeric(12,0) DEFAULT 0 NOT NULL,
unidad_empaque numeric(12,0) DEFAULT 0 NOT NULL
);
COMMENT ON TABLE lista_precios_proveedores IS 'Lista de precios para los productos por proveedor.';
COMMENT ON COLUMN lista_precios_proveedores.cod_lista IS 'Llave foranea de la lista.';
COMMENT ON COLUMN lista_precios_proveedores.codigo_producto IS 'Codigo del producto.';
COMMENT ON COLUMN lista_precios_proveedores.precio_bruto IS 'Precio sin iva del producto';
COMMENT ON COLUMN lista_precios_proveedores.iva IS 'iva que tendra el producto';
COMMENT ON COLUMN lista_precios_proveedores.precio_neto IS 'Precio incluido iva';
COMMENT ON COLUMN lista_precios_proveedores.unidad_empaque IS 'Unidades por las que viene el producto.';
ALTER TABLE ONLY lista_precios_proveedores
ADD CONSTRAINT lista_precios_proveedores_pkey PRIMARY KEY (cod_lista, codigo_producto);
ALTER TABLE ONLY lista_precios_proveedores
ADD CONSTRAINT cod_lista FOREIGN KEY (cod_lista) REFERENCES listas_proveedores(cod_lista) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY lista_precios_proveedores
ADD CONSTRAINT codigo_producto FOREIGN KEY (codigo_producto) REFERENCES inventarios_productos(codigo_producto) ON UPDATE CASCADE ON DELETE CASCADE;
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.