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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
004d44e1adf3134299c37d4997460ed300314d96 | SQL | BarcampBangalore/schadmin | /sch_selected_sessions.sql | UTF-8 | 3,715 | 2.84375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 3.5.8
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 12, 2013 at 08:07 AM
-- Server version: 5.1.70-cll
-- PHP Version: 5.3.17
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: `barcampb_bcbcms`
--
-- --------------------------------------------------------
--
-- Table structure for table `sch_selected_sessions`
--
CREATE TABLE IF NOT EXISTS `sch_selected_sessions` (
`id` int(3) NOT NULL AUTO_INCREMENT,
`post_id` int(10) NOT NULL,
`author` varchar(40) NOT NULL,
`post_title` varchar(1000) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_post` (`post_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=217 ;
--
-- Dumping data for table `sch_selected_sessions`
--
INSERT INTO `sch_selected_sessions` (`id`, `post_id`, `author`, `post_title`) VALUES
(181, 2204, 'siva.sap', 'Introduction to Cloud Computing'),
(182, 2232, 'hiemanshu', 'Working on the Android ROMs. Why, What and How!'),
(183, 2430, 'vishwasmudagal', 'Technology Innovation In Legal Industry'),
(184, 2318, 'soham', 'Make an android music player in 40 minutes flat'),
(185, 2143, 'laforge49', 'Distributed, Robust Software Made Easy'),
(186, 2398, 'vasudeva', 'Creating Astonishing mobile UX'),
(187, 2132, 'saifikhan', 'Lua (with C) an embeddable extensible scripting language'),
(188, 2480, 'arun.alpha', 'Randomness and Bias'),
(189, 2504, 'vibha', 'So it is BYOD now'),
(190, 2292, 'Sunanda', 'Graphology'),
(191, 2615, 'NJ666', 'Questioning Authority and Freedom'),
(192, 2300, 'AnujDuggal', 'Enhancing User Experience – Explain your product better'),
(193, 2314, 'pranayairan', 'Reverse Engineering an Android app – securing your android apps against attacks'),
(194, 2284, 'anandvns', 'No JS + Intro to DartCon'),
(195, 2076, 'sathyabhat', 'Password Management & You'),
(196, 2408, 'pavanv', 'How you could have survived the AWS Christmas eve outage'),
(197, 2404, 'twsitedlog', 'Taking Web Application Deployment from infancy to maturity using Cloud'),
(198, 2159, 'mail2akhtar', 'Storage as a Service and OpenStack storage services'),
(199, 2513, 'geekoo', 'Become a Better Programmer'),
(200, 2486, 'muqsith', 'Creating a Heatmap for Google Maps'),
(201, 2139, 'Ratzzz', 'Mathematics in Photography'),
(202, 2245, 'Gautam', 'Gamification'),
(203, 2155, 'Raghu25289', 'Why do people become entrepreneurs?'),
(204, 2147, 'ruchir89', 'A siteless vision: the power of accessibility'),
(205, 2424, 'adityabhushan61', 'Standing out or Outstanding: Networked life and the power of weak Links'),
(206, 2389, 'brandbull', 'New Trends in eCommerce – where do you fit in?'),
(207, 2185, 'thava', 'Python Concurrency'),
(208, 2509, 'deepakagra', 'BigQuery by Google'),
(209, 2200, 'caulagi', 'Expose your data'),
(210, 2496, 'fagun', 'Javascript – the winner!'),
(211, 2236, 'uday', 'Democracy Powered by Political Network (aka Social Network)'),
(212, 2263, 'rizmaverick', 'Get groovy with Groovy!'),
(213, 2518, 'Amrit Sanjeev', 'User Experience Designing for Mobile applications – What developers should know !'),
(214, 2453, 'Aravind', 'Mowbly'),
(215, 2228, 'djds4rce', 'True story of The Internet'),
(216, 2338, 'shankarsoma', 'Video Search Optimization & VSEO');
/*!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 |
7b9a24afd6d016568725298608236cb7a3330fa8 | SQL | madiandi17/isi-jtabel-dari-database- | /src/main/sql/skema-mysql.sql | UTF-8 | 325 | 2.84375 | 3 | [] | no_license | CREATE TABLE t_kontak (
id INT AUTO_INCREMENT,
nama VARCHAR(255) NOT NULL,
alamat VARCHAR(255) NOT NULL,
tanggal_lahir DATE,
aktif BOOLEAN,
PRIMARY KEY(id)
)Engine= InnoDB;
INSERT INTO t_kontak(nama, alamat, tanggal_lahir, aktif) VALUE
('Madi Andi', 'Jl.Madi Gosling', '1994-12-17', true),
('Dima Gosling', 'Jl.Dima Gosling', '1994-12-12', true); | true |
14cb7bb638389be16e9cf446d0188e2c0ae8786b | SQL | Community4WCF/de.community4wcf.contentPage | /install.sql | UTF-8 | 698 | 2.828125 | 3 | [] | no_license | DROP TABLE IF EXISTS wcf1_content_page;
CREATE TABLE wcf1_content_page (
pageID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
subject VARCHAR(255) NOT NULL DEFAULT '',
message MEDIUMTEXT NOT NULL,
shortDescription text NOT NULL,
time INT(10) NOT NULL DEFAULT 0,
icon varchar(255) NOT NULL,
canSeeGroupIDs varchar(255) NOT NULL,
userID INT(10) NOT NULL,
menuItemID int(10) unsigned NOT NULL,
attachments SMALLINT(5) NOT NULL DEFAULT 0,
pollID INT(10) NOT NULL DEFAULT 0,
enableSmilies TINYINT(1) NOT NULL DEFAULT 1,
enableHtml TINYINT(1) NOT NULL DEFAULT 0,
enableBBCodes TINYINT(1) NOT NULL DEFAULT 1,
FULLTEXT KEY (subject, message),
KEY (time)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; | true |
0a4d2bb2903fb78c3550e6600c309e15878b47d9 | SQL | GuilhermeLaraRusso/Trybe-MySQL | /Bloco 19/Query 6.sql | UTF-8 | 192 | 2.765625 | 3 | [] | no_license | SELECT * FROM sakila.actor;
SELECT DISTINCT last_name FROM sakila.actor;
SELECT COUNT(DISTINCT last_name) FROM sakila.actor;
SELECT * FROM sakila.actor
ORDER BY last_name ASC, first_name DESC; | true |
d0a4be24ff3e5504c5a3cd558acefacc9e8aff8c | SQL | rongandat/phanloaicanbo | /sql/update_version_26_6.sql | UTF-8 | 373 | 2.703125 | 3 | [] | no_license | CREATE TABLE `employees_luan_chuyen_history` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`em_id` INTEGER UNSIGNED NOT NULL,
`from_date` DATETIME,
`to_date` DATETIME,
`chuc_vu` INTEGER UNSIGNED,
`don_vi` INTEGER UNSIGNED,
`ngach_cong_chuc` INTEGER UNSIGNED,
`cong_viec` VARCHAR(255),
`chuyen_mon` VARCHAR(255),
PRIMARY KEY (`id`)
)
ENGINE = InnoDB;
| true |
2cda58e9efc675d6c9f7e81a8538d09f210313ab | SQL | msredhotero/despachadordeaduana | /sql/consultas/valor_puntos_por_funcion_obra.sql | UTF-8 | 1,515 | 3.734375 | 4 | [] | no_license | select
((t.totalgral * coalesce(t.porcentajereparto,1) / 100) - (t.totalgral * coalesce(t.porcentajeretencion,1) / 100)) / op.puntos
from (
select
sum(r.total - (r.valorpulicidad + r.costopapelentrada + r.gastotarjeta + r.argentores)) as totalgral, r.idobra,r.porcentajereparto, r.porcentajeretencion
from (
SELECT
total,
o.valorpulicidad,
round((o.valorticket * v.cantidad),2) as costopapelentrada,
round((o.costotranscciontarjetaiva / 100 * v.totaltarjeta),2) as gastotarjeta,
round((o.porcentajeargentores / 100 * v.total),2) as argentores,
o.idobra,
o.porcentajereparto,
o.porcentajeretencion
FROM dbventas v
inner join dbfunciones fu on fu.idfuncion = v.reffunciones
inner join dbobras o on o.idobra = fu.refobras
where fu.idfuncion = 40) as r
group by r.idobra,r.porcentajereparto, r.porcentajeretencion
) as t
inner join (SELECT
sum(cp.puntos) as puntos, o.idobra
FROM
dbpersonal p
INNER JOIN
dbpersonalcooperativas cp ON p.idpersonal = cp.refpersonal
INNER JOIN
dbcooperativas c ON c.idcooperativa = cp.refcooperativas
INNER JOIN
dbobrascooperativas oc ON oc.refcooperativas = c.idcooperativa
INNER JOIN
dbobras o ON o.idobra = oc.refobras
INNER JOIN
dbfunciones fu ON o.idobra = fu.refobras and fu.refcooperativas = c.idcooperativa
INNER JOIN
tbdias di ON di.iddia = fu.refdias
where fu.idfuncion = 40
group by o.idobra) op on op.idobra = t.idobra | true |
5ce86d53ef7d7a73088002475fa74c99045e1e9a | SQL | abarkhuysen/git-web-pagechangedemo | /pagechangedemo.sql | UTF-8 | 1,800 | 2.6875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 3.2.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 11, 2013 at 12:45 PM
-- Server version: 5.1.44
-- PHP Version: 5.3.1
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!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: `pagechangedemo`
--
-- --------------------------------------------------------
--
-- Table structure for table `links`
--
CREATE TABLE IF NOT EXISTS `links` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`url` varchar(65000) NOT NULL,
`md5hash` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;
--
-- Dumping data for table `links`
--
INSERT INTO `links` (`id`, `url`, `md5hash`) VALUES
(1, 'www.andm.gov.za/Pages/Vacancies.aspx', '4a86174c914388ce54be841e1859f885'),
(2, 'www.chrishanidm.gov.za/vacancies', 'e6be199727ccd74cc302f899b7501f0d'),
(3, 'www.lejwe.co.za/?page_id=1692', ''),
(4, 'www.sedibeng.gov.za/vacancies.html', '85eaae31d04980792b0e33a4e1715a17'),
(6, 'www.amajuba.gov.za/taxonomy/term/46', '9dfcb2fb9863cb0fe860f1d558af9842'),
(7, 'www.ilembe.gov.za/index.php/administration/careers', '7afa95c6b77fa6a0feed8d077eb5651e'),
(8, 'www.sisonke.gov.za/Vacancies.aspx', '5f9dac37cb5c12191aeff72f915f94db'),
(9, 'www.ugu.gov.za/vacancies.html', '2819005ef23b0e2e03efa40a39873cb6'),
(10, 'www.uthungulu.org.za/uThungulu/node/8', ''),
(11, 'www.sekhukhune.gov.za/vacancies.html', 'abd78db2d4d14e715c7929cd4927cccc'),
(12, 'www.cdmunicipality.wsiefusion.net/Vacancies', ''),
(13, 'www.vhembe.gov.za/index.php?page=vacancies', 'c1ad3107918bb0442beb197fbae15897');
| true |
c9900c0e37f5474a85d60a6fdf8204b094330a47 | SQL | gJigsaw/pyohio | /pyohio/junkdrawer/speaker_preferences.sql | UTF-8 | 481 | 3 | 3 | [] | no_license | alter table proposals_proposalbase
add column confirmed_after_first_pass timestamptz,
add column confirmed_accepted timestamptz;
create table speaker_available_times
(
speaker_id integer not null
references speakers_speaker (id)
on delete cascade,
available_time tstzrange not null
);
create table speaker_preferred_times
(
speaker_id integer not null
references speakers_speaker (id)
on delete cascade,
preferred_time tstzrange not null
);
| true |
da3531049f4e61f088556e238ee3027713956f8d | SQL | Mrcassin/bds-db-design | /mysql_bds_db_design.sql | UTF-8 | 10,325 | 3.3125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- Počítač: 127.0.0.1
-- Vytvořeno: Úte 02. lis 2021, 17:15
-- Verze serveru: 10.4.18-MariaDB
-- Verze PHP: 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 */;
--
-- Databáze: `bds_db_design`
--
-- --------------------------------------------------------
--
-- Struktura tabulky `address`
--
CREATE TABLE `address` (
`address_id` int(11) NOT NULL,
`city` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`street` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`house_number` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`zip_code` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `cinema`
--
CREATE TABLE `cinema` (
`cinema_id` int(11) NOT NULL,
`cinema_name` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`address_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `genre`
--
CREATE TABLE `genre` (
`genre_id` int(11) NOT NULL,
`genre_type` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
--
-- Vypisuji data pro tabulku `genre`
--
INSERT INTO `genre` (`genre_id`, `genre_type`) VALUES
(1, 'drama'),
(2, 'komedie');
-- --------------------------------------------------------
--
-- Struktura tabulky `hall`
--
CREATE TABLE `hall` (
`hall_id` int(11) NOT NULL,
`hall_name` varchar(3) COLLATE utf8mb4_czech_ci NOT NULL,
`cinema_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `membership`
--
CREATE TABLE `membership` (
`membership_id` int(11) NOT NULL,
`membership_type` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`expiration` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `movie`
--
CREATE TABLE `movie` (
`movie_id` int(11) NOT NULL,
`title` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`duration` int(11) NOT NULL,
`description` text COLLATE utf8mb4_czech_ci NOT NULL,
`banner` blob DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `movie_has_genre`
--
CREATE TABLE `movie_has_genre` (
`movie_id` int(11) NOT NULL,
`genre_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `news`
--
CREATE TABLE `news` (
`news_id` int(11) NOT NULL,
`title` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`article` text COLLATE utf8mb4_czech_ci NOT NULL,
`cinema_id` int(11) NOT NULL,
`photo` blob DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `seat`
--
CREATE TABLE `seat` (
`seat_id` int(11) NOT NULL,
`availability` tinyint(1) NOT NULL,
`show_id` int(11) NOT NULL,
`hall_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `shows`
--
CREATE TABLE `shows` (
`show_id` int(11) NOT NULL,
`show_start` datetime NOT NULL,
`show_end` datetime NOT NULL,
`price` int(11) NOT NULL,
`movie_id` int(11) NOT NULL,
`hall_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `users`
--
CREATE TABLE `users` (
`user_id` int(11) NOT NULL,
`given_name` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`family_name` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`mail` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`password` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL,
`phone_number` int(11) DEFAULT NULL,
`membership_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `user_has_address`
--
CREATE TABLE `user_has_address` (
`user_id` int(11) NOT NULL,
`address_id` int(11) NOT NULL,
`address_type` varchar(45) COLLATE utf8mb4_czech_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
-- --------------------------------------------------------
--
-- Struktura tabulky `user_has_show`
--
CREATE TABLE `user_has_show` (
`user_id` int(11) NOT NULL,
`show_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci;
--
-- Indexy pro exportované tabulky
--
--
-- Indexy pro tabulku `address`
--
ALTER TABLE `address`
ADD PRIMARY KEY (`address_id`);
--
-- Indexy pro tabulku `cinema`
--
ALTER TABLE `cinema`
ADD PRIMARY KEY (`cinema_id`),
ADD KEY `address_id` (`address_id`);
--
-- Indexy pro tabulku `genre`
--
ALTER TABLE `genre`
ADD PRIMARY KEY (`genre_id`);
--
-- Indexy pro tabulku `hall`
--
ALTER TABLE `hall`
ADD PRIMARY KEY (`hall_id`),
ADD KEY `cinema_id` (`cinema_id`);
--
-- Indexy pro tabulku `membership`
--
ALTER TABLE `membership`
ADD PRIMARY KEY (`membership_id`);
--
-- Indexy pro tabulku `movie`
--
ALTER TABLE `movie`
ADD PRIMARY KEY (`movie_id`);
--
-- Indexy pro tabulku `movie_has_genre`
--
ALTER TABLE `movie_has_genre`
ADD KEY `movie_id` (`movie_id`),
ADD KEY `genre_id` (`genre_id`);
--
-- Indexy pro tabulku `news`
--
ALTER TABLE `news`
ADD PRIMARY KEY (`news_id`),
ADD KEY `cinema_id` (`cinema_id`);
--
-- Indexy pro tabulku `seat`
--
ALTER TABLE `seat`
ADD PRIMARY KEY (`seat_id`),
ADD KEY `show_id` (`show_id`),
ADD KEY `hall_id` (`hall_id`);
--
-- Indexy pro tabulku `shows`
--
ALTER TABLE `shows`
ADD PRIMARY KEY (`show_id`),
ADD KEY `movie_id` (`movie_id`),
ADD KEY `hall_id` (`hall_id`);
--
-- Indexy pro tabulku `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`user_id`),
ADD KEY `membership_id` (`membership_id`);
--
-- Indexy pro tabulku `user_has_address`
--
ALTER TABLE `user_has_address`
ADD KEY `user_id` (`user_id`),
ADD KEY `address_id` (`address_id`);
--
-- Indexy pro tabulku `user_has_show`
--
ALTER TABLE `user_has_show`
ADD KEY `user_id` (`user_id`),
ADD KEY `show_id` (`show_id`);
--
-- AUTO_INCREMENT pro tabulky
--
--
-- AUTO_INCREMENT pro tabulku `address`
--
ALTER TABLE `address`
MODIFY `address_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pro tabulku `cinema`
--
ALTER TABLE `cinema`
MODIFY `cinema_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pro tabulku `genre`
--
ALTER TABLE `genre`
MODIFY `genre_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT pro tabulku `hall`
--
ALTER TABLE `hall`
MODIFY `hall_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pro tabulku `membership`
--
ALTER TABLE `membership`
MODIFY `membership_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pro tabulku `movie`
--
ALTER TABLE `movie`
MODIFY `movie_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pro tabulku `news`
--
ALTER TABLE `news`
MODIFY `news_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pro tabulku `seat`
--
ALTER TABLE `seat`
MODIFY `seat_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pro tabulku `shows`
--
ALTER TABLE `shows`
MODIFY `show_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pro tabulku `users`
--
ALTER TABLE `users`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Omezení pro exportované tabulky
--
--
-- Omezení pro tabulku `cinema`
--
ALTER TABLE `cinema`
ADD CONSTRAINT `cinema_ibfk_1` FOREIGN KEY (`address_id`) REFERENCES `address` (`address_id`);
--
-- Omezení pro tabulku `hall`
--
ALTER TABLE `hall`
ADD CONSTRAINT `hall_ibfk_1` FOREIGN KEY (`cinema_id`) REFERENCES `cinema` (`cinema_id`);
--
-- Omezení pro tabulku `movie_has_genre`
--
ALTER TABLE `movie_has_genre`
ADD CONSTRAINT `movie_has_genre_ibfk_1` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`movie_id`),
ADD CONSTRAINT `movie_has_genre_ibfk_2` FOREIGN KEY (`genre_id`) REFERENCES `genre` (`genre_id`);
--
-- Omezení pro tabulku `news`
--
ALTER TABLE `news`
ADD CONSTRAINT `news_ibfk_1` FOREIGN KEY (`cinema_id`) REFERENCES `cinema` (`cinema_id`);
--
-- Omezení pro tabulku `seat`
--
ALTER TABLE `seat`
ADD CONSTRAINT `seat_ibfk_1` FOREIGN KEY (`show_id`) REFERENCES `shows` (`show_id`),
ADD CONSTRAINT `seat_ibfk_2` FOREIGN KEY (`hall_id`) REFERENCES `hall` (`hall_id`);
--
-- Omezení pro tabulku `shows`
--
ALTER TABLE `shows`
ADD CONSTRAINT `shows_ibfk_1` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`movie_id`),
ADD CONSTRAINT `shows_ibfk_2` FOREIGN KEY (`hall_id`) REFERENCES `hall` (`hall_id`);
--
-- Omezení pro tabulku `users`
--
ALTER TABLE `users`
ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`membership_id`) REFERENCES `membership` (`membership_id`);
--
-- Omezení pro tabulku `user_has_address`
--
ALTER TABLE `user_has_address`
ADD CONSTRAINT `user_has_address_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`),
ADD CONSTRAINT `user_has_address_ibfk_2` FOREIGN KEY (`address_id`) REFERENCES `address` (`address_id`);
--
-- Omezení pro tabulku `user_has_show`
--
ALTER TABLE `user_has_show`
ADD CONSTRAINT `user_has_show_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`),
ADD CONSTRAINT `user_has_show_ibfk_2` FOREIGN KEY (`show_id`) REFERENCES `shows` (`show_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 |
63a7c9164a6ff3583646460fc2fb6ca3c51c9979 | SQL | Declipe/EDB | /tables/game_event_npcflag.sql | UTF-8 | 866 | 2.65625 | 3 | [] | no_license | -- ----------------------------
-- Table structure for `game_event_npcflag`
-- ----------------------------
DROP TABLE IF EXISTS `game_event_npcflag`;
CREATE TABLE `game_event_npcflag` (
`eventEntry` tinyint(3) unsigned NOT NULL COMMENT 'Entry of the game event',
`guid` mediumint(8) unsigned NOT NULL DEFAULT '0',
`npcflag` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`guid`,`eventEntry`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of game_event_npcflag
-- ----------------------------
INSERT INTO `game_event_npcflag` VALUES ('17', '1803', '179');
INSERT INTO `game_event_npcflag` VALUES ('17', '38112', '129');
INSERT INTO `game_event_npcflag` VALUES ('17', '26771', '179');
INSERT INTO `game_event_npcflag` VALUES ('17', '46320', '177');
INSERT INTO `game_event_npcflag` VALUES ('17', '208240', '1048705');
| true |
70c4a511dfee81d8b6380fe44a4936cedbfdc2d9 | SQL | toho7/EM2020_Melmer_Paulweber | /Abgabe DBI Projekt/SQL Dateien/Top10FifaAusEM.sql | UTF-8 | 306 | 2.625 | 3 | [] | no_license | use em2020_melmer_paulweber;
-- Liefert Mannschaften aus Top 10 der FifaWeltrangliste die bei der EM teilnehmen
SELECT mannschaft.fifaWeltrangliste AS FifaWeltrangliste, mannschaft.land AS Mannschaft
FROM mannschaft
WHERE mannschaft.fifaWeltrangliste <= 10
ORDER BY mannschaft.fifaWeltrangliste | true |
c09f512e08fafe202848743f0fc7a8f557242cf1 | SQL | caominhchung/Ki_9 | /PTTK/demo/DB/Dump20210115/dbpttk_tblmathang.sql | UTF-8 | 3,010 | 3 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 8.0.22, for Win64 (x86_64)
--
-- Host: localhost Database: dbpttk
-- ------------------------------------------------------
-- Server version 8.0.22
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!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 `tblmathang`
--
DROP TABLE IF EXISTS `tblmathang`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tblmathang` (
`tblMathangID` int NOT NULL,
`tenmathang` varchar(255) DEFAULT NULL,
`ma` varchar(255) DEFAULT NULL,
`giaban` float DEFAULT NULL,
`gianhap` float DEFAULT NULL,
`nhacungcap` varchar(255) DEFAULT NULL,
`nhanhieu` varchar(255) DEFAULT NULL,
`tblMathangsudungID` int DEFAULT NULL,
PRIMARY KEY (`tblMathangID`),
KEY `tblMathangsudungID` (`tblMathangsudungID`),
CONSTRAINT `tblmathang_ibfk_1` FOREIGN KEY (`tblMathangsudungID`) REFERENCES `tblmathangsudung` (`tblMathangsudungID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tblmathang`
--
LOCK TABLES `tblmathang` WRITE;
/*!40000 ALTER TABLE `tblmathang` DISABLE KEYS */;
INSERT INTO `tblmathang` VALUES (1,'oke babe','OK',30000,20000,'abc','OK',NULL),(2,'acbxyz','1212',10000,7000,'Ga Muuuu','Adidasssssss',2),(3,'Thach rau cau','TRV',25000,15000,'Boganic','Long Hai',3),(4,'Banh trung thu','BTT',15000,80000,'Guciiiiiiiiiiiii','Bao Hung',4),(5,'Miranda soda kem','MSDK',10000,7200,'Nam Hai','Pink',5),(6,'Miranda mau cam','MMC',10000,7200,'Nam Hai','Clock',6),(7,'Miranda chua nghi ra','MCNR',15000,12000,'Paper','Nam Hai',7),(8,'Nuoc loccc','VN01',6000,3500,'Clock','Nam Hai',8),(9,'abcccc','vcac',15000,5000,'qet','Nam Hai',8),(10,'vhvcahvc','jacjad',15000,6000,'adgh','Nam Hai',7),(11,'jbk','848ad',15100,1540,'bnv','Nam Hai',8),(12,'adghjs','bca120',600000,6000,'Nam Hai','Adidas',NULL);
/*!40000 ALTER TABLE `tblmathang` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-01-15 13:56:52
| true |
919f9f1f73084788cf9677ddbdf537b510415aa7 | SQL | Jgarcia4377/api-iVoto | /db/iVoto.sql | UTF-8 | 8,138 | 3.296875 | 3 | [] | no_license | -- MySQL Script generated by MySQL Workbench
-- Thu Aug 1 00:55:54 2019
-- 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 iVoto
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema iVoto
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `iVoto` DEFAULT CHARACTER SET utf8 ;
USE `iVoto` ;
-- -----------------------------------------------------
-- Table `iVoto`.`estadoVotacion`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `iVoto`.`estadoVotacion` (
`idestadoVotacion` INT(11) NOT NULL AUTO_INCREMENT,
`tipo` VARCHAR(45) NOT NULL,
PRIMARY KEY (`idestadoVotacion`))
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `iVoto`.`evento`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `iVoto`.`evento` (
`idevento` INT(11) NOT NULL AUTO_INCREMENT,
`descripcion` VARCHAR(60) NOT NULL,
`observaciones` VARCHAR(200) NULL DEFAULT NULL,
`fechaHoraInicio` DATETIME NOT NULL,
`fechaHoraFin` DATETIME NOT NULL,
`idestadoVotacion` INT(11) NOT NULL,
PRIMARY KEY (`idevento`),
INDEX `fk_votacion_estadoVotacion1_idx` (`idestadoVotacion` ASC),
CONSTRAINT `fk_votacion_estadoVotacion1`
FOREIGN KEY (`idestadoVotacion`)
REFERENCES `iVoto`.`estadoVotacion` (`idestadoVotacion`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `iVoto`.`persona`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `iVoto`.`persona` (
`idpersona` INT(11) NOT NULL AUTO_INCREMENT,
`cedula` VARCHAR(10) NOT NULL,
`nombres` VARCHAR(50) NOT NULL,
`apellido_p` VARCHAR(45) NOT NULL,
`apellido_m` VARCHAR(45) NOT NULL,
`huella_dactilar` VARCHAR(10) NULL DEFAULT NULL,
`correo` VARCHAR(45) NOT NULL,
`telefono` VARCHAR(10) NOT NULL,
`direccion` VARCHAR(100) NOT NULL,
PRIMARY KEY (`idpersona`),
UNIQUE INDEX `cedula_UNIQUE` (`cedula` ASC))
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `iVoto`.`PuestosCandidatos`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `iVoto`.`PuestosCandidatos` (
`idPuestosCandidatos` INT NOT NULL AUTO_INCREMENT,
`tipo` VARCHAR(100) NOT NULL,
PRIMARY KEY (`idPuestosCandidatos`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `iVoto`.`PartidosPoliticos`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `iVoto`.`PartidosPoliticos` (
`idPartidosPoliticos` INT NOT NULL AUTO_INCREMENT,
`nombrePartido` VARCHAR(100) NOT NULL,
`numeroPartido` VARCHAR(45) NOT NULL,
PRIMARY KEY (`idPartidosPoliticos`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `iVoto`.`candidato`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `iVoto`.`candidato` (
`idcandidato` INT(11) NOT NULL AUTO_INCREMENT,
`idvotacion` INT(11) NOT NULL,
`idpersona` INT(11) NOT NULL,
`idPuestosCandidatos` INT NOT NULL,
`idPartidosPoliticos` INT NOT NULL,
`cantidadVotos` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`idcandidato`),
INDEX `fk_candidato_votacion1_idx` (`idvotacion` ASC),
INDEX `fk_candidato_persona1_idx` (`idpersona` ASC),
INDEX `fk_candidato_PuestosCandidatos1_idx` (`idPuestosCandidatos` ASC),
INDEX `fk_candidato_PartidosPoliticos1_idx` (`idPartidosPoliticos` ASC),
CONSTRAINT `fk_candidato_votacion1`
FOREIGN KEY (`idvotacion`)
REFERENCES `iVoto`.`evento` (`idevento`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_candidato_persona1`
FOREIGN KEY (`idpersona`)
REFERENCES `iVoto`.`persona` (`idpersona`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_candidato_PuestosCandidatos1`
FOREIGN KEY (`idPuestosCandidatos`)
REFERENCES `iVoto`.`PuestosCandidatos` (`idPuestosCandidatos`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_candidato_PartidosPoliticos1`
FOREIGN KEY (`idPartidosPoliticos`)
REFERENCES `iVoto`.`PartidosPoliticos` (`idPartidosPoliticos`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `iVoto`.`estado_usuario`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `iVoto`.`estado_usuario` (
`idestado` INT(11) NOT NULL AUTO_INCREMENT,
`estado` VARCHAR(45) NOT NULL,
PRIMARY KEY (`idestado`))
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `iVoto`.`tipo_usuario`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `iVoto`.`tipo_usuario` (
`idtipo` INT(11) NOT NULL AUTO_INCREMENT,
`tipo` VARCHAR(45) NOT NULL,
PRIMARY KEY (`idtipo`))
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `iVoto`.`usuario`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `iVoto`.`usuario` (
`idusuario` INT(11) NOT NULL AUTO_INCREMENT,
`usuario` VARBINARY(100) NOT NULL,
`contrasena` VARBINARY(100) NOT NULL,
`persona_idpersona` INT(11) NOT NULL,
`tipo_usuario_id` INT(11) NOT NULL,
`estado_usuario_id` INT(11) NOT NULL,
PRIMARY KEY (`idusuario`),
INDEX `fk_usuario_persona_idx` (`persona_idpersona` ASC),
INDEX `fk_usuario_tipo_usuario1_idx` (`tipo_usuario_id` ASC),
INDEX `fk_usuario_estado_usuario1_idx` (`estado_usuario_id` ASC),
CONSTRAINT `fk_usuario_estado_usuario1`
FOREIGN KEY (`estado_usuario_id`)
REFERENCES `iVoto`.`estado_usuario` (`idestado`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_usuario_persona`
FOREIGN KEY (`persona_idpersona`)
REFERENCES `iVoto`.`persona` (`idpersona`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_usuario_tipo_usuario1`
FOREIGN KEY (`tipo_usuario_id`)
REFERENCES `iVoto`.`tipo_usuario` (`idtipo`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `iVoto`.`votoDetalle`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `iVoto`.`votoDetalle` (
`idvotoDetalle` INT(11) NOT NULL AUTO_INCREMENT,
`fechaHoraVoto` DATETIME NOT NULL,
`idevento` INT(11) NOT NULL,
`idusuario` INT(11) NOT NULL,
`idcandidato` INT(11) NOT NULL,
PRIMARY KEY (`idvotoDetalle`),
INDEX `fk_votoDetalle_votacion1_idx` (`idevento` ASC),
INDEX `fk_votoDetalle_usuario1_idx` (`idusuario` ASC),
INDEX `fk_votoDetalle_candidato1_idx` (`idcandidato` ASC),
CONSTRAINT `fk_votoDetalle_usuario1`
FOREIGN KEY (`idusuario`)
REFERENCES `iVoto`.`usuario` (`idusuario`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_votoDetalle_votacion1`
FOREIGN KEY (`idevento`)
REFERENCES `iVoto`.`evento` (`idevento`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_votoDetalle_candidato1`
FOREIGN KEY (`idcandidato`)
REFERENCES `iVoto`.`candidato` (`idcandidato`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
| true |
4ea969cc80485878b072d9876184ab6003a5a28b | SQL | rinunu/hello-go | /flyway/sql/V1__Initial.sql | UTF-8 | 447 | 3.84375 | 4 | [] | no_license | CREATE TABLE sources
(
id INT AUTO_INCREMENT,
title VARCHAR(300),
url VARCHAR(300) CHARSET latin1,
PRIMARY KEY (id),
UNIQUE u1 (url)
);
CREATE TABLE articles
(
id INT AUTO_INCREMENT,
source_id INT,
title VARCHAR(300),
link VARCHAR(300) CHARSET latin1,
description TEXT,
PRIMARY KEY (id),
UNIQUE u1 (link),
CONSTRAINT articles_sources_id_fk FOREIGN KEY (source_id) REFERENCES sources (id)
);
| true |
580ed02271e8e82b0f788e362151d61043745b10 | SQL | pengjiaobyb/PjTest | /xz.sql | UTF-8 | 816 | 2.546875 | 3 | [] | no_license | set names utf8;
drop database if exists fc;
#1、创建库fc
create database fc charset=utf8;
#2、进入fc
use fc;
#3、创建表user
create table user(
uid int primary key auto_increment,
uname varchar(20) not null default '',
upwd varchar(32) not null default '',
phone varchar(20) not null default '',
pic varchar(100) not null default ''
);
#4、添加3条数据
insert into user values(null,'tom','123','13512345678','imgs/1.jpg');
insert into user values(null,'mary','123','13512345678','imgs/2.jpg');
insert into user values(null,'king','123','13512345678','imgs/3.jpg');
insert into user values(null,'lucy','123','13512345678','imgs/4.jpg');
insert into user values(null,'jerry','123','13512345678','imgs/5.jpg');
insert into user values(null,'kate','123','13512345678','imgs/6.jpg');
| true |
bab7d24a93df5ac324caea2ccdc19235bc88a0c6 | SQL | Belen1996/Project2-Team-3 | /models/schema.sql | UTF-8 | 3,290 | 3.296875 | 3 | [] | no_license | DROP DATABASE IF EXISTS user_db;
CREATE DATABASE user_db;
USE user_db;
CREATE TABLE users
-- (
-- id INT AUTO_INCREMENT NOT NULL,
-- User_Name VARCHAR(30) NOT NULL,
-- Pass_word VARCHAR(30) NOT NULL,
-- Email VARCHAR(100) NOT NULL,
-- Cell_Phone VARCHAR(10) NOT NULL,
-- Verified BOOLEAN DEFAULT FALSE,
-- Active BOOLEAN DEFAULT TRUE,
-- PRIMARY KEY(id)
-- );
DROP DATABASE IF EXISTS main_db;
CREATE DATABASE main_db;
USE main_db;
CREATE TABLE calendars
-- (
-- id INT AUTO_INCREMENT NOT NULL,
-- User_Id INT NOT NULL,
-- Repeat_Key INT DEFAULT 0,
-- Event_Type INT NULL,
-- Event_Name VARCHAR(100) NOT NULL,
-- Event_Start_Date VARCHAR(10) NOT NUll,
-- Event_End_Date VARCHAR(10) NOT NULL,
-- Event_Start_Time VARCHAR(10) NOT NUll,
-- Event_End_Time VARCHAR(10) NOT NULL,
-- Event_Info TEXT(1000) NULL,
-- Event_location VARCHAR(255),
-- PRIMARY KEY(id)
-- );
-- CREATE TABLE repeating_calendars
-- (
-- id INT AUTO_INCREMENT NOT NULL,
-- Repeat_Freq INT DEFAULT NULL,
-- Repeat_Length VARCHAR(11) DEFAULT NULL,
-- Repeat_Start_Date VARCHAR(10) NOT NUll,
-- Repeat_End_Date VARCHAR(10) NOT NULL,
-- Repeat_Start_Time VARCHAR(10) NOT NUll,
-- Repeat_End_Time VARCHAR(10) NOT NULL,
-- PRIMARY KEY(id)
-- );
-- CREATE TABLE todos
-- (
-- id INT AUTO_INCREMENT NOT NULL,
-- User_Id INT NOT NULL,
-- Repeat_Key INT DEFAULT 0,
-- Todo_Type INT NULL,
-- Todo_Name VARCHAR(100) NOT NULL,
-- Todo_Start_Time VARCHAR(10) NOT NUll,
-- Todo_End_Time VARCHAR(10) NOT NULL,
-- Todo_Date VARCHAR(10),
-- Todo_Info TEXT(1000) NULL,
-- Todo_location VARCHAR(255),
-- Todo_Status INT(1) DEFAULT 0 NOT NULL,
-- PRIMARY KEY(id)
-- );
-- CREATE TABLE repeating_todos
-- (
-- id INT AUTO_INCREMENT NOT NULL,
-- Repeat_Freq INT DEFAULT NULL,
-- Repeat_Length VARCHAR(11) DEFAULT NULL,
-- Repeat_Start_Date VARCHAR(10) NOT NUll,
-- Repeat_End_Date VARCHAR(10) NOT NULL,
-- Repeat_Start_Time VARCHAR(10) NOT NUll,
-- Repeat_End_Time VARCHAR(10) NOT NULL,
-- PRIMARY KEY(id)
-- );
-- CREATE TABLE shopping_items
-- (
-- id INT AUTO_INCREMENT NOT NULL,
-- User_Id INT NOT NULL,
-- List_Type INT NULL,
-- List_Name VARCHAR(100) NOT NULL,
-- List_Quantity INT NOT NULL,
-- List_Location VARCHAR(255)
-- List_Status INT(1) DEFAULT 0 NOT NULL,
-- PRIMARY KEY(id)
-- );
-- CREATE TABLE lookup_shopping_types
-- (
-- id INT AUTO_INCREMENT NOT NULL,
-- Type_name VARCHAR(50) NOT NULL,
-- Primary Key(id)
-- );
-- CREATE TABLE user_shopping_types
-- (
-- id INT AUTO_INCREMENT NOT NULL,
-- User_Id INT NOT NULL,
-- Type_Id INT NOT NULL,
-- PRIMARY KEY(id)
-- );
-- CREATE TABLE reminders
-- (
-- id INT AUTO_INCREMENT NOT NULL,
-- User_Id INT NOT NULL,
-- Event_Key INT NOT NULL,
-- Do_time VARCHAR(20) NOT NULL,
-- Notification_Type VARCHAR(1) NOT NULL,
-- PRIMARY KEY(id)
-- );
-- CREATE TABLE attendees
-- (
-- id INT AUTO_INCREMENT,
-- User_Id INT NOT NUll,
-- Event_Key INT NOT NULL,
-- Notified INT BOOLEAN DEFAULT false NOT NULL,
-- Accepted INT BOOLEAN DEFAULT false NOT NULL,
-- PRIMARY KEY(id)
-- );
| true |
8dd4602630890a8286b3f43b014f3520c6868728 | SQL | Adam-J-Roberts/Database-Design | /Home Work/HW1.sql | UTF-8 | 824 | 3.75 | 4 | [] | no_license | Adam Roberts
2/13/20
Database HW1
CREATE TABLE Classes (
class TEXT,
type TEXT,
county TEXT,
numGuns INT,
bore INT,
displacement INT,
PRIMARY KEY (class, type)
);
//I assume a class has various types,
and that each country only makes certain types.
CREATE TABLE Ships (
name TEXT,
class TEXT,
launched TEXT,
PRIMARY KEY (name)
);
CREATE TABLE Battles (
name TEXT,
date TEXT,
PRIMARY KEY (name, date)
);
CREATE TABLE Outcomes (
ship TEXT,
battle TEXT,
result TEXT,
PRIMARY KEY (ship, battle)
);
ALTER TABLE Classes DROP bore;
ALTER TABLE Classes ADD yard TEXT;
---------------------------------------
2.4.3 (a-c)
SELECT class, country FROM Classes WHERE bore >= 16;
SELECT name FROM Ships WHERE launched < '1921.01.01';
SELECT ship FROM Outcomes WHERE battle = 'Denmark Strait' AND result = 'sunk';
| true |
150eceaabafe64e97b7673043779bc6acf300b21 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/high/day16/select1612.sql | UTF-8 | 191 | 2.6875 | 3 | [] | no_license |
SELECT timeStamp, temperature
FROM ThermometerObservation
WHERE timestamp>'2017-11-15T16:12:00Z' AND timestamp<'2017-11-16T16:12:00Z' AND SENSOR_ID='6888cd31_0273_4013_abb0_90a42c8225fb'
| true |
a6d6e78c744d66317e0061d50d4a385b1854b9fd | SQL | bojaxz/cs50projects | /bojaxz-cs50-problems-2020-x-movies/12.sql | UTF-8 | 383 | 3.375 | 3 | [] | no_license | -- select movies that Helena star in
select title from movies as m
JOIN stars as s ON m.id = s.movie_id
JOIN people as p ON s.person_id = p.id
where name = "Helena Bonham Carter"
-- compare the results with movies Johnny stars in and merge the similarities
Intersect
select title from movies as m
JOIN stars as s ON m.id = s.movie_id
JOIN people as p ON s.person_id = p.id
where name = "Johnny Depp";
| true |
6fe59cf51ea87fd4bca7597b1d620b9306357c25 | SQL | TheChanec/mcs.repository | /Reporting/iDatix/MCSData/dbo/Views/v_APVPRTaskNotifications.sql | UTF-8 | 1,064 | 3.59375 | 4 | [] | no_license | create view [v_APVPRTaskNotifications] as
select p.name as Process, t.name as Task, r.fullname as Username, count(*) as pending_tasks from [$(Progression)].dbo.taskqueue tq with (nolock)
inner join [$(Progression)].dbo.tasks t on tq.taskid = t.id
inner join [$(Progression)].dbo.processhistory ph with (nolock) on tq.processhistoryid = ph.id
inner join [$(Progression)].dbo.processes p with (nolock) on ph.processid = p.id
inner join [$(Progression)].dbo.tasksubscribers ts with (nolock) on tq.id = ts.QueueID
inner join [$(Progression)].dbo.resources r on ts.subscriberid = r.id and ts.subscribertype = r.subscribertype
where t.typeid in (0,15)
and ph.processid in
('B69C9468-CAC2-4BA3-BA98-BDF4B0F882A6',
'D7D87D26-3469-4DAD-AABB-22D5396EB273',
'903D347D-8C7D-45BC-8548-D70CE3C000A9',
'06FBCA8B-37A5-49F5-A8E4-1E244DAF18FA',
'9C638F34-104B-4C24-ACE8-2FEC53ED2FE2',
'F711086D-07EC-47C0-9F95-E9A3087977D1',
'860FE4FA-D71C-4A1C-9E96-687CE19CBFA1',
'0D231285-0116-48F0-8A32-63B376CC0AC6')
--and (r.fullname <> 'Espeed System')
group by p.name,t.name,r.fullname | true |
0eb3acba6834c838301f52a9c5ed07bb5492ca27 | SQL | nherment/crow | /db/queries/user/fetchUser.query.sql | UTF-8 | 562 | 3.84375 | 4 | [] | no_license | -- $1: email
SELECT
u.id,
u.email,
u.first_name,
u.last_name,
CASE WHEN (u.first_name IS NOT NULL OR u.last_name IS NOT NULL)
THEN
COALESCE(u.first_name, '') || ' ' || COALESCE(u.last_name, '')
ELSE
u.email
END AS full_name,
u.password_hash,
u.password_salt,
u.password_iterations,
u.password_key_length,
u.password_digest,
u.password_needs_changing,
u.active,
u.created_date,
s.token AS session_token,
s.expiry AS session_expiry
FROM users AS u
LEFT JOIN sessions AS s ON s.user_id = u.id
WHERE u.email = $1 | true |
3b26b140673873f69cf6690ec72869d080f768ca | SQL | mrigor87/voting | /src/main/resources/data.sql | UTF-8 | 1,168 | 3.734375 | 4 | [] | no_license | /*create table dish (id integer generated by default as identity, name varchar(255), price double, primary key (id))
create table menu (id integer generated by default as identity, curr_date timestamp, restaurant_id integer, primary key (id))
create table menu_dishes (menu_id integer not null, dishes_id integer not null)
create table restaurant (id integer generated by default as identity, name varchar(255), primary key (id))
create table user (id integer generated by default as identity, name varchar(255), primary key (id))
create table voting (id integer generated by default as identity, rating integer not null, restaurant binary(255), user binary(255), primary key (id))
alter table menu_dishes add constraint UK_6g02saeub38o9u6ig7bf4cjf2 unique (dishes_id)*/
DELETE FROM dish;
DELETE FROM restaurant;
DELETE FROM user;
DELETE FROM voting;
ALTER SEQUENCE global_seq RESTART WITH 100000;
INSERT INTO restaurant (name)
VALUES ('Restaurant 8'),
('Restaurant 2');
INSERT INTO dish (name, price,restaurant_id)
VALUES ('Dish1',2.1,100000),
('Dish2',3.2,100000),
('Dish13',4.3,100000);
INSERT INTO user (name)
VALUES ('user1'),('User2')
| true |
56e14079665866bf4e1dbd12b8f32251758c7016 | SQL | dictybase-docker/dictyuser-schema | /00006_modify-auth-permission-constraint.sql | UTF-8 | 426 | 2.578125 | 3 | [] | no_license | -- +goose Up
-- SQL in this section is executed when the migration is applied.
ALTER TABLE auth_permission
DROP constraint auth_permission_c1,
ADD CONSTRAINT auth_permission_c1 UNIQUE(permission,resource);
-- +goose Down
-- SQL in this section is executed when the migration is rolled back.
ALTER TABLE auth_permission
DROP constraint auth_permission_c1,
ADD CONSTRAINT auth_permission_c1 UNIQUE(permission);
| true |
ba7ee14de762ec2a0d8d82f65562db5c396dd60e | SQL | magnusandy/355DatabaseSQL | /views.sql | UTF-8 | 5,796 | 3.40625 | 3 | [] | no_license | -- VIEW CREATION FOR ALL TABLES
--CLIENTS
CREATE VIEW ns_v_clients AS SELECT
ns_cl_clname,
ns_cl_email,
ns_cl_phonenum,
ns_cl_buildingnum,
ns_cl_buildingname,
ns_cl_streetname,
ns_cl_city,
ns_cl_country,
ns_cl_region,
ns_cl_postalcode
FROM ns_t_clients
;
--ITEMS
CREATE VIEW ns_v_items AS SELECT
ns_i_inumkey,
ns_i_ialphakey,
ns_i_clientkey,
ns_i_iname,
ns_i_iorigin,
ns_i_iformat,
ns_i_isubformat,
ns_i_ischool,
ns_i_isubject,
ns_i_iinsurance,
ns_i_iacquisitiondate,
ns_i_icreationyear,
ns_i_idescription,
ns_i_itsvector
FROM ns_t_items
;
-- ITEM CREATORS
CREATE VIEW ns_v_item_creators AS SELECT
ns_cr_inumkey,
ns_cr_ialphakey,
ns_cr_clientkey,
ns_cr_crname
FROM ns_t_item_creators
;
--MATERIALS
CREATE VIEW ns_v_materials AS SELECT
ns_mat_matname
FROM ns_t_materials
;
--SUB COMPONENTS
CREATE VIEW ns_v_materials_subcomponents AS SELECT
ns_matsub_matname,
ns_matsub_subcomponent
FROM ns_t_materials_subcomponents
;
--ITEM MATERIALS
CREATE VIEW ns_v_item_materials AS SELECT
ns_imat_inumkey,
ns_imat_ialphakey,
ns_imat_clientkey,
ns_imat_matname
FROM ns_t_item_materials
;
--ITEM TRANSACTIONS
CREATE VIEW ns_v_item_transactions AS SELECT
ns_it_inumkey,
ns_it_ialphakey,
ns_it_clientkey,
ns_it_clname,
ns_it_ittype,
ns_it_itdatetime_start,
ns_it_itdatetime_end,
ns_it_itdatetime_returnby,
ns_it_itgross
FROM ns_t_item_transactions
;
--LOCATIONS
CREATE VIEW ns_v_locations AS SELECT
ns_loc_locname,
ns_loc_clientkey,
ns_loc_loctype,
ns_loc_numitems_min,
ns_loc_numitems_max,
ns_loc_locdimensionmetres_height,
ns_loc_locdimensionmetres_length,
ns_loc_locdimensionmetres_width,
ns_loc_loccreationdate,
ns_loc_elocdate_start,
ns_loc_elocdate_end,
ns_loc_iinsurance_total
FROM ns_t_locations;
;
--ITEM LOCATIONS
CREATE VIEW ns_v_item_locations AS SELECT
ns_ilo_inumkey,
ns_ilo_ialphakey,
ns_ilo_clientkey_item,
ns_ilo_locname,
ns_ilo_clientkey_location,
ns_ilo_ilodatetime_start,
ns_ilo_ilodatetime_end
FROM ns_t_item_locations
;
--LOCATION DOORS
CREATE VIEW ns_v_location_doors AS SELECT
ns_lodor_locname_entrance,
ns_lodor_clientkey_entrance,
ns_lodor_locname_exit,
ns_lodor_clientkey_exit
FROM ns_t_location_doors
;
--EXHIBITIONS
CREATE VIEW ns_v_exhibitions AS SELECT
ns_ex_ename,
ns_ex_showdate_start,
ns_ex_showdate_end,
ns_ex_edescription
FROM ns_t_exhibitions
;
--EXHIBITION ITEMS
CREATE VIEW ns_v_exhibition_items AS SELECT
ns_exi_inumkey,
ns_exi_ialphakey,
ns_exi_clientkey,
ns_exi_ename,
ns_exi_showdate_start,
ns_exi_exidate_start,
ns_exi_exidate_end
FROM ns_t_exhibition_items
;
--EXHIBITION LOCATIONS
CREATE VIEW ns_v_exhibition_locations AS SELECT
ns_exl_ename,
ns_exl_showdate_start,
ns_exl_locname,
ns_exl_clientkey,
ns_exl_exldate_start,
ns_exl_exldate_end,
ns_exl_security
FROM ns_t_exhibition_locations
;
-- ITEM COLORS
CREATE VIEW ns_v_item_colors AS SELECT
ns_icol_inumkey,
ns_icol_ialphakey,
ns_icol_clientkey,
ns_icol_icolor
FROM ns_t_item_colors
;
-- VIEW CREATION FROM ASSIGNMENTS AND OTHER USEFUL VIEWS
-- current item location
CREATE VIEW ns_v_current_item_location AS SELECT
ns_ilo_inumkey,
ns_ilo_ialphakey,
ns_ilo_clientkey_item,
ns_ilo_locname,
ns_ilo_clientkey_location,
ns_ilo_ilodatetime_start,
ns_ilo_ilodatetime_end
FROM
ns_t_item_locations
WHERE
ns_ilo_ilodatetime_start <= current_timestamp AND
(ns_ilo_ilodatetime_end >= current_timestamp OR ns_ilo_ilodatetime_end IS NULL)
;
-- currently in storage
CREATE VIEW ns_v_current_items_in_storage AS SELECT
ns_ilo_inumkey,
ns_ilo_ialphakey,
ns_ilo_clientkey_item,
ns_ilo_locname,
ns_ilo_clientkey_location,
ns_ilo_ilodatetime_start,
ns_ilo_ilodatetime_end
FROM
ns_v_current_item_location
WHERE
ns_ilo_locname = 'Storage' OR ns_ilo_locname = 'storage'
;
-- currently not in storage
CREATE VIEW ns_v_current_items_not_in_storage AS SELECT
ns_ilo_inumkey,
ns_ilo_ialphakey,
ns_ilo_clientkey_item,
ns_ilo_locname,
ns_ilo_clientkey_location,
ns_ilo_ilodatetime_start,
ns_ilo_ilodatetime_end
FROM
ns_v_current_item_location
WHERE
ns_ilo_locname != 'Storage' AND
ns_ilo_locname != 'storage'
;
--current exhibitions
CREATE VIEW ns_v_current_exhibitions AS SELECT
ns_ex_ename,
ns_ex_showdate_start,
ns_ex_showdate_end,
ns_ex_edescription
FROM
ns_t_exhibitions
WHERE
ns_ex_showdate_start <= current_timestamp AND
ns_ex_showdate_end >= current_timestamp
;
-- finished exhibitions
CREATE VIEW ns_v_past_exhibitions AS SELECT
ns_ex_ename,
ns_ex_showdate_start,
ns_ex_showdate_end,
ns_ex_edescription
FROM
ns_t_exhibitions
WHERE
ns_ex_showdate_end < current_timestamp
;
-- planned exhibitions
CREATE VIEW ns_v_future_exhibitions AS SELECT
ns_ex_ename,
ns_ex_showdate_start,
ns_ex_showdate_end,
ns_ex_edescription
FROM
ns_t_exhibitions
WHERE
ns_ex_showdate_start > current_timestamp
;
-- key, name, insurance of works in currently storage (also not in storage)
-- name, desc, location, numworks of all exhititions (public_current, public_past, public_future)
-- info public on items in exhibitions sorted by exhibition and name of the work (current, future, past)
-- listing of works SORTED by when they are available for use in a new exhibition and by classification ()
-- additional works that could be added to an exhibition just name of exhibition and number you could add (just make for all exhibitions)
--tsvector stuff?
-- current and future exhibitions, name, dates, max capacity, current num of works
-- query that lists locations a work is/was/will be in between two dates
-- all works found in an exhibition between two dates including, name of work, dates,
-- all the exhibitions that use a location between two dates
-- all borrowed, purchased, sold, rented, etc items
-- items made out of X material
| true |
9cfd849be2cb9e4df19ca29f44cb9ec76e394af1 | SQL | IanDoarn/SQLspace | /table querys/G_BIN_DATA.sql | UTF-8 | 654 | 4.0625 | 4 | [] | no_license | SELECT
p.id,
p.product_number,
p.edi_number,
ps.serial_number,
d.zone || '-' || d.position || '-' || d.shelf as bins
FROM
sms.stock s
LEFT JOIN sms.product p ON s.product_id = p.id
LEFT JOIN bins_v2 d on d.bin_id = s.container_id and s.container_type = 1
LEFT JOIN sms.product_serial ps on ps.id = s.serial_id
WHERE
s.stock_type in (3,4)
and s.inventory_type = 3
and s.location_type = 1
and s.distributor_id = 168
and s.container_type = 1
and d.zone similar to 'G%'
GROUP BY
p.id,
bins,
p.product_number,
p.edi_number,
ps.serial_number
ORDER BY
p.product_number,
ps.serial_number,
p.edi_number,
bins | true |
5b8d9e7953d4c82c91262f46d6a06bda19979fff | SQL | malopes21/ss-orm | /scripts-pra-producao/ScriptsChange-2019-10-13/scripts-02-2019-09-30-webhook.sql | UTF-8 | 2,947 | 3.484375 | 3 | [] | no_license |
-- WebHook
create table WebHook (
id bigint not null auto_increment,
objectId varchar(255),
objectType varchar(255),
token varchar(1000),
type varchar(255),
url varchar(255),
primary key (id)
) ENGINE=InnoDB;
-- inserts para InternalPermissions
insert into InternalPermission (category, description, label, name) values ('WEBHOOK', 'Listar web hooks.', 'List web hooks.', 'LIST_WEBHOOK');
insert into InternalPermission (category, description, label, name) values ('WEBHOOK', 'Editar web hook.', 'Edit web hook.', 'EDIT_WEBHOOK');
insert into InternalPermission (category, description, label, name) values ('WEBHOOK', 'Criar web hook.', 'Create web hook.', 'CREATE_WEBHOOK');
insert into InternalPermission (category, description, label, name) values ('WEBHOOK', 'Remover web hook.', 'Remove web hook.', 'REMOVE_WEBHOOK');
-- inserts para InternalPermissionGroup
insert into InternalPermissionGroup (category, description, label, name) values ('DEVELOPMENT', 'Visualizar Web Hooks.', 'Visualizar Web Hooks', 'WEBHOOK_VISUALIZE');
insert into InternalPermissionGroup (category, description, label, name) values ('DEVELOPMENT', 'Gerenciar Web Hooks.', 'Gerenciar Web Hooks', 'WEBHOOK_MANAGE');
-- inserts para InternalPermissionGroup_InternalPermission
insert into InternalPermissionGroup_InternalPermission (internalPermissionGroups_id, internalPermissions_id)
select ipg.id as internalPermissionGroups_id, ip.id as internalPermissions_id from InternalPermissionGroup ipg, InternalPermission ip
where ipg.name = 'WEBHOOK_VISUALIZE' and ip.name = 'LIST_WEBHOOK';
insert into InternalPermissionGroup_InternalPermission (internalPermissionGroups_id, internalPermissions_id)
select ipg.id as internalPermissionGroups_id, ip.id as internalPermissions_id from InternalPermissionGroup ipg, InternalPermission ip
where ipg.name = 'WEBHOOK_MANAGE' and ip.name = 'LIST_WEBHOOK';
insert into InternalPermissionGroup_InternalPermission (internalPermissionGroups_id, internalPermissions_id)
select ipg.id as internalPermissionGroups_id, ip.id as internalPermissions_id from InternalPermissionGroup ipg, InternalPermission ip
where ipg.name = 'WEBHOOK_MANAGE' and ip.name = 'EDIT_WEBHOOK';
insert into InternalPermissionGroup_InternalPermission (internalPermissionGroups_id, internalPermissions_id)
select ipg.id as internalPermissionGroups_id, ip.id as internalPermissions_id from InternalPermissionGroup ipg, InternalPermission ip
where ipg.name = 'WEBHOOK_MANAGE' and ip.name = 'CREATE_WEBHOOK';
insert into InternalPermissionGroup_InternalPermission (internalPermissionGroups_id, internalPermissions_id)
select ipg.id as internalPermissionGroups_id, ip.id as internalPermissions_id from InternalPermissionGroup ipg, InternalPermission ip
where ipg.name = 'WEBHOOK_MANAGE' and ip.name = 'REMOVE_WEBHOOK';
-- inserts para ManagerRole_InternalPermissionGroup (acho que será melhor setar na tela esses!)
| true |
a7f0b9dbcdb3fe481d9693d65589de3d7f5eb55f | SQL | devarh/otus-mssql-2021-03-PavelGuryev | /HW4/hw_cross_apply_pivot.sql | UTF-8 | 6,057 | 4.25 | 4 | [
"Unlicense"
] | permissive | -- ---------------------------------------------------------------------------
-- Задание - написать выборки для получения указанных ниже данных.
-- ---------------------------------------------------------------------------
USE WideWorldImporters
/*
1. Требуется написать запрос, который в результате своего выполнения
формирует сводку по количеству покупок в разрезе клиентов и месяцев.
В строках должны быть месяцы (дата начала месяца), в столбцах - клиенты.
Клиентов взять с ID 2-6, это все подразделение Tailspin Toys.
Имя клиента нужно поменять так чтобы осталось только уточнение.
Например, исходное значение "Tailspin Toys (Gasport, NY)" - вы выводите только "Gasport, NY".
Дата должна иметь формат dd.mm.yyyy, например, 25.12.2019.
Пример, как должны выглядеть результаты:
-------------+--------------------+--------------------+-------------+--------------+------------
InvoiceMonth | Peeples Valley, AZ | Medicine Lodge, KS | Gasport, NY | Sylvanite, MT | Jessie, ND
-------------+--------------------+--------------------+-------------+--------------+------------
01.01.2013 | 3 | 1 | 4 | 2 | 2
01.02.2013 | 7 | 3 | 4 | 2 | 1
-------------+--------------------+--------------------+-------------+--------------+------------
*/
WITH cust AS
(
SELECT
CustomerID
, SUBSTRING(CustomerName
, CHARINDEX('(', CustomerName) + 1
, CHARINDEX(')', CustomerName) - CHARINDEX('(', CustomerName) - 1
) ShortName
FROM Sales.Customers
WHERE
CustomerID between 2 and 6
)
SELECT
CONVERT(varchar(10), invMonth, 104) as InvoiceMonth
, [Peeples Valley, AZ], [Medicine Lodge, KS], [Gasport, NY], [Sylvanite, MT], [Jessie, ND]
FROM
(
SELECT
DATEFROMPARTS(YEAR(i.InvoiceDate),MONTH(i.InvoiceDate),1) AS invMonth
, c.ShortName
, i.InvoiceID
FROM Sales.Invoices i
JOIN cust c ON i.CustomerID = c.CustomerID
) AS src
PIVOT(COUNT(InvoiceID) FOR ShortName IN
([Sylvanite, MT], [Peeples Valley, AZ], [Medicine Lodge, KS], [Gasport, NY], [Jessie, ND])
) AS p
ORDER BY
invMonth;
/*
2. Для всех клиентов с именем, в котором есть "Tailspin Toys"
вывести все адреса, которые есть в таблице, в одной колонке.
Пример результата:
----------------------------+--------------------
CustomerName | AddressLine
----------------------------+--------------------
Tailspin Toys (Head Office) | Shop 38
Tailspin Toys (Head Office) | 1877 Mittal Road
Tailspin Toys (Head Office) | PO Box 8975
Tailspin Toys (Head Office) | Ribeiroville
----------------------------+--------------------
*/
SELECT
custName
, AddressLine
FROM
(
SELECT
c.CustomerName AS custName
, c.DeliveryAddressLine1
, c.DeliveryAddressLine2
, c.PostalAddressLine1
, c.PostalAddressLine2
FROM Sales.Customers c
WHERE
CustomerName LIKE '%Tailspin Toys%'
)src
UNPIVOT (AddressLine FOR addr IN (DeliveryAddressLine1, DeliveryAddressLine2, PostalAddressLine1, PostalAddressLine2)) AS rslt;
/*
3. В таблице стран (Application.Countries) есть поля с цифровым кодом страны и с буквенным.
Сделайте выборку ИД страны, названия и ее кода так,
чтобы в поле с кодом был либо цифровой либо буквенный код.
Пример результата:
--------------------------------
CountryId | CountryName | Code
----------+-------------+-------
1 | Afghanistan | AFG
1 | Afghanistan | 4
3 | Albania | ALB
3 | Albania | 8
----------+-------------+-------
*/
SELECT
CountryID
, CountryName
, Code
FROM
(
SELECT
CountryID
, CountryName
, IsoAlpha3Code
, CAST(IsoNumericCode as nvarchar(3)) AS IsoNumericCode
FROM Application.Countries
)src
UNPIVOT (Code FOR someCode IN (IsoAlpha3Code, IsoNumericCode)) AS rslt;
/*
4. Выберите по каждому клиенту два самых дорогих товара, которые он покупал.
В результатах должно быть ид клиета, его название, ид товара, цена, дата покупки.
*/
/*
В запросе использовал максимальную дату продажи, так как если выводить даты, то текущий вариант может выводить
не 2 товара, а один с разными датами. Данную проблему можно решить использовав оконные функции, как показано
во втором варианте запроса
*/
SELECT
c.CustomerID
, c.CustomerName
, t.StockItemID
, t.UnitPrice
, t.OrderDate
FROM Sales.Customers c
CROSS APPLY
(
SELECT TOP 2 WITH TIES
ol.StockItemID
, ol.UnitPrice
, MAX(o.OrderDate) as OrderDate
FROM
Sales.Orders o
JOIN Sales.OrderLines ol ON o.OrderID = ol.OrderID
WHERE
o.CustomerID = c.CustomerID
GROUP BY
ol.StockItemID
, ol.UnitPrice
ORDER BY
UnitPrice DESC
)t
--вариант с оконной функцией
SELECT
c.CustomerID
, c.CustomerName
, t.StockItemID
, t.UnitPrice
, t.OrderDate
FROM Sales.Customers c
CROSS APPLY
(
SELECT
ol.StockItemID
, ol.UnitPrice
, o.OrderDate
, DENSE_RANK() OVER (PARTITION BY o.CustomerID ORDER BY UnitPrice DESC) AS npp
FROM
Sales.Orders o
JOIN Sales.OrderLines ol ON o.OrderID = ol.OrderID
WHERE
o.CustomerID = c.CustomerID
)t
WHERE
t.npp < 3 | true |
ddaf17b6526c9264a8cbd7b0c946f65a4f0365da | SQL | alaaebeed/Pharmacy-System | /Pharmacy.sql | UTF-8 | 6,091 | 2.765625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.6.6deb5
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Oct 20, 2018 at 01:38 AM
-- Server version: 5.7.23-0ubuntu0.18.04.1
-- PHP Version: 7.2.7-0ubuntu0.18.04.2
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: `Pharmacy`
--
-- --------------------------------------------------------
--
-- Table structure for table `activirylog`
--
CREATE TABLE `activirylog` (
`name` varchar(30) NOT NULL,
`date and time` varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `activirylog`
--
INSERT INTO `activirylog` (`name`, `date and time`) VALUES
('alaaEbeed', '18/10/2018 21:40:41'),
('alaaebeed', '18/10/2018 23:14:45'),
('alaaebeed', '18/10/2018 23:15:14'),
('alaaebeed', '19/10/2018 04:38:58'),
('alaaebeed', '19/10/2018 17:53:23'),
('alaaebeed', '19/10/2018 17:56:09'),
('alaaebeed', '19/10/2018 20:25:14'),
('alaaebeed', '19/10/2018 20:31:02'),
('alaaebeed', '19/10/2018 20:44:46'),
('alaaebeed', '19/10/2018 21:21:22'),
('alaaebeed', '19/10/2018 23:57:23'),
('alaaebeed', '19/10/2018 23:59:01'),
('alaaebeed', '20/10/2018 00:05:54'),
('alaaebeed', '20/10/2018 00:22:55');
-- --------------------------------------------------------
--
-- Table structure for table `Bill`
--
CREATE TABLE `Bill` (
`id` int(11) NOT NULL,
`cureCode` int(20) NOT NULL,
`cureName` varchar(20) NOT NULL,
`amount` int(20) NOT NULL,
`rPrice` int(20) NOT NULL,
`tPrice` int(20) NOT NULL,
`date` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Bill`
--
INSERT INTO `Bill` (`id`, `cureCode`, `cureName`, `amount`, `rPrice`, `tPrice`, `date`) VALUES
(12, 321, 'antiflu', 60, 23, 24, '20/10/2018 00:26:15'),
(13, 123, 'florest', 7, 19, 20, '20/10/2018 00:26:39');
-- --------------------------------------------------------
--
-- Table structure for table `CureInfo`
--
CREATE TABLE `CureInfo` (
`code` int(20) NOT NULL,
`cureName` varchar(50) NOT NULL,
`companyName` varchar(50) NOT NULL,
`distributerName` varchar(50) NOT NULL,
`distributerNumber` int(10) NOT NULL,
`amount` int(10) NOT NULL,
`tabsNumber` int(10) NOT NULL,
`expireDate` date NOT NULL,
`retialPrice` int(20) NOT NULL,
`totalPrice` int(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `CureInfo`
--
INSERT INTO `CureInfo` (`code`, `cureName`, `companyName`, `distributerName`, `distributerNumber`, `amount`, `tabsNumber`, `expireDate`, `retialPrice`, `totalPrice`) VALUES
(123, 'florest', 'farmaco', 'adam', 10001001, 20, 7, '2018-10-19', 19, 20),
(321, 'antiflu', 'pharmaco', 'nadeen', 1000434, 0, 0, '1970-01-01', 23, 24);
-- --------------------------------------------------------
--
-- Table structure for table `salesReview`
--
CREATE TABLE `salesReview` (
`cureCode` int(11) NOT NULL,
`cureName` varchar(20) NOT NULL,
`amount` int(20) NOT NULL,
`rPrice` int(20) NOT NULL,
`tPrice` int(20) NOT NULL,
`date` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `salesReview`
--
INSERT INTO `salesReview` (`cureCode`, `cureName`, `amount`, `rPrice`, `tPrice`, `date`) VALUES
(321, 'antiflu', -6, 23, 24, '19/10/2018 18:17:55'),
(123, 'florest', 95, 19, 20, '19/10/2018 18:36:23'),
(123, 'florest', 0, 19, 20, '19/10/2018 18:45:46'),
(321, 'antiflu', 0, 23, 24, '19/10/2018 18:45:52'),
(321, 'antiflu', 0, 23, 24, '19/10/2018 18:45:57'),
(321, 'antiflu', 0, 23, 24, '19/10/2018 18:45:59'),
(123, 'florest', 0, 19, 20, '19/10/2018 23:59:41'),
(321, 'antiflu', 0, 23, 24, '19/10/2018 23:59:49'),
(123, 'florest', 1, 19, 20, '20/10/2018 00:00:08'),
(321, 'florest', 1, 19, 20, '20/10/2018 00:00:17'),
(321, 'florest', 1, 19, 20, '20/10/2018 00:00:21'),
(321, 'antiflu', 2, 23, 24, '20/10/2018 00:00:39'),
(123, 'florest', 1, 19, 20, '20/10/2018 00:00:53'),
(321, 'antiflu', 1, 23, 24, '20/10/2018 00:01:09'),
(123, 'florest', 1, 19, 20, '20/10/2018 00:01:18'),
(1231, 'florest', 1, 19, 20, '20/10/2018 00:25:57'),
(1231, 'florest', 1, 19, 20, '20/10/2018 00:26:03'),
(321, 'antiflu', 60, 23, 24, '20/10/2018 00:26:15'),
(123, 'florest', 7, 19, 20, '20/10/2018 00:26:39');
-- --------------------------------------------------------
--
-- Table structure for table `Users`
--
CREATE TABLE `Users` (
`id` int(30) NOT NULL,
`firstName` varchar(60) NOT NULL,
`lastName` varchar(60) NOT NULL,
`userName` varchar(60) NOT NULL,
`psswd` varchar(60) NOT NULL,
`phoneNumber` int(60) NOT NULL,
`personalId` int(60) NOT NULL,
`address` varchar(60) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Users`
--
INSERT INTO `Users` (`id`, `firstName`, `lastName`, `userName`, `psswd`, `phoneNumber`, `personalId`, `address`) VALUES
(2, 'Alaa', 'ebeed', 'alaaEbeed', 'abc123', 1001102, 321312, 'fasal '),
(9, 'Alaa', 'ebeed', 'alaaEbeed', '123', 321312, 321321, 'fsdafsd'),
(10, 'alaa', 'Fares', 'AlaaFares', '123', 1001932723, 213543534, 'Alharam ST');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `Bill`
--
ALTER TABLE `Bill`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `CureInfo`
--
ALTER TABLE `CureInfo`
ADD PRIMARY KEY (`code`),
ADD UNIQUE KEY `code` (`code`);
--
-- Indexes for table `Users`
--
ALTER TABLE `Users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `Bill`
--
ALTER TABLE `Bill`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- AUTO_INCREMENT for table `Users`
--
ALTER TABLE `Users`
MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
/*!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 |
d2cc9954ef24f4481ddf60a241550bb1073c6137 | SQL | Amankr113114/Portfolio_Projects | /covid analysis 2021.sql | UTF-8 | 5,219 | 3.828125 | 4 | [] | no_license | SELECT *
FROM PortfolioProject..CovidDeaths$
WHERE continent IS not null
ORDER BY 3,4
--SELECT *
--FROM PortfolioProject..CovidVaccination$
--ORDER BY 3,4
SELECT location,date,total_cases,new_cases,total_deaths, population
FROM PortfolioProject..CovidDeaths$
ORDER BY 1,2
--Looking at total cases vs total deaths
--shows likelihood of dying if you contact covid in India
SELECT location,date,total_cases,total_deaths,(total_deaths/total_cases)*100 AS DeathPercentage
FROM PortfolioProject..CovidDeaths$
WHERE location like 'India'
ORDER BY 1,2
--Looking at Total Cases vs Population
--Shows what percentage of population got covid
SELECT location,date,total_cases,population,(total_cases/population)*100 AS DeathPercentage1
FROM PortfolioProject..CovidDeaths$
--WHERE location like 'India'
ORDER BY 1,2
-- Looking at countries with highest Infection Rate compared to population
SELECT location,MAX(total_cases) AS HigestInfectionCount,population,(MAX(total_cases)/population)*100 AS InfectedPopulation
FROM PortfolioProject..CovidDeaths$
GROUP BY location,population
ORDER BY InfectedPopulation DESC
--Showing Countries with Highest Death Count per Population
SELECT location,MAX(CAST(total_deaths AS int)) AS HighestDeathCount
FROM PortfolioProject..CovidDeaths$
WHERE continent IS null
GROUP BY location
ORDER BY HighestDeathCount DESC
--Letsbreak thngs down by continent
--Showing the continent with Highest death count per population
SELECT continent, MAX(CAST(total_deaths AS int)) AS HighestDeathCount
FROM PortfolioProject..CovidDeaths$
WHERE continent IS not null
GROUP BY continent
ORDER BY HighestDeathCount DESC
--Global Numbers
SELECT date, sum(new_cases) AS total_cases ,SUM(CAST(new_deaths AS int)) AS total_deaths ,SUM(CAST(new_deaths AS int))/sum(new_cases)*100 AS DeathPercentage
FROM PortfolioProject..CovidDeaths$
WHERE continent IS not null
GROUP BY date
ORDER BY 1,2
--Total deaths and Total cases
SELECT sum(new_cases) AS total_cases ,SUM(CAST(new_deaths AS int)) AS total_deaths ,SUM(CAST(new_deaths AS int))/sum(new_cases)*100 AS DeathPercentage
FROM PortfolioProject..CovidDeaths$
WHERE continent IS not null
--GROUP BY date
ORDER BY 1,2
--joining both table covid death and covid vaccinations
SELECT *
FROM PortfolioProject..CovidDeaths$ d
JOIN PortfolioProject..CovidVaccination$ v
On d.location = v.location
and d.date = v.date
--looking at Total Population vs Vaccination
SELECT d.continent,d.location,d.date,d.population,v.new_vaccinations
FROM PortfolioProject..CovidDeaths$ d
JOIN PortfolioProject..CovidVaccination$ v
On d.location = v.location
and d.date = v.date
WHERE d.continent IS not null
ORDER BY 2,3
--or
SELECT d.continent,d.location,d.date,d.population,v.new_vaccinations,SUM(CONVERT(INT,v.new_vaccinations)) OVER (Partition by d.location)
FROM PortfolioProject..CovidDeaths$ d
JOIN PortfolioProject..CovidVaccination$ v
On d.location = v.location
and d.date = v.date
WHERE d.continent IS not null
ORDER BY 2,3
SELECT d.continent,d.location,d.date,d.population,v.new_vaccinations,SUM(CONVERT(INT,v.new_vaccinations)) OVER (Partition by d.location ORDER BY d.location)
FROM PortfolioProject..CovidDeaths$ d
JOIN PortfolioProject..CovidVaccination$ v
On d.location = v.location
and d.date = v.date
WHERE d.continent IS not null
ORDER BY 2,3
--use CTE
WITH PopvsVac (continent,location,date,population,new_vaccination,RollingPeopleVaccinated)
AS
(
SELECT d.continent,d.location,d.date,d.population,v.new_vaccinations,SUM(CONVERT(INT,v.new_vaccinations)) OVER (Partition by d.location ORDER BY d.location,d.date) AS RollingPeopleVaccinated
FROM PortfolioProject..CovidDeaths$ d
JOIN PortfolioProject..CovidVaccination$ v
On d.location = v.location
and d.date = v.date
WHERE d.continent IS not null
--ORDER BY 2,3
)
SELECT *,(RollingPeopleVaccinated/population)*100 AS RPC
FROM PopvsVac
--TEMP TABLE
DROP TABLE IF EXISTS #PercentpopulationVaccinated
CREATE TABLE #PercentpopulationVaccinated
(
Continent nvarchar(255),
Location nvarchar(255),
Date datetime,
Population numeric,
New_vaccinations numeric,
RollingPeopleVaccinated numeric
)
INSERT INTO #PercentpopulationVaccinated
SELECT d.continent,d.location,d.date,d.population,v.new_vaccinations,SUM(CONVERT(float,v.new_vaccinations)) OVER (Partition by d.location ORDER BY d.location,d.date) AS RollingPeopleVaccinated
FROM PortfolioProject..CovidDeaths$ d
JOIN PortfolioProject..CovidVaccination$ v
On d.location = v.location
and d.date = v.date
SELECT *,(RollingPeopleVaccinated/population)*100 AS RPC
FROM #PercentpopulationVaccinated
--creating view to store data for later visualization
CREATE View PercentPopulationVaccinated1 as
SELECT d.continent,d.location,d.date,d.population,v.new_vaccinations,SUM(CONVERT(INT,v.new_vaccinations))
OVER (Partition by d.location ORDER BY d.location,d.date) AS RollingPeopleVaccinated
FROM PortfolioProject..CovidDeaths$ d
JOIN PortfolioProject..CovidVaccination$ v
On d.location = v.location
and d.date = v.date
WHERE d.continent IS not null
SELECT *
FROM PercentPopulationVaccinated1 | true |
a071759c7f277979a044fc3eab3e8903da7cab42 | SQL | allyvio/appinves | /public/db/provinces.sql | UTF-8 | 4,107 | 2.578125 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 01 Nov 2019 pada 07.52
-- Versi server: 10.1.37-MariaDB
-- Versi PHP: 7.2.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `ppl_ecommerce`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `provinces`
--
CREATE TABLE `provinces` (
`id` bigint(20) UNSIGNED NOT NULL,
`province_id` int(10) UNSIGNED NOT NULL,
`title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data untuk tabel `provinces`
--
INSERT INTO `provinces` (`id`, `province_id`, `title`, `created_at`, `updated_at`) VALUES
(1, 1, 'Bali', '2019-10-22 07:50:11', '2019-10-22 07:50:11'),
(2, 2, 'Bangka Belitung', '2019-10-22 07:50:12', '2019-10-22 07:50:12'),
(3, 3, 'Banten', '2019-10-22 07:50:12', '2019-10-22 07:50:12'),
(4, 4, 'Bengkulu', '2019-10-22 07:50:13', '2019-10-22 07:50:13'),
(5, 5, 'DI Yogyakarta', '2019-10-22 07:50:14', '2019-10-22 07:50:14'),
(6, 6, 'DKI Jakarta', '2019-10-22 07:50:14', '2019-10-22 07:50:14'),
(7, 7, 'Gorontalo', '2019-10-22 07:50:14', '2019-10-22 07:50:14'),
(8, 8, 'Jambi', '2019-10-22 07:50:15', '2019-10-22 07:50:15'),
(9, 9, 'Jawa Barat', '2019-10-22 07:50:16', '2019-10-22 07:50:16'),
(10, 10, 'Jawa Tengah', '2019-10-22 07:50:17', '2019-10-22 07:50:17'),
(11, 11, 'Jawa Timur', '2019-10-22 07:50:18', '2019-10-22 07:50:18'),
(12, 12, 'Kalimantan Barat', '2019-10-22 07:50:19', '2019-10-22 07:50:19'),
(13, 13, 'Kalimantan Selatan', '2019-10-22 07:50:20', '2019-10-22 07:50:20'),
(14, 14, 'Kalimantan Tengah', '2019-10-22 07:50:21', '2019-10-22 07:50:21'),
(15, 15, 'Kalimantan Timur', '2019-10-22 07:50:22', '2019-10-22 07:50:22'),
(16, 16, 'Kalimantan Utara', '2019-10-22 07:50:22', '2019-10-22 07:50:22'),
(17, 17, 'Kepulauan Riau', '2019-10-22 07:50:23', '2019-10-22 07:50:23'),
(18, 18, 'Lampung', '2019-10-22 07:50:24', '2019-10-22 07:50:24'),
(19, 19, 'Maluku', '2019-10-22 07:50:25', '2019-10-22 07:50:25'),
(20, 20, 'Maluku Utara', '2019-10-22 07:50:26', '2019-10-22 07:50:26'),
(21, 21, 'Nanggroe Aceh Darussalam (NAD)', '2019-10-22 07:50:27', '2019-10-22 07:50:27'),
(22, 22, 'Nusa Tenggara Barat (NTB)', '2019-10-22 07:50:28', '2019-10-22 07:50:28'),
(23, 23, 'Nusa Tenggara Timur (NTT)', '2019-10-22 07:50:28', '2019-10-22 07:50:28'),
(24, 24, 'Papua', '2019-10-22 07:50:30', '2019-10-22 07:50:30'),
(25, 25, 'Papua Barat', '2019-10-22 07:50:33', '2019-10-22 07:50:33'),
(26, 26, 'Riau', '2019-10-22 07:50:33', '2019-10-22 07:50:33'),
(27, 27, 'Sulawesi Barat', '2019-10-22 07:50:34', '2019-10-22 07:50:34'),
(28, 28, 'Sulawesi Selatan', '2019-10-22 07:50:35', '2019-10-22 07:50:35'),
(29, 29, 'Sulawesi Tengah', '2019-10-22 07:50:39', '2019-10-22 07:50:39'),
(30, 30, 'Sulawesi Tenggara', '2019-10-22 07:50:39', '2019-10-22 07:50:39'),
(31, 31, 'Sulawesi Utara', '2019-10-22 07:50:41', '2019-10-22 07:50:41'),
(32, 32, 'Sumatera Barat', '2019-10-22 07:50:42', '2019-10-22 07:50:42'),
(33, 33, 'Sumatera Selatan', '2019-10-22 07:50:44', '2019-10-22 07:50:44'),
(34, 34, 'Sumatera Utara', '2019-10-22 07:50:44', '2019-10-22 07:50:44');
--
-- Indexes for dumped tables
--
--
-- Indeks untuk tabel `provinces`
--
ALTER TABLE `provinces`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT untuk tabel yang dibuang
--
--
-- AUTO_INCREMENT untuk tabel `provinces`
--
ALTER TABLE `provinces`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35;
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 |
3857bec26657dfab0b6c57a8b1030ba75a2efd2f | SQL | Shamzic/BDD_project | /projet/fonction1.sql | UTF-8 | 2,457 | 3.546875 | 4 | [] | no_license | /* Simon HAMERY : simon.hamery2@etu.unistra.fr
Fonction qui convertit au format json les informations d’une vidéo.
L'id de la vidéo est donné en paramètre.
Comment appeler cette fonction :
SQL> @fonction1.sql
SQL> variable toto varchar2(500);
SQL> call conv_video_json(X) into :toto; //X étant l'id de vidéo...
SQL> print toto;
Exemple d'affichage de la vidéo 1 :
{
nom_vid : Super-Chats,
descr_vid : Voici des chatons fous,
duree_vid : 30,
anneeDif_vid : 01-JAN-16,
dateFinDif_vid : 01-JAN-17,
boolMultiLang_vid : Y,
formatLang_vid : SMALL,
nbJourReplay_vid : 10,
id_categ : 1,
pays : FRANCE,
id_ems : 4,
numero_episode : 1
}
*/
set serveroutput on format wrapped;
CREATE OR REPLACE FUNCTION conv_video_json(id_video INTEGER)
RETURN VARCHAR2 AS
v_nom_vid varchar(25) ;
v_descr_vid varchar2(60) ;
v_duree_vid number(4) ;
v_anneeDif_vid date ;
v_dateFinDif_vid date ;
v_boolMultiLang_vid CHAR(1) ; /* 'Y' ou 'N' */
v_formatLang_vid varchar2(6) ;
v_nbJourReplay_vid number(3) ;
v_id_categ number(2) ;
v_pays varchar2(15) ;
v_id_ems number(2);
v_numero_episode number(2) ;
v_retour varchar2(500) := '';
test number(3);
BEGIN
SELECT count(*) into test from video where id_vid=id_video;
IF ( test > 0)
THEN
SELECT
nom_vid,
descr_vid,
duree_vid,
anneeDif_vid,
dateFinDif_vid,
boolMultiLang_vid,
formatLang_vid,
nbJourReplay_vid,
id_categ,
pays,
id_ems,
numero_episode
INTO
v_nom_vid,
v_descr_vid,
v_duree_vid,
v_anneeDif_vid,
v_dateFinDif_vid,
v_boolMultiLang_vid,
v_formatLang_vid,
v_nbJourReplay_vid,
v_id_categ,
v_pays,
v_id_ems,
v_numero_episode
from video where id_vid=id_video;
select '{'||chr(10)||' nom_vid : '||v_nom_vid||',
'||'descr_vid : '||v_descr_vid||',
'||'duree_vid : '||v_duree_vid||',
'||'anneeDif_vid : '||v_anneeDif_vid||',
'||'dateFinDif_vid : '||v_dateFinDif_vid||',
'||'boolMultiLang_vid : '||v_boolMultiLang_vid||',
'||'formatLang_vid : '||v_formatLang_vid||',
'||'nbJourReplay_vid : '||v_nbJourReplay_vid||',
'||'id_categ : '||v_id_categ||',
'||'pays : '||v_pays||',
'||'id_ems : '||v_id_ems||',
'||'numero_episode : '||v_numero_episode||chr(10)||'}' into v_retour from dual;
return v_retour;
ELSE
dbms_output.put_line('Video inconnue au bataillon !');
END IF;
END;
/
show errors function conv_video_json;
| true |
668cc377d3878e270b8c02b4f90278399523c94a | SQL | btownshend/pyTecan | /RobotDB/mkrobot.sql | UTF-8 | 5,889 | 3.6875 | 4 | [] | no_license | -- Make database on gcloud mysql for robot data
-- Almost identical to SQLLITE database (since it will be synced from there)
-- but: doesn't include synctime columns used to drive movement from robot to master
-- flags supports sync from master back to robot
create database robot;
use robot;
-- An experiment -- a pass through a particular program with a fixed set of plates
-- May be made up of multiple runs
create table expts (
expt integer primary key auto_increment,
complete boolean not null -- True after run is complete (log_endrun processed)
);
-- Header for a run (which is actually a parse of one logfile -- multiple runs could make up a single experiment
-- Inserted,updated on robot only, read-only on master
create table runs(
run integer primary key auto_increment,
program integer not null, foreign key(program) references programs(program),
logfile varchar(50),
starttime timestamp not null default current_timestamp,
endtime timestamp null, -- time of last log entry (or null if not completely parsed)
lineno integer default null, -- last (or current) line processed in log
firstline integer default null, -- first line processed in log
expt integer, foreign key(expt) references expts(expt), -- which expt this run is part of
logheader varchar(100) not null -- message from beginning of log (program names, lines planned to execute)
status varchar(50) default null -- Message from last log_status
);
-- Flags for a run
-- Inserted on either robot or master, never updated (just add a later record instead)
create table flags(
flag integer primary key auto_increment,
run integer not null,
name varchar(50) not null,
value integer,
lastupdate timestamp not null,
pulltime timestamp null, -- Time this record was last pulled to robot
foreign key(run) references runs(run) on delete cascade
);
-- Measurements of Vols for a run
-- Inserted on robot only, read-only on master, never updated
-- Volume measurement occuring during a particular program operation
create table vols(
vol integer primary key auto_increment,
run integer not null,
op integer not null, foreign key(op) references ops(op) on delete cascade, -- not null
estvol float not null, -- estimated volume based on prior operations and measurements
gemvolume float, -- Volume as reported by Gemini
volume float, -- gemvolume converted to true volume
height integer, -- tip height as reported by Gemini (in native units of 1/10 mm)
submerge integer, -- submerge depth
zmax integer, -- zmax - bottom of tube
zadd integer, -- zadd - extra height needed after submerge (to permit tracking during aspirate?)
measured timestamp not null default current_timestamp, -- when was measurement made
foreign key(run) references runs(run) on delete cascade
);
-- Programs
-- inserted during build of progam (generation time)
create table programs(
program integer primary key auto_increment,
name varchar(50) not null,
gentime not null timestamp,
checksum varchar(8) not null,
gitlabel varchar(8) not null,
totaltime float default null, -- Total execution time estimate in minutes
complete boolean not null, -- True if all data for this program is in database
unique(name,gentime)
);
create table samples (
sample integer primary key auto_increment,
program integer not null, foreign key(program) references programs(program) on delete cascade,
plate varchar(20) not null,
well varchar(4) not null,
name varchar(50) not null,
unique(program,plate,well)
);
create table liquidclasses (
lc integer primary key auto_increment,
name varchar(50) not null
);
-- Pippette operations
-- for washes: sample, lc, and volume are null
-- some denormalization as ops.program must be the same as ops.sample.program
create table ops (
op integer primary key auto_increment,
program integer not null, foreign key(program) references programs(program) on delete cascade,
sample integer not null, foreign key(sample) references samples(sample) on delete cascade,
cmd varchar(20) not null,
lineno integer not null, -- line number in program
elapsed float not null, -- elapsed time in program
tip integer not null, -- which tip was used (1..4)
lc integer not null, foreign key(lc) references liquidclasses(lc),
volchange float not null, -- increase/decrease in volume (+ for dispense, -ve for aspirate, 0 for LD)
clean boolean
);
CREATE OR REPLACE VIEW v_ops AS
SELECT p.program,p.name pgmname,o.lineno,o.elapsed,o.op,s.sample, s.name,s.plate,s.well,o.cmd,o.tip,lc.name lc,o.volchange,o.clean
FROM ops o, samples s, liquidclasses lc, programs p
WHERE o.sample=s.sample AND s.program=p.program AND o.lc=lc.lc
order by o.lineno;
CREATE OR REPLACE VIEW v_vols AS
SELECT v.run, p.program, p.name pgmname,o.lineno,o.elapsed,v.measured,o.op,s.sample,s.name,s.plate,s.well,o.cmd,o.tip,lc.name lc,o.volchange, v.estvol, v.volume obsvol,v.gemvolume, v.height,v.submerge,v.zmax,v.zadd
FROM vols v, ops o, samples s, liquidclasses lc, programs p
WHERE v.op=o.op AND o.sample=s.sample AND s.program=p.program AND o.lc=lc.lc
order by o.lineno;
CREATE OR REPLACE VIEW v_tips AS
SELECT * FROM v_ops ORDER BY tip,lineno;
create or replace view v_history as
select r.run,s.program,s.sample,s.plate,s.well,s.name,o.op,o.cmd,o.lineno,o.tip,o.volchange,o.elapsed,v.vol,v.volume,v.measured,v.estvol
from runs r
JOIN samples s ON r.program=s.program
JOIN ops o ON s.sample=o.sample
left join vols v on v.op=o.op AND v.run=r.run
where (v.measured is not null or o.cmd!='Detect_Liquid')
order by r.run,s.plate, s.well, o.lineno;
| true |
ee55002025c73b551075ae4052bab35d9bfdb869 | SQL | kathleentabbada/merchant | /merchantDB.sql | UTF-8 | 3,204 | 3.390625 | 3 | [] | no_license | -- --------------------------------------------------------
-- Host: 127.0.0.1
-- Server version: 10.4.6-MariaDB - mariadb.org binary distribution
-- Server OS: Win64
-- HeidiSQL Version: 9.5.0.5196
-- --------------------------------------------------------
/*!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' */;
-- Dumping database structure for merchantdb
DROP DATABASE IF EXISTS `merchantdb`;
CREATE DATABASE IF NOT EXISTS `merchantdb` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `merchantdb`;
-- Dumping structure for table merchantdb.enrolledmerchant_tbl
DROP TABLE IF EXISTS `enrolledmerchant_tbl`;
CREATE TABLE IF NOT EXISTS `enrolledmerchant_tbl` (
`enmerch_id` varchar(20) NOT NULL,
`merch_id` varchar(20) DEFAULT NULL,
`accountnumber` varchar(50) DEFAULT NULL,
PRIMARY KEY (`enmerch_id`),
KEY `merch_id` (`merch_id`),
CONSTRAINT `enrolledmerchant_tbl_ibfk_1` FOREIGN KEY (`merch_id`) REFERENCES `merchant_tbl` (`merch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Data exporting was unselected.
-- Dumping structure for table merchantdb.hibernate_sequence
DROP TABLE IF EXISTS `hibernate_sequence`;
CREATE TABLE IF NOT EXISTS `hibernate_sequence` (
`next_not_cached_value` bigint(21) NOT NULL,
`minimum_value` bigint(21) NOT NULL,
`maximum_value` bigint(21) NOT NULL,
`start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
`increment` bigint(21) NOT NULL COMMENT 'increment value',
`cache_size` bigint(21) unsigned NOT NULL,
`cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed',
`cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
) ENGINE=InnoDB SEQUENCE=1;
-- Data exporting was unselected.
-- Dumping structure for table merchantdb.merchant_tbl
DROP TABLE IF EXISTS `merchant_tbl`;
CREATE TABLE IF NOT EXISTS `merchant_tbl` (
`merch_id` varchar(20) NOT NULL,
`merch_name` varchar(50) DEFAULT NULL,
PRIMARY KEY (`merch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Data exporting was unselected.
-- Dumping structure for table merchantdb.transaction_tbl
DROP TABLE IF EXISTS `transaction_tbl`;
CREATE TABLE IF NOT EXISTS `transaction_tbl` (
`trans_id` varchar(20) NOT NULL,
`merch_id` varchar(20) DEFAULT NULL,
`amount` double NOT NULL,
`accountnumber` varchar(20) NOT NULL,
`trans_date` date NOT NULL,
PRIMARY KEY (`trans_id`),
KEY `merch_id` (`merch_id`),
CONSTRAINT `transaction_tbl_ibfk_1` FOREIGN KEY (`merch_id`) REFERENCES `merchant_tbl` (`merch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Data exporting was unselected.
/*!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 |
2fa60a6657fdab2a481a6e6bf689fdbddfbc743d | SQL | chriskov/data_analytics | /hw2.sql | UTF-8 | 840 | 3.828125 | 4 | [] | no_license |
SELECT 'ФИО: Чернова Кристина Сергеевна';
-- 1.2
SELECT * FROM links WHERE imdbid LIKE '%42' AND movieid BETWEEN 100 AND 1000 LIMIT 10;
-- 2.1
SELECT IMDBID FROM LINKS INNER JOIN ratings ON links.movieid=ratings.movieid WHERE ratings.rating=5 LIMIT 10;
-- 3.1
SELECT COUNT(*) FROM LINKS LEFT JOIN ratings ON links.movieid=ratings.movieid WHERE ratings.rating IS NULL;
-- 3.2
SELECT userid, avg(rating) AS average_rating FROM ratings GROUP BY userid having AVG(rating) > 3.5 ORDER BY 2 DESC LIMIT 10;
-- 4.1
SELECT l1.movieid FROM links AS l1 INNER JOIN
(SELECT movieid, AVG(rating) FROM ratings GROUP BY movieid HAVING AVG(rating) > 3.5) AS r1 ON l1.movieid = r1.movieid LIMIT 10;
-- 4.2
SELECT AVG(rating) FROM ratings INNER JOIN
(SELECT userid as uid FROM ratings GROUP BY userid HAVING count(userid) > 10) AS rs ON ratings.userid = rs.uid LIMIT 10;
| true |
e60d03bfd77b20b52edb1b4014ba5a33bb7ccb44 | SQL | payalprakash99/Day3 | /mysqlTempTables.sql | UTF-8 | 1,124 | 4.34375 | 4 | [] | no_license | CREATE TEMPORARY TABLE MonthlyAverageSales
SELECT MONTH(orders.order_date) AS months,
orders.store_id AS store_Id,
stores.store_name AS store_Name,
ROUND((COUNT(orders.order_id))/3) AS Average_Orders
FROM orders
LEFT JOIN stores
ON stores.store_id=orders.store_id
where YEAR(orders.order_date) IN ( 2017,2018,2019)
GROUP BY MONTH(orders.order_date)
ORDER BY MONTH(orders.order_date);
CREATE TEMPORARY TABLE MontlyAverageSales2020
SELECT MONTH(orders.order_date) AS months,
YEAR(orders.order_date) AS years,
orders.store_id AS StoreID,
stores.store_name AS storeName,
COUNT(orders.order_id) AS OrderCount
FROM orders
LEFT JOIN stores
ON stores.store_id=orders.store_id
WHERE YEAR(orders.order_date) = 2020
GROUP BY MONTH(orders.order_date)
ORDER BY MONTH(orders.order_date);
SELECT t2.months AS months,
t2.years as Years,
t2.orderCount as OrderCount,
t1.Average_Orders as Average_Orders,
case
when(orderCount > t1.Average_Orders) then 'Increase'
when(orderCount < t1.Average_Orders) then 'Reduce'
END AS SalesDirection
FROM table2 t2
LEFT JOIN table1 t1
ON t2.months = t1.months
GROUP BY months
ORDER BY months;
| true |
7431ac70a84bd4522ce7b7eaf0ca019afb175a5c | SQL | Komaricus/applenperry-db | /migrations/00031_adds_pages_and_files_table.sql | UTF-8 | 324 | 2.90625 | 3 | [] | no_license | -- +goose Up
create table if not exists dbo.pages_and_files
(
id uuid not null primary key,
page_id uuid not null references dbo.pages (id),
file_id uuid not null references dbo.files (id)
);
alter table dbo.pages_and_files
owner to appleadmin;
-- +goose Down
drop table if exists dbo.pages_and_files; | true |
10a17a1cab79be9905913111b43633d6c478739b | SQL | The-CJ/Phaazebot | /Utils/DBTemplates/twitch_known_bot.sql | UTF-8 | 815 | 3.453125 | 3 | [
"MIT"
] | permissive | /*
DESCRIBE `twitch_known_bot`;
+--------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(128) | YES | UNI | NULL | |
| bot_id | varchar(128) | YES | UNI | NULL | |
+--------+--------------+------+-----+---------+----------------+
*/
-- SHOW CREATE TABLE `twitch_known_bot`;
CREATE TABLE `twitch_known_bot` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(128) DEFAULT NULL,
`bot_id` varchar(128) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `bot_id` (`bot_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
| true |
8df0761e289f3ec8cbfecf55c5185fe27f371fb0 | SQL | Douglas-Belani/POC-Rest-API | /sqlScripts/procedure_update_expired_order.sql | UTF-8 | 445 | 3.140625 | 3 | [] | no_license | DELIMITER $
CREATE PROCEDURE update_expired_order()
BEGIN
SET @orderStatusCanceledId = (SELECT orderStatusId FROM orderStatus WHERE status = 'CANCELED');
SET @orderStatusPendentId = (SELECT orderStatusId FROM orderStatus WHERE status = 'PENDENT');
UPDATE `order`
SET orderStatusId = @orderStatusCanceledId
WHERE orderStatusId = @orderStatusPendentId AND DATEDIFF(NOW(), `date`) > 7;
END $
DELIMITER ; | true |
3ad3e96025ece9fd587015da7f212292dbae6c5f | SQL | AguilarFerrer/TrivialLeaguePHP | /SQL/Inserts_Questions_&_Topics.sql | UTF-8 | 14,346 | 2.890625 | 3 | [] | no_license | INSERT INTO Trivial.Topics (Name, Image) VALUES ('Sports', '".\images\topics\sports.png"');
INSERT INTO Trivial.Topics (Name, Image) VALUES ('Culture', '".\images\topics\culture.png"');
INSERT INTO Trivial.Topics (Name, Image) VALUES ('Cinema', '".\images\topics\cinema.png"');
INSERT INTO Trivial.Topics (Name, Image) VALUES ('Geography', '".\images\topics\geography.png"');
INSERT INTO Trivial.Topics (Name, Image) VALUES ('Art', '".\images\topics\art.png"');
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES(1, 1, "The lakers removed from the franchise 2 shirts of Kobe Bryant, which ones?",
"8 &24","32 &8","24 & 44","42,32");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (2, 1,"How many championships has Fernando Alonso(2016)?","2","1","3","0");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (3, 1,"Who won the last World Cup of football(2016)?","Germany","Spain","Argentina","Brasil");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (4, 1,"How many players are in the field of basketball, between both teams?","10","11","5","22");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (5, 1,"Who is called 'The Doctor' at motorbikes?","Valentino Rossi","Marc Marquez","Jorge Lorenzo","Maverick Viñales");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (6, 1,"Which player scored 100 points in a game of basketball?","Wilt Chamberlain","Kobe Bryant","Hakeem Olajuwon","Michael Jordan");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (7, 1,"Who has the record of triple-double in a season of NBA?","Rusell Westbrook","Oscar Robertson","Lebron James","Michael Jordan");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (8, 1,"Who has the record of championships in F1(2016)?","Michael Schumacher","Alain Prost","Ayrton Senna", "Fernando Alonso");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (9, 1,"Who won last Champions League edition (2016)?","Real Madrid","Barcelona","Juventus","Bayern Munich");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (10, 1,"Which player is known as 'El niño maravilla'?","Alexis Sanchez","Lionel Messi","Cristiano Ronaldo","Angel Di Maria");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (11, 1,"In how many teams have played Francesco Totti?","1","2","3","4");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (12, 1,"In what position was selected Carmelo Anthony at Draft?","3","1","2","4");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (13, 1,"Which explayer started his career at the benches in NBA?","Jason Kidd","Shaquille O`Neal","Larry Bird","Michael Jordan");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (14, 1,"What did Michael Phelps during is career?","Swim","Run","Basketball","Football");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (15, 1,"Who is Usain Bolt?","A sprinter","A swimmer","A football player","A basketball player");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (1, 4,"Which river passes through 'Cataluña'?","Ebro","Tajo","Guadalquivir","Turia");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (2, 4,"Where is located the national park of 'Doñana'?","Huelva","Madrid","Valladolid","Huesca");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (3, 4,"Which city is called the capital of love?","Paris","Roma","Venice","London");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (4, 4,"Which city is characteristic for their gondolas?","Venice","Manchester","Munich","Barcelona");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (5, 4,"Where is located the Big Ben?","London","Sheffield","Birmingham","Leicester");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (6, 4,"Which is the capital of Spain?","Madrid","Barcelona","Bilbao","Sevilla");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (7, 4,"In which country are the ruins of Sparta?","Greece","Italy","Spain","Morocco");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (8, 4,"Which is the longest river in the world?","Nile","Amazonas","Ebro","Yangtse");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (9, 4,"How many continents are in the world?","6","5","11","10");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (10, 4,"What is the largest island in the Mediterranean Sea?","Sicily","Majorca","Cyprus","Sardinia");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (11, 4,"What is the bigger mountain in the world?","Everest","Teide","Kilimanjaro","K2");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (12, 4,"What is the most populated country in the world?","China","India","Japan","Rusia");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (13, 4,"Where is located Grand Canyon?","EEUU","Rusia","Mexico","Canada");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (14, 4,"What is the smallest country in the world?","El Vaticano","Monaco","San Marino","Finland");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (15, 4,"What is the capital of Canada?","Ottawa","Toronto","Texas","Vancouver");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (1, 2,"Where the first olympic games were created?","Olimpia","Rome","Turin","Venice");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (2, 2,"Who wrote 'El Quijote'?","Miguel de Cervantes","Pablo Picasso","Pablo Neruda","Arturo Pérez-Reverte");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (3, 2,"In which year came Cristobal Colón to America?","1492","1936","1514","1874");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (4, 2,"What is the most produced product in Guatemala?","Cafe","Rice","Fruits","Milk");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (5, 2,"Who is known as The King Of Rock?","Elvis Presley","Led Zeppelin","David Bowie","Elton Jhon");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (6, 2,"What studies cartography?","Maps","Rivers","Seas","Coasts");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (7, 2,"Which coin use in United Kingdom?","Pound","Euro","Dolar","Penny");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (8, 2,"Which is the color of hope?","Green","Purple","Yellow","Red");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (9, 2,"How many legs has a spider?","8","6","7","10");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (10, 2,"Where is the monument 'Taj Mahal'","India","Morocco","France","Egypt");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (11, 2,"Which name had the general of the 'Nazis' during the WWII?","Adolf Hitler","Eric Bill","Sebastian Bëhr","Roman Reus");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (12, 2,"Which year did the First World War Started?","1914","1916","1936","192");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (13, 2,"Which name has the creator of Facebook?","Mark Zuckerberg","Mark Brown","Stephen Simmons","Walden Smith");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (14, 2,"The year that the Spanish Constitution was aproved...","1978","1980","1938","1940");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (15, 2,"The first atomic bomb impacted in...","Japan","China","India","Korea");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (1, 3,"Who is the protagonist of the film 'Rocky'?","Sylverter Stallone","Memo Ochoa","Jason Staham","Adam Sandler");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (2 , 3,"Which of the following films the actor 'Jhonny Deep' doesn't appear","The Equalizer","Pirates of The Caribbean","The mask","Alice in Wonderland");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (3, 3,"Which actor is also called 'The Rock', for is past in WWE?","Dwayne Jhonson","Jhon Cena","Kevin Hart","Jack Black");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (4, 3,"How many films have Star Wars?(2017)","9","6","7","8");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (5, 3,"Which name has the evil neighbour in the film 'Toy Story'?","Sid","Tommy","Pedro","Jhon");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (6, 3,"Which color is the suit of 'The Incredibles'?","Red","Green","White","Blue");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (7, 3,"Who filmed 'The Adventures of Tintin: The Secret of the Unicorn'?","Steven Spielberg","Mark Douglas","Pedro Almodovar","Charlie Sheen");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (8, 3,"Who is the character 'Logan' of X-Men","Hugh Jackman","Ben Afleck","Adam Sandler","Jhonny Deep");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (9, 3,"Who produced Monsters Inc.?","Pixar","21th Century Fox","Axn","Syfy");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (10, 3,"Who bought 21th Century Fox in 2017?","Disney","Pixar","Disapeared","Netflix");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (11, 3,"Who interprets Robert Downey Jr. in Avengers","Iron Man","Captain America","Nick Fury","Anyone");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (12, 3,"At the film 'The hunger games', it's divided by Districts, how many?","13","11","10","12");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (13, 3,"Of how many movies is The Godfather filmed?","3","2","1","5");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (14, 3,"Who did the films of 'Harry Potter'?","Warner Bros & David Heyman","J.K. Rowling","21th Century Fox","LucasFilm");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (15, 3,"Who interprets 'Ali G'?","Baron Cohen","Adam Sandler","Jhonny Deep","Mark Mylad");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (1, 5,"In what century was born Velazquez?","XVII","XV","XVIII","XVI");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (2, 5,"Where we can find the 'Mona Lisa'?","Louvre","Museum of Prado","British Museum","Galeria Uffizi");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (3, 5,"In what century did rebirth arise?","XV","XIV","XVI","XVII");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (4, 5,"What year was Goya born?","1746","1806","1706","1796");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (5, 5,"In what current Da Vinci was inspired?","High Renaissance","Baroque","Realism","Mannerism");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (6, 5,"From where is 'Joan Miro'?","Majorca","Barcelona","Valencia","Madrid");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (7, 5,"In which century started Renaissance?","XV","XIV","XVII","XVIII");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (8, 5,"What group founded Jimmy Page?","Led Zeppelin","ACDC","Black Sabath","Iron Maiden");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (9, 5,"The beatles style was...","Pop/Rock","Hard Metal","Rock","Pop");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (10, 5,"Which singer was known as 'The Big O'?","Roy Orbison","Ozzy Osbourne","Des o'Connor","Jhon Lennon");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (11, 5,"How many components had The Beatles?","4","3","2","1");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (12, 5,"Roxanne is a song of...","The police","The Beatles","Elton Jhon","Elvis Presley");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (13, 5,"Where was born Noel Gallagher?","Manchester","London","Liverpool","Leicester");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (14, 5,"From where were 'The Rolling Stones'?","London","Liverpool","Manchester","Sheffield");
INSERT INTO Trivial.Questions(TopicQuestion, Topic,Question,AnsCorrect,AnsA,AnsB,AnsC)
VALUES (15, 5,"Which genre hasn't done Mick Jagger?","Metal","Rock","Pop","Blues")
| true |
072814a6ebdc4b8a330e7c13d28fda5a3dc9cc9d | SQL | redfin-research/schools-and-housing | /city-level/housing_cost_query.sql | UTF-8 | 592 | 4.15625 | 4 | [] | no_license | -- Redfin housing cost by city in 2016
select pm.table_id as place_id
, quantile(sale_price::numeric, 0.5) as median_sale_price
, quantile((l.sale_price::numeric / nullif(l.approx_sq_ft, 0)), 0.5) as median_sale_price_per_sqft
, count(distinct l.property_id) as total_sales
from listings l
join property_region_map pm on pm.property_id = l.property_id
and pm.region_type_id = 6
where l.property_type_id in (3,4,6,13)
and l.listing_type_id = 1
and l.sale_price >= 5000
and date_trunc('year', l.sale_date) = '2016-01-01'
group by 1
having count(distinct l.property_id) >= 5
; | true |
4e0f67140fcb823d9814999074a32153f0898e39 | SQL | hellgrenj/super-silly-todo | /db2/migrations/000001_create_todo_list.up.sql | UTF-8 | 328 | 3.296875 | 3 | [] | no_license | CREATE TABLE list (
id int PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) UNIQUE NOT NULL
);
CREATE TABLE item (
id int PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
done boolean not null default 0,
list_id INT NOT NULL,
FOREIGN KEY (list_id) REFERENCES list (id) ON DELETE CASCADE
); | true |
776bd87c012e3653ea6aeaac3fe5e59fbdaf13bd | SQL | msw822/xjny_dev | /xjny_version/dw_hadoop/table/app/edu_app_mj_zjhd.sql | UTF-8 | 1,281 | 2.953125 | 3 | [] | no_license | --公共业务库-5/6
use app;
drop TABLE IF EXISTS edu_app_mj_zjhd;
CREATE EXTERNAL TABLE edu_app_mj_zjhd(
rq string comment '日期,格式:YYYY-MM-DD'
,xh string comment '学号'
,xm string comment '姓名'
,yxdm string comment '院系代码'
,yxmc string comment '院系名称,根据院系代码与字典表进行联查'
,zydm string comment '专业代码'
,zymc string comment '专业名称,根据专业代码与字典表进行联查'
,bjdm string comment '班级代码'
,bjmc string comment '班级名称,根据班级代码与字典表进行联查'
,xznj string comment '现在年级,格式:YYYY'
,xz double comment '学制:N'
,zjxfsj string comment '最近消费时间:从一卡通消费表中抽取'
,zjmjsj string comment '最近门禁时间:从门禁信息表中抽取'
,zjswsj string comment '最近上网时间:从网络访问记录表中进行抽取'
)comment '[最近活动时间]'
PARTITIONED BY (
dt string)
row format delimited
fields terminated by '\t'
STORED AS orc
TBLPROPERTIES('orc.compress'='SNAPPY');
| true |
53e3d49e231d69b3573201c1a8560c6a325145d2 | SQL | MuhammadRizkiSatria/TKT311-2020-C-PrizeClass | /database/claszious.sql | UTF-8 | 4,732 | 2.890625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 27 Des 2020 pada 14.43
-- Versi server: 10.4.14-MariaDB
-- Versi PHP: 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: `claszious`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `tbl_kelas`
--
CREATE TABLE `tbl_kelas` (
`id_kelas` int(11) NOT NULL,
`kelas` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `tbl_kelas`
--
INSERT INTO `tbl_kelas` (`id_kelas`, `kelas`) VALUES
(1, 'kelas 1'),
(2, 'kelas 2\r\n'),
(3, 'KELAS TES');
-- --------------------------------------------------------
--
-- Struktur dari tabel `tbl_pesan`
--
CREATE TABLE `tbl_pesan` (
`id_pesan` int(100) NOT NULL,
`id_kelas` int(11) NOT NULL,
`id_user` int(11) NOT NULL,
`nama_user` varchar(100) NOT NULL,
`pesan` text NOT NULL,
`waktu` time NOT NULL,
`tanggal` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `tbl_pesan`
--
INSERT INTO `tbl_pesan` (`id_pesan`, `id_kelas`, `id_user`, `nama_user`, `pesan`, `waktu`, `tanggal`) VALUES
(2, 1, 3, 'ANDI', 'nuril', '11:20:40', '2020-12-20'),
(3, 1, 3, 'ANDI', 'iya', '23:20:49', '2020-12-24'),
(4, 1, 1, 'Tirta', 'dmna', '23:36:46', '2020-12-24'),
(5, 1, 1, 'Tirta', 'aq ga masuk ya', '14:21:01', '2020-12-26'),
(6, 1, 1, 'Tirta', 'kenapa', '14:39:52', '2020-12-26');
-- --------------------------------------------------------
--
-- Struktur dari tabel `tb_guru`
--
CREATE TABLE `tb_guru` (
`id` int(11) NOT NULL,
`username` varchar(100) NOT NULL,
`pass` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `tb_guru`
--
INSERT INTO `tb_guru` (`id`, `username`, `pass`, `email`) VALUES
(1, 'Tirta', '827ccb0eea8a706c4c34a16891f84e7b', 'tirta@gmail.com'),
(2, 'Rayyan', '827ccb0eea8a706c4c34a16891f84e7b', 'rayyan@gmail.com');
-- --------------------------------------------------------
--
-- Struktur dari tabel `tb_mapel`
--
CREATE TABLE `tb_mapel` (
`id` int(11) NOT NULL,
`mapel` varchar(100) NOT NULL,
`jml_soal` varchar(15) NOT NULL,
`poin` varchar(15) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `tb_mapel`
--
INSERT INTO `tb_mapel` (`id`, `mapel`, `jml_soal`, `poin`) VALUES
(1, 'Matematika', '20', '125'),
(2, 'B.Indonesia', '10', '80'),
(3, 'B.Inggris', '50', '200'),
(4, 'PKN', '25', '170');
-- --------------------------------------------------------
--
-- Struktur dari tabel `tb_siswa`
--
CREATE TABLE `tb_siswa` (
`id` int(11) NOT NULL,
`username` varchar(100) NOT NULL,
`pass` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`kelas` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `tb_siswa`
--
INSERT INTO `tb_siswa` (`id`, `username`, `pass`, `email`, `kelas`) VALUES
(1, 'Tirta', '827ccb0eea8a706c4c34a16891f84e7b', 'tirta@gmail.com', '14a'),
(2, 'Fadil', '827ccb0eea8a706c4c34a16891f84e7b', 'fadil@gmail.com', '12a');
--
-- Indexes for dumped tables
--
--
-- Indeks untuk tabel `tbl_kelas`
--
ALTER TABLE `tbl_kelas`
ADD PRIMARY KEY (`id_kelas`);
--
-- Indeks untuk tabel `tbl_pesan`
--
ALTER TABLE `tbl_pesan`
ADD PRIMARY KEY (`id_pesan`);
--
-- Indeks untuk tabel `tb_guru`
--
ALTER TABLE `tb_guru`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `tb_mapel`
--
ALTER TABLE `tb_mapel`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `tb_siswa`
--
ALTER TABLE `tb_siswa`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT untuk tabel yang dibuang
--
--
-- AUTO_INCREMENT untuk tabel `tbl_kelas`
--
ALTER TABLE `tbl_kelas`
MODIFY `id_kelas` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT untuk tabel `tbl_pesan`
--
ALTER TABLE `tbl_pesan`
MODIFY `id_pesan` int(100) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT untuk tabel `tb_guru`
--
ALTER TABLE `tb_guru`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT untuk tabel `tb_mapel`
--
ALTER TABLE `tb_mapel`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT untuk tabel `tb_siswa`
--
ALTER TABLE `tb_siswa`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
cfc417e41464a15c35a0afdd93d5b8c4ed38e20a | SQL | brynjaranalytica/SEP4 | /ThermalAnalysis/WeatherConditionMargins.sql | UTF-8 | 2,459 | 3.65625 | 4 | [
"MIT"
] | permissive | /* ThermalAnalysisWeatherConditionMargins.sql
*
* This script can be rerun to change the accepted margins of the different
* weather parameters.
*
* Ideally the margins should be derived from feature analysis like anova
* testing.
*/
drop table weather_condition_margins
;
create table weather_condition_margins as
select 5 as surface_temperature
, 20 as dew_point_temperature
, 10 as wind_speed
, 100 as visibility
, 4000 as cloud_altitude
from dual
;
/* Here are bunch of queries to see the count of each value in the ranges of
* all weather condition dimensions. Can be used to get a rough idea of the
* distribution of facts.
*/
-- group count of nearest weather stations
select b.nearest_weather_station, count(*)
from f_movement a, d_gridcell b
where a.grid_id = b.grid_cell_id
and a.delta_altitude > 0
group by b.nearest_weather_station
;
-- group count of surface temperatures
select d_surfacetemperature.surface_temperature_fahrenheit, count(*)
from f_movement, d_surfacetemperature
where f_movement.surface_temperature_id = d_surfacetemperature.surface_temperature_id
and f_movement.delta_altitude > 0
group by d_surfacetemperature.surface_temperature_fahrenheit
order by d_surfacetemperature.surface_temperature_fahrenheit
;
-- group count of dew point temperatures
select b.dew_point_temperature_fahrenheit, count(*)
from f_movement a, d_dewpointtemperature b
where a.dew_point_temperature_id = b.dew_point_temperature_id
group by b.dew_point_temperature_fahrenheit
order by b.dew_point_temperature_fahrenheit
;
-- group count of wind direction
select b.direction, count(*)
from f_movement a, d_winddirection b
where a.wind_direction_id = b.wind_direction_id
group by b.direction
order by b.direction
;
-- group count of wind direction
select b.speed_knots, count(*)
from f_movement a, d_windspeed b
where a.wind_speed_id = b.wind_speed_id
group by b.speed_knots
order by b.speed_knots
;
-- group count of visibility
select b.visibility, count(*)
from f_movement a, d_visibility b
where a.visibility_id = b.visibility_id
group by b.visibility
;
-- group count of cloud coverage
select b.cloud_coverage, count(*)
from f_movement a, d_cloudcoverage b
where a.cloud_coverage_id = b.cloud_coverage_id
group by b.cloud_coverage
;
-- group count of cloud altitude
select b.cloud_height, count(*)
from f_movement a, d_cloudaltitude b
where a.cloud_altitude_id = b.cloud_altitude_id
group by b.cloud_height
; | true |
a9e133bcd2c5de57710911d0d215cab9777f2cf6 | SQL | admfarmer/consent-form-upload | /sql/documents.sql | UTF-8 | 501 | 2.53125 | 3 | [] | no_license | DROP TABLE IF EXISTS `documents`;
CREATE TABLE `documents` (
`document_id` varchar(128) NOT NULL,
`document_code` varchar(20) DEFAULT NULL,
`originalname` varchar(200) DEFAULT NULL,
`file_name` varchar(150) DEFAULT NULL,
`file_path` varchar(200) DEFAULT NULL,
`uploaded_at` varchar(20) DEFAULT NULL,
`mime_type` varchar(50) DEFAULT NULL,
`file_size` int(12) DEFAULT NULL,
PRIMARY KEY (`document_id`),
KEY `idx_document_code` (`document_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
| true |
47ed36aef90c2cbc6fc1e34f7f46caeaa0df9811 | SQL | bilykb/BootcampX | /1_queries/4_students_with_gmail.sql | UTF-8 | 99 | 2.6875 | 3 | [] | no_license | SELECT name, id, email, cohort_id
FROM students
WHERE email NOT LIKE ('%gmail%')
AND phone IS NULL; | true |
f924b03a85d3bd92dc413d673605dda0031d640e | SQL | A00431152/Managing-Programming-and-Databases | /Assignmnet3&4/Part 1 - Assignment 3 files/make_person_table.sql | UTF-8 | 364 | 2.625 | 3 | [] | no_license | create table if not exists person (
_id INT not null auto_increment,
lname VARCHAR(50),
fname VARCHAR(50),
email VARCHAR(50),
city VARCHAR(50),
country VARCHAR(50),
postalcode VARCHAR(50),
streetnum VARCHAR(50),
streetname VARCHAR(50),
mainjob VARCHAR(50),
primary key(_id)
) engine = innodb;
load data local infile 'persons.tsv' into table person;
| true |
48970773c98fa4e599f7300b7978970824c7a168 | SQL | radtek/abs3 | /sql/mmfo/bars/Sequence/s_file_info.sql | UTF-8 | 1,161 | 2.609375 | 3 | [] | no_license |
PROMPT =====================================================================================
PROMPT *** Run *** ========== Scripts /Sql/BARS/Sequence/S_FILE_INFO.sql =========*** Run **
PROMPT =====================================================================================
PROMPT *** Create sequence S_FILE_INFO ***
CREATE SEQUENCE BARS.S_FILE_INFO MINVALUE 0 MAXVALUE 999999999999999999 INCREMENT BY 1 START WITH 43206182 CACHE 20 NOORDER NOCYCLE ;
PROMPT *** Create grants S_FILE_INFO ***
grant SELECT on S_FILE_INFO to BARS_ACCESS_DEFROLE;
grant SELECT on S_FILE_INFO to DPT_ROLE;
grant SELECT on S_FILE_INFO to WR_ALL_RIGHTS;
PROMPT =====================================================================================
PROMPT *** End *** ========== Scripts /Sql/BARS/Sequence/S_FILE_INFO.sql =========*** End **
PROMPT =====================================================================================
| true |
2c81015add3c89fb07d2b7a0c6d6b4b7468adfb2 | SQL | SimeonAnunciado/BusKaro | /buskaro.sql/buskaro_table_department.sql | UTF-8 | 596 | 3.390625 | 3 | [
"MIT"
] | permissive |
-- --------------------------------------------------------
--
-- Table structure for table `department`
--
DROP TABLE IF EXISTS `department`;
CREATE TABLE IF NOT EXISTS `department` (
`DCode` varchar(5) NOT NULL,
`DName` varchar(50) DEFAULT NULL,
PRIMARY KEY (`DCode`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `department`
--
INSERT INTO `department` (`DCode`, `DName`) VALUES
('CSE', 'Computer Science and Engineering'),
('DS', 'Design'),
('ECE', 'Electronics and Communication Engineering'),
('ME', 'Mechanical Engineering'),
('NS', 'Natural Sciences');
| true |
98b1a7ecbe7012cc1555c3290806d9239df8aa39 | SQL | alvvazort/Attica | /sql/triggers.sql | UTF-8 | 475 | 3.375 | 3 | [] | no_license | DELIMITER //
CREATE OR REPLACE TRIGGER triggerFiftyPhotos
BEFORE INSERT ON Photos
FOR EACH ROW
BEGIN
DECLARE photosUser INT;
SET photosUser = (SELECT COUNT(*)
FROM photos
WHERE userId = new.userId);
IF(photosUser > 50) THEN
SIGNAL SQLSTATE '45000' SET message_text =
'Áttica no admite más de 50 fotos por usuario.';
END IF;
END//
DELIMITER ; | true |
9433c99c2464497bc0548b8313c1ef47185af43b | SQL | chriseagle1/sanyou | /models/mysql/product.sql | GB18030 | 4,027 | 3.4375 | 3 | [
"BSD-3-Clause"
] | permissive | DROP TABLE IF EXISTS `product`;
CREATE TABLE `product`(
`id` INT(11) UNSIGNED NOT NULL auto_increment,
`product_no` VARCHAR(15) NOT NULL DEFAULT '',
`product_name` VARCHAR(100) NOT NULL DEFAULT '',
`brand` VARCHAR(30) NOT NULL DEFAULT '',
`unit` VARCHAR(50) NOT NULL DEFAULT '',
`specification` VARCHAR(30) NOT NULL DEFAULT '',
`retail_price` DECIMAL(7, 2) NOT NULL DEFAULT 0.00,
`vip_price` DECIMAL(7, 2) NOT NULL DEFAULT 0.00,
`remarks` TEXT,
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE INDEX `idx_prod_no` (`product_no`)
)ENGINE=INNODB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `product_stock`;
CREATE TABLE `product_stock`(
`id` INT(11) UNSIGNED NOT NULL auto_increment,
`product_no` VARCHAR(15) NOT NULL DEFAULT '',
`stock` INT(5) UNSIGNED NOT NULL DEFAULT 0,
`cost_price` DECIMAL(7,2) NOT NULL DEFAULT 0.00,
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE INDEX `idx_prod_no` (`product_no`)
)ENGINE=INNODB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `order`;
CREATE TABLE `order` (
`id` INT(11) UNSIGNED NOT NULL auto_increment,
`order_id` VARCHAR(64) NOT NULL DEFAULT '',
`order_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
`status` TINYINT(4) NOT NULL DEFAULT 0,
`product_num` INT(11) NOT NULL DEFAULT 0,
`order_amount` DECIMAL(11, 2) NOT NULL DEFAULT 0.00,
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE INDEX `idx_order_id` (`order_id`)
)ENGINE=INNODB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `order_detail`;
CREATE TABLE `order_detail`(
`id` INT(11) UNSIGNED NOT NULL auto_increment,
`order_id` VARCHAR(64) NOT NULL DEFAULT '',
`product_no` VARCHAR(15) NOT NULL DEFAULT '',
`product_num` INT(11) NOT NULL DEFAULT 0,
`product_amount` DECIMAL(11, 2) NOT NULL DEFAULT 0.00,
`profits` DECIMAL(11, 2) NOT NULL DEFAULT 0.00,
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
)ENGINE=INNODB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `pay_list`;
CREATE TABLE `pay_list` (
`id` INT(11) UNSIGNED NOT NULL auto_increment,
`trade_no` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '֧',
`out_trade_no` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '̻',
`buyer_logon_id` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '֧˺',
`total_amount` DECIMAL(11, 2) NOT NULL DEFAULT 0.00 COMMENT '',
`receipt_amount` DECIMAL(11, 2) NOT NULL DEFAULT 0.00 COMMENT 'ʵս',
`buyer_pay_amount` DECIMAL(11, 2) NOT NULL DEFAULT 0.00 COMMENT 'ҸĽ',
`point_amount` DECIMAL(11, 2) NOT NULL DEFAULT 0.00 COMMENT 'ʹûֱĽ',
`invoice_amount` DECIMAL(11, 2) NOT NULL DEFAULT 0.00 COMMENT 'пɸû߷ƱĽ',
`gmt_payment` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '֧ʱ',
`fund_bill_list` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '֧ʹõʽ',
`card_balance` DECIMAL(11, 2) NOT NULL DEFAULT 0.00 COMMENT '֧',
`store_name` VARCHAR(512) NOT NULL DEFAULT '' COMMENT '֧̻ŵ',
`buyer_user_id` VARCHAR(28) NOT NULL DEFAULT '' COMMENT '֧ûid',
`discount_goods_detail` TEXT,
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE INDEX `idx_trade_no` (`trade_no`),
INDEX `idx_order_no` (`out_trade_no`)
)ENGINE=INNODB DEFAULT CHARSET=utf8; | true |
717b21822d8e447890cb3453d702af649d675f62 | SQL | radtek/scripts-oracle-named | /+usados/Diversos/TB-DF-RBS.sql | UTF-8 | 6,210 | 4.0625 | 4 | [
"MIT"
] | permissive | //Description: The script generates a report of tablesapces, data files, roll back segments, control files, log files, objects (user wise, valid and invalid)
set long 132
set serveroutput on
declare
cursor tablespaces is
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
cursor datafiles is
select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;
cursor rollbacksegments is
select segment_name,
tablespace_name, r.status,
(initial_extent/1024) InitialExtent,
(next_extent/1024) NextExtent,
max_extents, v.curext CurExtent
From dba_rollback_segs r, v$rollstat v
Where r.segment_id = v.usn(+)
order by segment_name ;
cursor controlfiles is select name from v$controlfile;
cursor logfiles is select member from v$logfile;
cursor objects is select owner, object_type, status, count(*) count# from all_objects group by owner, object_type, status;
DBName VarChar2(20);
ToDate VarChar2(20);
Grand_Total_Space Integer;
Grand_Free_Space Integer;
TmpOwner VarChar2(50);
TmpObjectType VarChar2(50);
free_space Integer;
Ruler Char(90);
Remarks VarChar2(80);
Star Char(90);
Version VarChar2(80);
Log_Mode VarChar2(32);
Created VarChar2(20);
ValidCount Integer;
InValidCount Integer;
TotValidCount Integer;
TotInValidCount Integer;
GrandValidCount Integer;
GrandInValidCount Integer;
Is_It_First_Record Integer;
begin
dbms_output.enable;
ruler :=
'---------------------------------------------------------------------------
-----';
Star :=
'***************************************************************************
*****';
Grand_Total_Space := 0;
Grand_Free_Space := 0;
Select Substr(Global_Name,1,4) , To_Char(sysdate,'DD-MON-YYYY
HH24:MI:SS')
Into DBName, ToDate
From Global_Name;
Select version
Into Version
FROM Product_component_version
Where SUBSTR(PRODUCT,1,6)='Oracle';
Select Created, Log_Mode
Into Created, Log_Mode
From V$Database;
--
-- Database
--
dbms_output.put_line(Star);
dbms_output.put_line('Date : ' || ToDate);
dbms_output.put_line('Database : ' || DBName);
dbms_output.put_line('Created : ' || Created);
dbms_output.put_line('Version : ' || Version);
dbms_output.put_line('Log Mode : ' || Log_Mode);
dbms_output.put_line(Star);
--
-- Tablespaces
--
dbms_output.put_line('TABLESPACES (' || DBName || ')');
dbms_output.put_line(Ruler);
dbms_output.put_line( rpad('TABLESPACE',60,' ') ||
rpad('TOTAL(M)',10,' ') || rpad('FREE(M)',10,' '));
dbms_output.put_line(Ruler);
Grand_Total_Space := 0;
Grand_Free_Space := 0;
for tablespace in tablespaces loop
free_space := 0;
Begin
select sum(bytes/(1024*1024))
into free_space
from dba_free_space
where tablespace_name = tablespace.tablespace_name
group by tablespace_name;
Exception
When No_Data_Found Then Free_Space := 0;
End;
remarks := null;
If free_space <= (tablespace.ts_size * .1) then
remarks := ' ***';
End If;
dbms_output.put_line (rpad(tablespace.tablespace_name,60,'
')
|| rpad(to_char(tablespace.ts_size)
,10,' ')
|| rpad(to_char(free_space) ,6,' ' )
|| remarks
);
Grand_Total_Space := Grand_Total_Space + tablespace.ts_size;
Grand_Free_Space := Grand_Free_Space + free_space;
end loop;
dbms_output.put_line('-----');
dbms_output.put_line (rpad('Total ',60,' ') ||
rpad(Grand_Total_Space,10,' ') || rpad(Grand_Free_Space,10,' '));
dbms_output.put_line('-----');
--
-- Data Files
--
dbms_output.put_line(Ruler);
dbms_output.put_line('DATA FILES (' || DBName || ')');
dbms_output.put_line(Ruler);
dbms_output.put_line( rpad('TABLESPACE',15,' ') || rpad('DATA
FILE',45,' ') || rpad('TOTAL(M)',10,' ') || rpad('FREE(M)',10,' '));
dbms_output.put_line(Ruler);
Grand_Total_Space := 0;
Grand_Free_Space := 0;
for datafile in datafiles loop
free_space := 0;
Begin
select sum(bytes/(1024*1024))
into free_space
from dba_free_space
where tablespace_name =
datafile.tablespace_name
and file_id = datafile.file_id
group by tablespace_name, file_id;
Exception
When No_Data_Found Then Free_Space := 0;
End;
remarks := null;
If free_space <= (datafile.total_space * .1) then
remarks := ' ***';
End If;
dbms_output.put_line (rpad(datafile.tablespace_name,15,' ')
|| rpad(datafile.file_name,45,' ')
||
rpad(to_char(datafile.total_space) ,10,' ')
|| rpad(to_char(free_space) ,6,' ')
|| remarks
);
Grand_Total_Space := Grand_Total_Space +
datafile.total_space;
Grand_Free_Space := Grand_Free_Space + free_space;
end loop;
dbms_output.put_line('-----');
dbms_output.put_line (rpad('Total ',60,' ') ||
rpad(Grand_Total_Space,10,' ') || rpad(Grand_Free_Space,10,' '));
dbms_output.put_line('-----');
--
-- RollBack Segments
--
dbms_output.put_line(Ruler);
dbms_output.put_line('ROLLBACK SEGMENTS (' || DBName || ')');
dbms_output.put_line(Ruler);
dbms_output.put_line( rpad('RBS NAME', 15, ' ') ||
rpad('TABLESPACE', 20, ' ') ||
rpad('STATUS', 8, ' ') ||
rpad('INITIAL(K)', 10, ' ') ||
rpad('NEXT(K)', 10, ' ') ||
rpad('MAX(NO)', 8, ' ') ||
rpad('CURR.(NO)', 9, ' ')
);
dbms_output.put_line(Ruler);
for RBS in rollbacksegments loop
remarks := null;
If Rbs.Max_Extents - Rbs.CurExtent <= 10 then
remarks := ' ***';
End If;
dbms_output.put_line( rpad(rbs.segment_name,15,' ') ||
rpad(rbs.tablespace_name,20,' ') ||
rpad(rbs.status,8,' ') ||
rpad(rbs.initialextent,10,' ') ||
rpad(rbs.nextextent,10,' ') ||
rpad(rbs.Max_Extents,10,' ') ||
rpad(rbs.curextent,10,' ')
);
end loop;
--
-- Control Files
--
dbms_output.put_line(Ruler);
dbms_output.put_line('CONTROL FILES (' || DBName || ')');
dbms_output.put_line(Ruler);
for controlfile in controlfiles loop
dbms_output.put_line( rpad(controlfile.name,50,' '));
end loop;
--
-- Log Files
--
dbms_output.put_line(Ruler);
dbms_output.put_line('LOG FILES (' || DBName || ')');
dbms_output.put_line(Ruler);
for logfile in logfiles loop
dbms_output.put_line( rpad(logfile.member,50,' '));
end loop;
dbms_output.put_line(Ruler);
end;
/
| true |
01a726136fa6df3bed42e3d678fcefee70508e93 | SQL | Amanda1102/Divide-A.I.---plataforma-de-acompanhamento-e-divis-o-de-despesas. | /Database_System/Divide_AI_SQL_script.sql | UTF-8 | 1,328 | 3.9375 | 4 | [] | no_license | CREATE SCHEMA Divide_AI;
USE Divide_AI;
CREATE TABLE Usuario (
CPF BIGINT NOT NULL,
Idade TINYINT,
Pnome VARCHAR(30),
Sobrenome VARCHAR(50),
Saldo FLOAT,
PRIMARY KEY (CPF)
);
CREATE TABLE Grupo(
Identificador VARCHAR(50) NOT NULL,
Nome VARCHAR(30),
Quantidade_pessoas INT,
PRIMARY KEY (Identificador)
);
CREATE TABLE Divida(
CPF_devedor BIGINT NOT NULL,
CPF_credor BIGINT NOT NULL,
Quantia INT NOT NULL,
Tipo_moeda VARCHAR(30),
Categoria VARCHAR(30),
PRIMARY KEY (CPF_devedor , CPF_credor),
FOREIGN KEY (CPF_devedor)
REFERENCES Usuario (CPF)
ON DELETE CASCADE,
FOREIGN KEY (CPF_credor)
REFERENCES Usuario (CPF)
ON DELETE CASCADE
);
CREATE TABLE Usuario_grupo(
CPF BIGINT NOT NULL,
Identificador VARCHAR(50) NOT NULL,
PRIMARY KEY (CPF,Identificador),
FOREIGN KEY (CPF)
REFERENCES Usuario(CPF)
ON DELETE CASCADE,
FOREIGN KEY (Identificador)
REFERENCES Grupo(Identificador)
ON DELETE CASCADE
);
CREATE TRIGGER UPDATE_NUMBER_PEOPLE_GROUP BEFORE INSERT ON usuario_grupo
FOR EACH ROW
UPDATE grupo SET Quantidade_pessoas = Quantidade_pessoas + 1
WHERE grupo.identificador = NEW.Identificador;
CREATE TRIGGER SET_NUMBER_GROUP_ZERO BEFORE INSERT ON Grupo
FOR EACH ROW
SET new.Quantidade_pessoas = 0;
| true |
b1b8e38dfc775f4b4343703b8110022b9a2f0059 | SQL | PerryHuan9/LearnSpring | /src/main/resources/sql/curd.sql | UTF-8 | 4,245 | 4.8125 | 5 | [] | no_license | # 创建表
CREATE TABLE classes
(
id BIGINT NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- 创建students表:
CREATE TABLE students
(
id BIGINT NOT NULL AUTO_INCREMENT,
class_id BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
gender VARCHAR(1) NOT NULL,
score INT NOT NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
# 基本查询
SELECT *
FROM students;
# 条件查询
SELECT *
FROM students
WHERE (score >= 90 OR score < 60)
AND gender = 'M';
# 阴影查询
SELECT id, name
FROM students;
# 排序, 默认为ASC 升序
SELECT *
FROM students
ORDER BY score;
# 降序排序 DESC
SELECT id, name, score
FROM students
ORDER BY score DESC;
# 条件查询且排序
SELECT *
FROM students
WHERE gender = 'F'
order by score;
# 多个排序字段
# 下面在score值相同时使用name升序排序
SELECT *
FROM students
ORDER BY score DESC, name ASC;
# 使用LIMIT <M> OFFSET <N>可以对结果集进行分页,每次查询返回结果集的一部分;
SELECT *
FROM students
ORDER BY score DESC
LIMIT 3 OFFSET 0;
# OFFSET 表示从第四个开始查,即第四个
SELECT *
FROM students
ORDER BY score DESC
LIMIT 3 OFFSET 3;
# 聚合查询
# count 计数 count(*)与count(id)效果一致
SELECT COUNT(*)
FROM students;
# 为聚合输出列取个别名
SELECT COUNT(*) num
FROM students
where gender = 'M';
# sum聚合 求和(仅能对数值类型操作)
SELECT SUM(score) sun_score
FROM students;
# avg聚合 求平均值(仅能对数值类型操作)
SELECT AVG(score)
FROM students
WHERE gender = 'F';
# max 求最大值
# min求最小值
SELECT MAX(students.score)
FROM students;
SELECT MIN(students.score)
FROM students;
# 聚合查询, 分别统计相同class_id数据的数量
SELECT class_id, COUNT(*) count
FROM students
GROUP BY class_id;
# 多表查询又叫笛卡尔查询
# 查询的结果集列数是所有表的列数之和,行数则是所有表的行数之积
SELECT *
FROM students,
classes;
# 当出现重名属性,
SELECT students.id sid,
students.name,
students.gender,
students.score,
classes.id cid,
classes.name cname
FROM classes,
students;
# 连接查询
# 内连接 结果会把两张表中的数据交集取出,依据是条件部分
# 注意INNER JOIN查询的写法是:
# 1、先确定主表,仍然使用FROM <表1>的语法;
# 2、再确定需要连接的表,使用INNER JOIN <表2>的语法;
# 3、然后确定连接条件,使用ON <条件...>,这里的条件是s.class_id = c.id,表示students表的class_id列与classes表的id列相同的行需要连接;
# 4、可选:加上WHERE子句、ORDER BY等子句。
SELECT s.id, s.name, s.gender, c.name class, s.score
FROM students s
INNER JOIN classes c on s.class_id = c.id;
# 外连接
# 左外连接
SELECT s.id, s.name, s.gender, c.name class, s.score
FROM students s
LEFT OUTER JOIN classes c on s.class_id = c.id;
# 由外连接
SELECT s.id, s.name, s.gender, c.name class, s.score
FROM students s
RIGHT OUTER JOIN classes c on c.id = s.class_id;
# 全外连接 MYSQL不支持
# SELECT s.id, s.name, s.class_id, c.name class_name, s.gender, s.score
# FROM students s FULL OUTER JOIN classes c
# ON s.class_id = c.id;
# 在查询的时候,数据库系统会自动分析查询语句,并选择一个最合适的索引。
# 但是很多时候,数据库系统的查询优化器并不一定总是能使用最优索引。
# 如果我们知道如何选择索引,可以使用FORCE INDEX强制查询使用指定的索引。
# 声明索引
ALTER TABLE students
ADD INDEX idx_class_id (class_id);
SELECT *
FROM students FORCE INDEX (idx_class_id)
WHERE class_id = 1
ORDER BY score DESC;
# 修改数据
# 插入数据
INSERT INTO students(name, class_id, gender, score)
VALUES ('1212', 3, 'M', 66),
('天一', 3, 'M', 68),
('1666', 3, 'M', 66);
# 更新数据
UPDATE students
SET name = '天下',
class_id=3
WHERE id = 11;
UPDATE students
SET score=score + 10
WHERE score < 60;
# 删除数据
DELETE
FROM students
WHERE id = 12;
| true |
18765ce196deaa07774d3a826e57c15d9cdeee56 | SQL | rijumone/url-shortening-service | /shorturl/schema.sql | UTF-8 | 206 | 2.609375 | 3 | [] | no_license | DROP TABLE IF EXISTS urls_map;
CREATE TABLE urls_map (
id INTEGER PRIMARY KEY,
short_url TEXT DEFAULT NULL,
original_url TEXT DEFAULT NULL,
created_at DATETIME DEFAULT (datetime('now', 'utc'))
); | true |
a012a5f15d18347c2cab793407430c9600bf7420 | SQL | miryasha/analytics | /app/db/checkTheSize.sql | UTF-8 | 661 | 3.625 | 4 | [] | no_license | SELECT
table_schema 'Database Name',
SUM(data_length + index_length) 'Size in Bytes',
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) 'Size in MiB'
FROM information_schema.tables
GROUP BY table_schema;
UNIQUE (ID)
CREATE TABLE Orders (
OrderID int NOT NULL,
OrderNumber int NOT NULL,
PersonID int,
PRIMARY KEY (OrderID),
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
);
ALTER TABLE Orders
ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);
//copy table into new one
INSERT qoutes_daily.spy SELECT * FROM test.spy_quotes;
//make a new tabel
ALTER TABLE vendors ADD COLUMN vendor_group INT NOT NULL;
| true |
1b12b8267de018b7a9405576f2b63dd8d15d0cb2 | SQL | llmhyy/clonepedia | /clonepedia/design/dbSchema/Method.SQL | UTF-8 | 225 | 2.609375 | 3 | [] | no_license | CREATE TABLE IF NOT EXISTS Method
(
methodId VARCHAR(255) NOT NULL,
ownerId VARCHAR(50) NOT NULL,
methodName VARCHAR(255) NOT NULL,
returnType VARCHAR(255),
returnTypeCategory VARCHAR(50),
PRIMARY KEY (methodId)
)
;
| true |
323091029b98791cbbf112c5bf4f1bc6f3fd8ad7 | SQL | alexanderps3393/Simple-HMVC-in-Codeigniter-3 | /engg.sql | UTF-8 | 4,271 | 3.140625 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.2.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 25, 2015 at 07:03 AM
-- Server version: 5.6.20
-- PHP Version: 5.4.35
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: `engg`
--
-- --------------------------------------------------------
--
-- Table structure for table `Chats`
--
CREATE TABLE IF NOT EXISTS `Chats` (
`id` int(5) unsigned NOT NULL,
`message` text NOT NULL,
`time` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `files`
--
CREATE TABLE IF NOT EXISTS `files` (
`file_id` int(10) unsigned NOT NULL,
`file_name` varchar(255) COLLATE latin1_general_ci NOT NULL,
`file_orig_name` varchar(255) COLLATE latin1_general_ci NOT NULL,
`file_path` varchar(255) COLLATE latin1_general_ci NOT NULL,
`upload_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `membership`
--
CREATE TABLE IF NOT EXISTS `membership` (
`id` int(11) NOT NULL,
`firstname` varchar(30) NOT NULL,
`lastname` varchar(30) NOT NULL,
`state` varchar(30) NOT NULL,
`city` varchar(30) NOT NULL,
`country` varchar(30) NOT NULL,
`zip` int(6) NOT NULL,
`address` varchar(500) NOT NULL,
`email` varchar(30) NOT NULL,
`mobileno` varchar(10) NOT NULL,
`landlineno` varchar(15) NOT NULL,
`username` varchar(30) NOT NULL,
`password` varchar(100) NOT NULL,
`date` date NOT NULL,
`admin_id` varchar(100) NOT NULL,
`status` int(1) NOT NULL
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `membership`
--
INSERT INTO `membership` (`id`, `firstname`, `lastname`, `state`, `city`, `country`, `zip`, `address`, `email`, `mobileno`, `landlineno`, `username`, `password`, `date`, `admin_id`, `status`) VALUES
(1, '', '', '', '', '', 0, '', '', '', '', 'admin', '0192023a7bbd73250516f069df18b500', '0000-00-00', '', 0);
-- --------------------------------------------------------
--
-- Table structure for table `student_list`
--
CREATE TABLE IF NOT EXISTS `student_list` (
`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`address` varchar(100) NOT NULL,
`year` varchar(100) NOT NULL,
`gender` varchar(100) NOT NULL,
`interest` varchar(100) NOT NULL,
`status` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `student_list`
--
INSERT INTO `student_list` (`id`, `name`, `address`, `year`, `gender`, `interest`, `status`) VALUES
(1, 'admin', 'address', '201', 'male', 'music', 0),
(2, 'admin', 'adddress', 'male', '2010', '', 1),
(3, 'admin', 'adddress', 'male', '2010', '', 1),
(4, 'admin', 'adddress', '2010', 'male', '', 1);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `Chats`
--
ALTER TABLE `Chats`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `files`
--
ALTER TABLE `files`
ADD PRIMARY KEY (`file_id`);
--
-- Indexes for table `membership`
--
ALTER TABLE `membership`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `student_list`
--
ALTER TABLE `student_list`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `Chats`
--
ALTER TABLE `Chats`
MODIFY `id` int(5) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `files`
--
ALTER TABLE `files`
MODIFY `file_id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `membership`
--
ALTER TABLE `membership`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `student_list`
--
ALTER TABLE `student_list`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;
/*!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 |
ed7b46202483ea5dc0bb0473aec5fed8eb887a97 | SQL | DevartVasiliyK/MySQL_rep | /Functions/inventory_held_by_customer.sql | UTF-8 | 366 | 3.5625 | 4 | [] | no_license | DELIMITER $$
CREATE FUNCTION `inventory_held_by_customer`(p_inventory_id INT)
RETURNS INT(11)
READS SQL DATA
BEGIN
DECLARE v_customer_id INT;
DECLARE EXIT HANDLER FOR NOT FOUND RETURN NULL;
SELECT customer_id INTO v_customer_id
FROM rental
WHERE return_date IS NULL
AND inventory_id = p_inventory_id;
RETURN v_customer_id;
END
$$
DELIMITER ; | true |
97e80d4e7c36bd5c9eced69d1e02ca0320932d8e | SQL | molokovskikh/af_prgdata | /migrations/468_00_user_prices_begore_insert_trigger.sql | UTF-8 | 692 | 3.28125 | 3 | [] | no_license | DROP TRIGGER IF EXISTS Customers.UserPricesBeforeInsert;
CREATE
DEFINER=`RootDBMS`@`127.0.0.1`
TRIGGER `Customers`.`UserPricesBeforeInsert`
BEFORE INSERT ON `Customers`.`userprices`
FOR EACH ROW
BEGIN
update
Usersettings.AnalitFReplicationInfo ar
join Usersettings.PricesData pd on pd.FirmCode = ar.FirmCode
set ForceReplication = 1
where ar.UserId = NEW.UserId and pd.PriceCode = NEW.PriceId;
update
Customers.Users u
join Usersettings.AnalitFReplicationInfo ar on ar.UserId = u.Id
join Usersettings.PricesData pd on pd.FirmCode = ar.FirmCode and pd.PriceCode = NEW.PriceId
set ForceReplication = 1
where
u.InheritPricesFrom = NEW.UserId;
END;
| true |
625e51d699ac380304ad93216a8d0ec333fda70f | SQL | benardkirui/digitala-attendance-system | /database/attendance.sql | UTF-8 | 6,081 | 3.125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Sep 02, 2019 at 10:10 AM
-- Server version: 5.7.26
-- PHP Version: 7.2.18
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `attendance`
--
-- --------------------------------------------------------
--
-- Table structure for table `attachees`
--
DROP TABLE IF EXISTS `attachees`;
CREATE TABLE IF NOT EXISTS `attachees` (
`name` varchar(32) NOT NULL,
`email` varchar(32) NOT NULL,
`start` varchar(32) NOT NULL,
`specialization` varchar(32) NOT NULL,
`gender` varchar(32) NOT NULL,
`language` varchar(32) NOT NULL,
`phone` varchar(32) NOT NULL,
`idnumber` varchar(32) NOT NULL,
`subcounty` varchar(32) NOT NULL,
`ward` varchar(32) NOT NULL,
`institution` varchar(32) NOT NULL,
`course` varchar(32) NOT NULL,
PRIMARY KEY (`idnumber`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `attachees`
--
INSERT INTO `attachees` (`name`, `email`, `start`, `specialization`, `gender`, `language`, `phone`, `idnumber`, `subcounty`, `ward`, `institution`, `course`) VALUES
('kones kip', 'koneskip@gmail.com', '2019-08-02', 'OS Installation', 'Male', 'C#', '0716838766', '33452626', 'Chepalungu', 'Sigor', 'MKU', 'EGN'),
('collins kipngetich', 'kipngetich310@gmail.com', '2019-08-23', 'Programming', 'Male', 'Android', '0716543456', '33298572', 'Bomet Central', 'Ndarawetta', 'MKU', 'COMPUTER ENGINEERING'),
('collins kipngetich', 'collins10@gmail.com', '2019-08-23', 'Technical', 'Male', 'Data Base', '0716543345', '38678765', 'Chepalungu', 'Sigor', 'jkuat', 'BBIT'),
('Kiptoo Rashon', 'biikiptoo@gmail.com', '2019-08-09', 'Programming', 'Male', 'Android', '0702820251', '37568077', 'Konoin', 'Mogogosiek', 'jkuat', 'ece'),
('rono enock', 'bernadben41@gmail.com', '2019-09-06', 'Programming', 'Male', 'Data Base', '0713454546', '24536754', 'Bomet Central', 'Singorwet', 'jkuat', 'engineering'),
('Bernard Mutai', 'bernaben41@gmail.com', '2019-09-20', 'Networking', 'Male', 'Data Base', '0715675675', '33456734', 'Bomet Central', 'Silibwet', 'jkuat', 'bsc it');
-- --------------------------------------------------------
--
-- Table structure for table `done`
--
DROP TABLE IF EXISTS `done`;
CREATE TABLE IF NOT EXISTS `done` (
`idnumber` varchar(50) NOT NULL,
`fullname` varchar(50) NOT NULL,
`jobdone` varchar(1000) NOT NULL,
`date` varchar(50) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `done`
--
INSERT INTO `done` (`idnumber`, `fullname`, `jobdone`, `date`) VALUES
('37568077', 'Kiptoo Rashon', 'i was sent to the treasury', '2019-09-02 08:58:28'),
('37568077', 'Kiptoo Rashon', 'i was sent tot he treasury', '2019-09-02 09:00:04');
-- --------------------------------------------------------
--
-- Table structure for table `reporting`
--
DROP TABLE IF EXISTS `reporting`;
CREATE TABLE IF NOT EXISTS `reporting` (
`fullname` varchar(32) NOT NULL,
`idnumber` varchar(10) NOT NULL,
`reportin` varchar(32) NOT NULL,
`reportout` varchar(32) DEFAULT NULL,
`department` varchar(50) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `reporting`
--
INSERT INTO `reporting` (`fullname`, `idnumber`, `reportin`, `reportout`, `department`) VALUES
('Kiptoo Rashon', '37568077', '2-9-2019 11:59:53', '2-9-2019 12:0:4', NULL);
-- --------------------------------------------------------
--
-- Table structure for table `supervisors`
--
DROP TABLE IF EXISTS `supervisors`;
CREATE TABLE IF NOT EXISTS `supervisors` (
`idnumber` int(11) NOT NULL,
`fullname` varchar(64) NOT NULL,
`department` varchar(32) NOT NULL,
`phonenumber` varchar(13) NOT NULL,
`email` varchar(40) NOT NULL,
`username` varchar(15) NOT NULL,
`password` varchar(64) NOT NULL,
PRIMARY KEY (`idnumber`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `supervisors`
--
INSERT INTO `supervisors` (`idnumber`, `fullname`, `department`, `phonenumber`, `email`, `username`, `password`) VALUES
(33783245, 'kipkirui ken', 'ICT', '0723543765', 'kipkiruikip32@gmail.com', 'ken', 'adeeba08e6e63fca2ba7c530a28f29a6'),
(66455727, 'enock bett', 'ENG', '0715645756', 'bernad41@gmail.com', 'enock', '13126195d5ef15b7d922a2b392e17a0a');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`fullname` varchar(64) DEFAULT NULL,
`username` varchar(64) DEFAULT NULL,
`idnumber` varchar(64) DEFAULT NULL,
`phonenumber` varchar(10) DEFAULT NULL,
`level` varchar(10) NOT NULL,
`password` varchar(64) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`fullname`, `username`, `idnumber`, `phonenumber`, `level`, `password`) VALUES
('Koech', 'koechc', '22463631', '0722336377', 'admin', '10959a2ad8d4116054b7f62a8989a9c1'),
('one direction', 'direction', '33297285', '0716837766', 'admin', '4051bc853473fa22ae96de7aa5f4939a'),
('collins kipngetich', 'collo', '33298572', '0716543456', 'not admin', '7ce38bf6811a96afd3411188577b08ee'),
('collins kipngetich', 'collo', '38678765', '0716543345', 'not admin', '2ea32bc284eef17c399199171f346caa'),
('kones kip', 'kones', '33452626', '0716838766', 'not admin', '2a38a4186a3ad36740480664772af763'),
('Kiptoo Rashon', 'kiptoo-attachee', '37568077', '0702820251', 'not admin', 'e10adc3949ba59abbe56e057f20f883e'),
('Kiptoo Rashon', 'kiptoo-admin', '34266245', '0702820251', 'admin', 'e10adc3949ba59abbe56e057f20f883e'),
('kirui Bob', 'kirui', '30406565', '0715675654', 'admin', 'e77b22ec4319553ca52d9a9398f89384'),
('rono enock', 'rono', '24536754', '0713454546', 'not admin', 'c6dee5c22a7a2d9e0be6da62b30ea5ad'),
('Bernard Mutai', 'Mutai', '33456734', '0715675675', 'not admin', '4a874a33c0220b962daa4e0cda1f0d1d');
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 |
80b848ba65372dca7980886b94ef6047fbc29106 | SQL | hilongjw/wazi | /Dockerfile/wazi.sql | UTF-8 | 3,814 | 3 | 3 | [
"MIT"
] | permissive | /*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50540
Source Host : localhost:3306
Source Database : wazi
Target Server Type : MYSQL
Target Server Version : 50540
File Encoding : 65001
Date: 2015-06-22 17:55:15
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for item
-- ----------------------------
DROP TABLE IF EXISTS `item`;
CREATE TABLE `item` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`num` int(12) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL,
`desct` text,
`title` varchar(32) DEFAULT NULL,
`price` decimal(12,2) DEFAULT NULL,
`pic` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=gbk;
-- ----------------------------
-- Records of item
-- ----------------------------
INSERT INTO `item` VALUES ('1', '20', '[aaaaa]新品薄款男式袜春夏袜子', '由于袜子工艺问题,深色袜子可能会出现少许白色地方,在意慎拍由于袜子工艺问题,深色袜子可能会出现少许白色地方,在意慎拍由于袜子工艺问题,深色袜子可能会出现少许白色地方,在意慎拍由于袜子工艺问题,深色袜子可能会出现少许白色地方,在意慎拍由于袜子工艺问题,深色袜子可能会出现少许白色地方,在意慎拍', 'aaaaaaa薄款男式袜春夏袜啊啊啊啊子', '0.00', 'assets/i/upload/wazi1.jpg,assets/i/upload/wazi2.jpg');
-- ----------------------------
-- Table structure for news
-- ----------------------------
DROP TABLE IF EXISTS `news`;
CREATE TABLE `news` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`title` varchar(64) DEFAULT NULL,
`desct` varchar(256) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=gbk;
-- ----------------------------
-- Records of news
-- ----------------------------
INSERT INTO `news` VALUES ('3', '满5双送货到寝室', '满5双送货到寝室满5双送货到寝室满5双送货到寝室');
INSERT INTO `news` VALUES ('4', '哈哈哈哈h', '哈哈哈哈h');
INSERT INTO `news` VALUES ('5', '暗示法按时 ', '防暗示法暗示法');
INSERT INTO `news` VALUES ('6', '阿斯顿暗示法', '暗示法');
-- ----------------------------
-- Table structure for orderlist
-- ----------------------------
DROP TABLE IF EXISTS `orderlist`;
CREATE TABLE `orderlist` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`itemId` int(12) DEFAULT NULL,
`numb` int(8) DEFAULT NULL,
`tel` varchar(16) DEFAULT NULL,
`addrs` char(128) DEFAULT NULL,
`wait` varchar(16) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=gbk;
-- ----------------------------
-- Records of orderlist
-- ----------------------------
INSERT INTO `orderlist` VALUES ('7', '1', '3', '345345', '1舍454', 'wait');
-- ----------------------------
-- Table structure for reco
-- ----------------------------
DROP TABLE IF EXISTS `reco`;
CREATE TABLE `reco` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`itemid` int(12) NOT NULL,
PRIMARY KEY (`id`,`itemid`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=gbk;
-- ----------------------------
-- Records of reco
-- ----------------------------
INSERT INTO `reco` VALUES ('2', '2');
INSERT INTO `reco` VALUES ('4', '0');
INSERT INTO `reco` VALUES ('6', '16');
INSERT INTO `reco` VALUES ('7', '17');
-- ----------------------------
-- Table structure for wazi_user
-- ----------------------------
DROP TABLE IF EXISTS `wazi_user`;
CREATE TABLE `wazi_user` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`user` varchar(32) NOT NULL,
`tel` varchar(16) NOT NULL,
`password` varchar(32) NOT NULL,
PRIMARY KEY (`id`,`user`,`tel`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk;
-- ----------------------------
-- Records of wazi_user
-- ----------------------------
| true |
5f8c519178977f96cff9a673cbc8b5e5415616f9 | SQL | i-MCcarri/init-api | /migrations/006.do.create_init_comments.sql | UTF-8 | 381 | 3 | 3 | [] | no_license | CREATE TABLE init_comments (
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
text TEXT NOT NULL,
date_created TIMESTAMPTZ DEFAULT now() NOT NULL,
post_id INTEGER
REFERENCES init_posts(id) ON DELETE CASCADE NOT NULL,
user_id INTEGER
REFERENCES user_information(id) ON DELETE CASCADE NOT NULL,
unread BOOLEAN DEFAULT true NOT NULL
);
| true |
37ff49ef86c7616bc35056098c89cac8359be940 | SQL | gruter/tajo-elasticsearch | /tajo-core/src/test/resources/queries/TestJoinQuery/testInnerJoinWithThetaJoinConditionInWhere.sql | UTF-8 | 129 | 3.546875 | 4 | [
"Apache-2.0",
"PostgreSQL",
"BSD-3-Clause",
"MIT"
] | permissive | select a.r_regionkey, a.r_name, b.r_name from region a join region b
on a.r_regionkey = b.r_regionkey
where a.r_name <= b.r_name; | true |
8cc91d254199fa5d5c570b6262f7a1151be01a8d | SQL | cabacdorina/SQL | /create_a_record.sql | UTF-8 | 565 | 3.40625 | 3 | [] | no_license |
declare
--r_emp employees%rowtype;
type t_emp is record (first_name VARCHAR2(50), last_name EMPLOYEES.LAST_NAME%type,
salary employees.salary%type, hire_date date);
r_emp t_emp;
begin
--select first_name, last_name, salary, hire_date into r_emp from employees where employee_id='101';
r_emp.first_name := 'Liliana';
r_emp.salary := 2500;
r_emp.hire_date := '01-JAN-20';
dbms_output.put_line(r_emp.first_name||' '||r_emp.last_name|| ' earns: ' ||r_emp.salary||
' and was hired at: ' || r_emp.hire_date);
end;
--select * from employees;
| true |
4df4e22ff95c9fe1481e8fcf3f8fea05622fe97e | SQL | rojaleen91/SQL-QUERIES | /SQL DOCUMENTS.sql | UTF-8 | 3,736 | 3.859375 | 4 | [] | no_license | CREATE DATABASE testDB;
/*...create table....*/
CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);
/*...Insert query....*/
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (1, 'Ramesh', 32, 'Ahmedabad', 2000.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (2, 'Khilan', 25, 'Delhi', 1500.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (3, 'kaushik', 23, 'Kota', 2000.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (4, 'Chaitali', 25, 'Mumbai', 6500.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (5, 'Hardik', 27, 'Bhopal', 8500.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (6, 'Komal', 22, 'MP', 4500.00 );
/*...select query with where condition....*/
SELECT * FROM CUSTOMERS;
SELECT ID, NAME, SALARY
FROM CUSTOMERS
WHERE SALARY > 2000;
SELECT ID, NAME, SALARY
FROM CUSTOMERS
WHERE NAME = 'Hardik';
SELECT ID, NAME, SALARY
FROM CUSTOMERS
WHERE SALARY > 2000 AND age < 25;
SELECT ID, NAME, SALARY
FROM CUSTOMERS
WHERE SALARY > 2000 OR age < 25;
/*...update query....*/
UPDATE CUSTOMERS
SET ADDRESS = 'Pune'
WHERE ID = 6;
DELETE FROM CUSTOMERS
WHERE ID = 6;
/*...wildcard operator like....*/
SELECT * FROM CUSTOMERS
WHERE SALARY LIKE '200%';
SELECT * FROM CUSTOMERS
WHERE SALARY LIKE '_%_%0%0';
SELECT * FROM CUSTOMERS
WHERE SALARY LIKE '2%_%_0';
SELECT * FROM CUSTOMERS
WHERE SALARY LIKE '2___3';
SELECT TOP 3 * FROM CUSTOMERS;
SELECT * FROM CUSTOMERS;
/*...order by....*/
SELECT * FROM CUSTOMERS
ORDER BY NAME;
SELECT * FROM CUSTOMERS
ORDER BY NAME, SALARY;
/*...group by....*/
SELECT NAME, SUM(SALARY) FROM CUSTOMERS
GROUP BY NAME;
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (6, 'Chaitali', 22, 'MP', 4500.00 );
SELECT NAME, SUM(SALARY) FROM CUSTOMERS
GROUP BY NAME;
SELECT NAME,SUM(SALARY) FROM CUSTOMERS
WHERE SALARY>6000
GROUP BY NAME
ORDER BY NAME DESC;
/*...distinct....*/
SELECT DISTINCT SALARY FROM CUSTOMERS
ORDER BY SALARY;
CREATE TABLE ORDERS(
OID INT NOT NULL,
DATE DATETIME,
CUSTOMER_ID INT,
AMOUNT INT
);
INSERT INTO ORDERS(
OID,DATE,CUSTOMER_ID,AMOUNT)
VALUES(
102 ,2009-10-08,3,3000);
INSERT INTO ORDERS(
OID,DATE,CUSTOMER_ID,AMOUNT)
VALUES(
100 ,2009-10-08,3,1500);
INSERT INTO ORDERS(
OID,DATE,CUSTOMER_ID,AMOUNT)
VALUES(
101 ,2009-11-20,2,1560);
INSERT INTO ORDERS(
OID,DATE,CUSTOMER_ID,AMOUNT)
VALUES(
103 ,2008-05-20,4,2060);
SELECT * FROM ORDERS;
SELECT ID, NAME, AGE, AMOUNT
FROM CUSTOMERS, ORDERS
WHERE CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
/*...LEFT JOIN....*/
SELECT ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
LEFT JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
/*...RIGHT JOIN....*/
SELECT ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
RIGHT JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
/*...TABLE ALIAS AND COLUMN ALIAS....*/
SELECT C.ID, C.NAME, C.AGE, O.AMOUNT
FROM CUSTOMERS AS C, ORDERS AS O
WHERE C.ID = O.CUSTOMER_ID;
SELECT ID AS CUSTOMER_ID, NAME AS CUSTOMER_NAME
FROM CUSTOMERS
WHERE SALARY IS NOT NULL;
/*...HAVING....*/
SELECT ID
FROM CUSTOMERS
GROUP BY ID
HAVING ID >= 2;
/*...2ND HIGHEST SALARY....*/
SELECT * FROM CUSTOMERS;
SELECT MAX(SALARY) FROM CUSTOMERS
WHERE SALARY < (
SELECT MAX(SALARY) FROM CUSTOMERS);
/*...2ND HIGHEST SALARY USING TABLE ALIAS....*/
SELECT * FROM CUSTOMERS CUST1
WHERE (2)=
(SELECT COUNT (DISTINCT (CUST2.SALARY))
FROM CUSTOMERS CUST2
WHERE CUST1.SALARY>=CUST2.SALARY);
| true |
db7e6a1bf9866a76738efa65153623a1b7e71142 | SQL | PratikRaut15/speed-elixia-project | /.svn/pristine/db/db7e6a1bf9866a76738efa65153623a1b7e71142.svn-base | UTF-8 | 992 | 3.265625 | 3 | [] | no_license | DELIMITER $$
DROP PROCEDURE IF EXISTS `insert_vehicle`$$
CREATE PROCEDURE `insert_vehicle`(
IN transporterid INT
, IN vehicletypeid INT
, IN vehicleno VARCHAR(20)
, IN customerno INT
, IN todaysdate DATETIME
, IN userid INT
, OUT currentvehicleid INT
)
BEGIN
INSERT INTO vehicle(
transporterid
, vehicletypeid
, vehicleno
, customerno
, created_on
, updated_on
, created_by
, updated_by
)
VALUES (
transporterid
, vehicletypeid
, vehicleno
, customerno
, todaysdate
, todaysdate
, userid
, userid
);
SET currentvehicleid = LAST_INSERT_ID();
END$$
DELIMITER ;
| true |
af6a9acae81d94bca3ced161c865e23e4a8392ea | SQL | EternalVigil/week-14-handlebars | /db/schema.sql | UTF-8 | 174 | 2.53125 | 3 | [] | no_license | CREATE DATABASE burger_db;
use burger_db;
CREATE TABLE burgers(
id INTEGER(10) NOT NULL AUTO_INCREMENT,
burger_name VARCHAR(50),
devoured BOOL,
date DATE,
PRIMARY KEY(id)
); | true |
a4d1a44e4b497deec68f9fa00dcae35c370ca71e | SQL | jlemonier/utils | /win_utils/py/vf_v4/VF_SO_DB_vs_XML.sql | UTF-8 | 6,675 | 3.15625 | 3 | [] | no_license |
-- v5 csv loaded with PoLineNumber correctly -
if 'no create #vf' = 'create #vf' begin
drop table #vf
-- Table alias
-- VF connect invoices to xml data
-- select * from tt_om_vendordoc vd where vd.shippingordernum in ('5010159481')
-- select * from tt_om_org_invoicestatus
-- select top 50 * from tt_om_vendordoc_lineitem order by 1 desc
-- select top 500 * from #tmp where CommercialInvoiceNumber in ('122866')
select
inv.om_invoice_id
, inv.invoicenum
, vd.shippingordernum
, vdl.om_poline_num
, t.POLineNumber
, vdl.vdocline_objidkey
, vdsa.color
, vdsa.size
, vdsa.dimension
-- , vdsa.upc upc_vd_sku_asst, t.upc upc_so_xml
, vdsa.quantity quantity_sku_asst
, vds.qty qty_sku
, t.quantity quantity_so_xml
, vds.gross_amt gross_amt_sku_asst
-- , t.quantity * t.FirstCostPrice gross_amt_so_xml_calc
, vdsa.size size_vd_sku_asst
, t.size size_so_xml
, vdsa.color color_sku_asst
, t.color color_so_xml
, vdsa.dimension dim_sku_asst
, t.dimension dim_so_xml
, t.upc upc_so_xml
-- , t.color color_inv_xml
, vdl.firstcost firstCost_so_line
, t.FirstCostPrice firstCostPrice_inv_xml
-- , t.ShippingOrderNumber
, inv.om_org_invoicestatus_id
, st.name invstatus
, st.code invstatus_code
, inv.ispaymentprocessed
, inv.gross_amt
, t.filename
-- , pmtinfo.paymentid, pmtinfo.endtoendid
, inv.customs_amt
, inv.net_amt
, inv.discount_amt
, inv.claim_amt
, vd.om_vendordoc_id
, vdl.om_vendordoc_lineitem_id
, vds.om_vendordoc_sku_id
, vdsa.om_assortment_id
-- , 'vd table' vd_table, vd.*
-- , 'vd line' vd_line, vdl.*
-- , 'vd sku' vd_sku, vds.*
-- , 'vd sku asst' vd_sku_asst, vdsa.*
-- , inv.*
-- drop table #vf
into #vf
from tt_om_invoice inv
-- left join tt_pmtremittance pmtremit on pmtremit.om_invoice_id = inv.om_invoice_id
-- left join tt_pmtinfo pmtinfo on pmtinfo.pmtinfo_id = pmtremit.pmtinfo_id
left join tt_om_org_invoicestatus st on st.om_org_invoicestatus_id = inv.om_org_invoicestatus_id
inner join tt_om_vendordoc vd on vd.om_vendordoc_id = inv.om_vendordoc_id and vd.isobsolete = 0 and vd.isactive = 1
inner join tt_om_vendordoc_lineitem vdl on vdl.om_vendordoc_id = vd.om_vendordoc_id and vdl.isobsolete = 0
-- inner join tt_om_poline pol on pol.om_poline_id = vdl.om_poline_id and pol.isactive = 1
inner join tt_om_vendordoc_sku vds on vds.om_vendordoc_lineitem_id = vdl.om_vendordoc_lineitem_id and vds.isobsolete = 0
inner join tt_om_assortment vdsa on vdsa.om_assortment_id = vds.om_assortment_id
-- Now find matches from XML
left join #tmp t
-- SO / CI / PO
on t.ShippingOrderNumber = vd.shippingordernum
and t.CommercialInvoiceNumber = vd.invoicenum
and t.PurchaseOrderNumber = vdl.ponum
-- Assortment: Color + Size + Dimension
and t.Color = vdsa.color
and t.Size = vdsa.size
and (t.Dimension = vdsa.dimension or len(vdsa.dimension) < 1 or vdsa.dimension is null )
and t.POLineNumber = vdl.om_poline_num -- same in VDL and POL
-- and t.upc = vdsa.upc
-- PO-line / VD-line
left join tt_om_prod px
on px.code = t.ItemNumber and px.org_id = 12408
---->> Note om_prod_id check below
where 1=1
-- and inv.invoicenum in ('122866')
and inv.isactive = 1
and inv.customer_org_id=12408 --VF
and inv.isactive = 1
-- Must ensure the SO-line matches! but do not remove DB Assortment from query if no match. This prevents duplicates.
and vdl.om_prod_id = isnull(px.om_prod_id, vdl.om_prod_id)
and inv.om_org_invoicestatus_id in (2,3)
and inv.ispaymentprocessed = 0
-- Filter down to SO.xml that we are analyzing now ...
and vd.shippingordernum in (select distinct ShippingOrderNumber from #tmp)
-- Exclude Invoices linked to Memos: Debits or Credits
and not exists
(select 1
from tt_om_invoicememo invm
where invm.invoicenum = inv.invoicenum
and invm.customerorg_id = inv.customer_org_id
and invm.isactive = 1
)
order by
inv.om_invoice_id
, inv.invoicenum
, vd.shippingordernum
, vdl.vdocline_objidkey
, vdsa.color
, vdsa.size
, vdsa.dimension
end
select top 1 * from #vf
select top 1 * from #tmp
if 'counts' = 'counts' begin
select 'Analyzing Counts'
select count(*) db2xml_count from #vf -- 87699 in VF table
select count(*) xml_asst_count from #tmp -- 62638
select count(*) from #vf where quantity_so_xml is null -- 1788 -- rows to be fixed
select count(distinct om_vendordoc_sku_id) from #vf -- 63450 unique sku_ids
select CommercialInvoiceNumber, ShippingOrderNumber, PurchaseOrderNumber, ItemNumber, Color, Size, Dimension
, count(*)
from #tmp
group by CommercialInvoiceNumber, ShippingOrderNumber, PurchaseOrderNumber, ItemNumber, Color, Size, Dimension
having count(*) > 1
end
if 'check duplicates in #vf' = 'check duplicates in #vf' begin
select om_invoice_id, invoicenum, shippingordernum, vdocline_objidkey, color, size, dimension
, count(*) rows
, max(upc_so_xml) upc_max
, min(upc_so_xml) upc_min
, max(om_vendordoc_sku_id) sku_id_max
, min(om_vendordoc_sku_id) sku_id_min
, max(qty_sku) qty_max
, min(qty_sku) qty_min
, max(quantity_so_xml) qty_so_xml_max
, min(quantity_so_xml) qty_so_xml_min
, max(filename) filename_mssgdocid_max
, min(filename) filename_mssgdocid_min
from #vf
group by om_invoice_id, invoicenum, shippingordernum, vdocline_objidkey, color, size, dimension
having count(*) > 1 and
max(quantity_so_xml) <> min(quantity_so_xml)
order by count(*) desc
end
if 'clean #tmp' = 'clean #tmp done' begin
-- drop table #so
-- Make sure ONLY data for needed SO #s are in #tmp
select distinct shippingordernum into #so from #vf
-- 986 should not be there in #tmp
delete
-- select shippingordernumber
from #tmp
where shippingordernumber not in (select distinct shippingordernum from #so)
select top 50 *
from tt_om_po po
inner join tt_om_poline pol on pol.om_po_id = po.om_po_id
where po.ponum in ('4500909708')
end
select top 3 * from #vf
select top 3 * from #tmp
if 'no check SO 5010165626' = 'check SO 5010165626' begin
select * from #tmp t
where t.shippingordernumber in ('5010165626')
select vdl.om_poline_id, vdl.om_poline_num, pol.om_poline_num, *
from tt_om_vendordoc_lineitem vdl
inner join tt_om_poline pol on pol.om_poline_id = vdl.om_poline_id
where vdl.vdocline_objidkey in ('{5010166782}{4500935992}{450093599200020}{3849276}')
end | true |
34adb4108ffaa19c4d309290aa6cf3c1ef4c3126 | SQL | BenMusch/cs3200-final-project | /db/db3.sql | UTF-8 | 385 | 3.125 | 3 | [] | no_license | --
-- Table structure for table `debaters`
--
CREATE TABLE `debaters` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Test Person',
PRIMARY KEY (`id`),
UNIQUE KEY `NAME` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
| true |
7d09206b83cb2eaeb168ccafe73402b246e82110 | SQL | ramoslm/bifrcu | /scripts/dwfrcu/dim_redprogramatica_std_redprogramatica.sql | UTF-8 | 2,072 | 3.140625 | 3 | [] | no_license | DROP TABLE dim_redprogramatica_std_redprogramatica;
CREATE TABLE dim_redprogramatica_std_redprogramatica(
redprogramatica_sk SERIAL NOT NULL,
redprogramatica_programa SMALLINT,
redprogramatica_nombreprograma VARCHAR(60),
redprogramatica_nombre VARCHAR(40),
redprogramatica_subprograma SMALLINT,
redprogramatica_proyecto SMALLINT,
redprogramatica_actividad SMALLINT,
redprogramatica_obra SMALLINT,
redprogramatica_sort VARCHAR(30),
redprogramatica_check VARCHAR(32),
batch_id BIGINT,
CONSTRAINT pk_dim_redprogramatica_std_redprogramatica PRIMARY KEY(redprogramatica_sk),
CONSTRAINT uk_dim_redprogramatica_std_redprogramatica UNIQUE(redprogramatica_programa, redprogramatica_subprograma, redprogramatica_proyecto, redprogramatica_actividad, redprogramatica_obra)
);
COMMENT ON TABLE dim_redprogramatica_std_redprogramatica IS 'Distintos programas, subprogramas, proyectos, actividades y obras.';
COMMENT ON TABLE dim_redprogramatica_std_redprogramatica IS 'La clave de negocio (bk) para esta tabla esta compuesta por redprogramatica_programa, redprogramatica_subprograma, redprogramatica_proyecto, redprogramatica_actividad y redprogramatica_obra';
ALTER TABLE dim_redprogramatica_std_redprogramatica OWNER TO etl_user;
INSERT INTO dim_redprogramatica_std_redprogramatica(redprogramatica_sk, redprogramatica_programa, redprogramatica_subprograma, redprogramatica_proyecto,
redprogramatica_actividad, redprogramatica_obra, redprogramatica_nombreprograma, redprogramatica_nombre, redprogramatica_sort, redprogramatica_check, batch_id)
VALUES(-1, -1, -1, -1, -1, -1, 'Desconocido', 'Desconocido', 'DESC', 'ZZZZZZZZZZZZZZZZZZZZ', 0);
INSERT INTO dim_redprogramatica_std_redprogramatica(redprogramatica_sk, redprogramatica_programa, redprogramatica_subprograma, redprogramatica_proyecto,
redprogramatica_actividad, redprogramatica_obra, redprogramatica_nombreprograma, redprogramatica_nombre, redprogramatica_sort, redprogramatica_check, batch_id)
VALUES(-2, -2, -2, -2, -2, -2, 'No Aplicable', 'No Aplicable', 'NA', 'ZZZZZZZZZZZZZZZZZZZZ', 0);
| true |
0171beeb47e4913a69d8ca83a76c02c62ef32bb4 | SQL | xeeshansoftech/Akhpal-Kaar | /Forms/RMS/LOAN/DATABASE/Audit_RMS_Cust_Client_Loan_TRG.sql | UTF-8 | 926 | 2.875 | 3 | [] | no_license | create or replace trigger "AU_TRG_RMS_CUST_CLIENTS_LOAN"
before update or delete on RMS_CUST_CLIENTS_LOAN
for each ROW
declare
-- local variables here
nextversion_no AUDIT_RMS_CUST_CLIENTS_LOAN.version_no%TYPE;
begin
SELECT nvl(MAX(version_no), 0) + 1
INTO nextversion_no
FROM AUDIT_RMS_CUST_CLIENTS_LOAN RCL
WHERE RCL.RMS_CUST_LOAN_ID = :old.RMS_CUST_LOAN_ID;
INSERT INTO AUDIT_RMS_CUST_CLIENTS_LOAN
(rms_cust_loan_id,
loan_date,
client_code,
isin,
loan_volume,
settlement_date,
approved_by,
executed,
post,
log_id,
version_no,
rejected)
VALUES
(:Old.rms_cust_loan_id,
:Old.loan_date,
:Old.client_code,
:Old.isin,
:Old.loan_volume,
:Old.settlement_date,
:Old.approved_by,
:Old.executed,
:Old.post,
:Old.log_id,
nextversion_no,
:Old.Rejected);
end AU_TRG_RMS_CUST_CLIENTS_LOAN;
/
| true |
21783be507ba791969be558b6320845671c53278 | SQL | byeveweb/php-foro-trabajo-UCAV | /sql/foro._seas.sql | UTF-8 | 2,596 | 3.171875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.2
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 29-11-2018 a las 20:57:50
-- Versión del servidor: 10.1.30-MariaDB
-- Versión de PHP: 7.2.2
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de datos: `foro_seas`
--
--
-- Estructura de tabla para la tabla `posteados`
--
CREATE TABLE `posteados` (
`post_id` int(11) NOT NULL,
`post_mensaje` varchar(70) COLLATE utf8_spanish2_ci NOT NULL,
`post_date` date NOT NULL,
`post_tema` int(7) NOT NULL,
`post_user` varchar(50) COLLATE utf8_spanish2_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci;
--
-- Estructura de tabla para la tabla `temas`
--
CREATE TABLE `temas` (
`tema_id` int(11) NOT NULL,
`tema_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`tema_autor` varchar(50) COLLATE utf8_spanish2_ci NOT NULL,
`tema_titulo` varchar(50) COLLATE utf8_spanish2_ci NOT NULL,
`tema_npost` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci;
CREATE TABLE `usuarios` (
`users_id` int(11) NOT NULL,
`user_type` tinyint(1) NOT NULL,
`user_email` varchar(50) CHARACTER SET latin1 COLLATE latin1_spanish_ci NOT NULL,
`user_password` varchar(100) COLLATE utf8_spanish_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- Indices de la tabla `posteados`
--
ALTER TABLE `posteados`
ADD PRIMARY KEY (`post_id`);
--
-- Indices de la tabla `temas`
--
ALTER TABLE `temas`
ADD PRIMARY KEY (`tema_id`);
--
-- Indices de la tabla `usuarios`
--
ALTER TABLE `usuarios`
ADD PRIMARY KEY (`users_id`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
-- AUTO_INCREMENT de la tabla `posteados`
--
ALTER TABLE `posteados`
MODIFY `post_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=64;
--
-- AUTO_INCREMENT de la tabla `temas`
--
ALTER TABLE `temas`
MODIFY `tema_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT de la tabla `usuarios`
--
ALTER TABLE `usuarios`
MODIFY `users_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;
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 |
68dfc85b8cf072c8329f2b06455e7da336daa415 | SQL | lsst/qserv | /src/qmeta/schema/migrate-0-to-1.sql | UTF-8 | 2,745 | 3.84375 | 4 | [] | no_license | --
-- Migration script from version 0 to version 1 of QMeta database:
-- - QInfo table adds two new columns
-- - processlist views add result location column
-- - QMetadata table is added to keep schema version
--
-- -----------------------------------------------------
-- Add new columns to table `QInfo`
-- -----------------------------------------------------
ALTER TABLE `QInfo` ADD COLUMN (
`messageTable` CHAR(63) NULL COMMENT 'Name of the message table for the ASYNC query',
`resultLocation` TEXT NULL COMMENT 'Result destination - table name, file name, etc.'
);
-- -----------------------------------------------------
-- Update view `ShowProcessList`
-- -----------------------------------------------------
ALTER VIEW `ShowProcessList` AS
SELECT DISTINCT
`QInfo`.`queryId` `Id`,
`QInfo`.`user` `User`,
NULL `Host`,
GROUP_CONCAT(DISTINCT `QTable`.`dbName`) `db`,
`QInfo`.`qType` `Command`,
NULL `Time`,
`QInfo`.`status` `State`,
`QInfo`.`query` `Info`,
NULL `Progress`,
`QInfo`.`submitted` `Submitted`,
`QInfo`.`completed` `Completed`,
`QInfo`.`returned` `Returned`,
`QInfo`.`czarId` `CzarId`,
REPLACE(`QInfo`.`resultLocation`, '#QID#', `QInfo`.`queryId`) `ResultLocation`
FROM `QInfo` LEFT OUTER JOIN `QTable` USING (`queryId`)
GROUP BY `QInfo`.`queryId`;
-- -----------------------------------------------------
-- Update view `InfoSchemaProcessList`
-- -----------------------------------------------------
ALTER VIEW `InfoSchemaProcessList` AS
SELECT DISTINCT
`QInfo`.`queryId` `ID`,
`QInfo`.`user` `USER`,
NULL `HOST`,
GROUP_CONCAT(DISTINCT `QTable`.`dbName`) `DB`,
`QInfo`.`qType` `COMMAND`,
NULL `TIME`,
`QInfo`.`status` `STATE`,
`QInfo`.`query` `INFO`,
`QInfo`.`submitted` `SUBMITTED`,
`QInfo`.`completed` `COMPLETED`,
`QInfo`.`returned` `RETURNED`,
`QInfo`.`czarId` `CZARID`,
REPLACE(`QInfo`.`resultLocation`, '#QID#', `QInfo`.`queryId`) `RESULTLOCATION`,
NULLIF(COUNT(`QWorker`.`chunk`), 0) `NCHUNKS`
FROM `QInfo` LEFT OUTER JOIN `QTable` USING (`queryId`)
LEFT OUTER JOIN `QWorker` USING (`queryId`)
GROUP BY `QInfo`.`queryId`;
-- -----------------------------------------------------
-- Create table `QMetadata`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `QMetadata` (
`metakey` CHAR(64) NOT NULL COMMENT 'Key string',
`value` TEXT NULL COMMENT 'Key string',
PRIMARY KEY (`metakey`))
ENGINE = InnoDB
COMMENT = 'Metadata about database as a whole, bunch of key-value pairs';
-- Add record for schema version, migration script expects this record to exist
INSERT INTO `QMetadata` (`metakey`, `value`) VALUES ('version', '1');
| true |
b3fa1cf2aeec19d6179daf025de9e99eb74642da | SQL | menome/neo4j-spatial-experiments | /3_walkscore_neo4j/cypher_scripts/1_dykstra.cql | UTF-8 | 1,009 | 3.53125 | 4 | [
"MIT"
] | permissive | // ------------------------------------------------------------------
// Neo4j Spatial Experiments, December 2018
// Written by Menome Technologies Inc. http://www.menome.com
//
// Cypher Version of the Walk Score Calculation
// ------------------------------------------------------------------
// 6 compute walk score Walk Score® = Raw Score x 6.67 - (ID - ABL)
// Can use any lat/long or pre-configured Buildings Test 1, Test 2, Test 3
match (d:Building {Code:'Test 1'})
with d,point({ longitude: d.lon, latitude: d.lat }) as p1
// find all points of interest in boundary
match (p:PointOfInterest)-[]-(t:OSMTags)
with d,p1,collect(p) as pointsOfInterest
// unwind and compute actual distances from Test1
unwind (pointsOfInterest) as point
call algo.shortestPath.stream(d,point,'distance',
{relationshipQuery:'ROUTE',nodeQuery:'Routable',direction:'BOTH', defaultValue:1.0}) YIELD nodeId,cost
match (n) where id(n)=nodeId
return collect({lat:n.location.latitues,lon:n.location.longitude}) as route | true |
1b3cb6c2d84c26f336184484963d9ed147d25b53 | SQL | YousCode/docker | /db/db.sql | UTF-8 | 235 | 2.5625 | 3 | [] | no_license | CREATE DATABASE Docker;
USE Docker;
CREATE TABLE Users
( ID int,
Username VARCHAR(20),
Email VARCHAR(40),
password VARCHAR(100));
INSERT INTO Users VALUES
( 1,
'brasko',
'brasko_93@gmail.com',
'ici-cest-la-cite');
| true |
d0819f8223b0a2089542193aa4f8f8b8c6189ba6 | SQL | Jackiezj/myql-jdbc | /mysql/src/dml.sql | UTF-8 | 605 | 3.4375 | 3 | [] | no_license | -- 添加数据
insert into student (id, name, age) values (null, "zhangsan", 18); -- 除数字外所有内容都用"" 引起来 如日期
insert into student values (...); -- ... 表示所有列全部需要依次传递
-- 删除数据
delete from student where age=18;
delete from student; -- 不加条件表示全部删除, 不推荐使用
truncate table student; -- 先删除表,然后再创建一张一样的表, 推荐使用
-- 修改数据
update student set name = "lisi", age = 18 where name = "ls"
update student set name = "list", age = 18; -- 不加条件, 修改表中的所有记录
| true |
a91bade5323da6ec1c83f6857e299b1112cb2a3d | SQL | VadimKNF/OOP_1 | /modules/core/db/init/hsql/10.create-db.sql | UTF-8 | 2,556 | 3.21875 | 3 | [] | no_license | -- begin OOP1_EMPLOYEE
create table OOP1_EMPLOYEE (
ID varchar(36) not null,
VERSION integer not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
FIRST_NAME varchar(30) not null,
LAST_NAME varchar(30) not null,
BIRTH_DATE date,
EMAIL varchar(30),
SALARY decimal(19, 2) not null,
WORK_SHOP_ID varchar(36),
--
primary key (ID)
)^
-- end OOP1_EMPLOYEE
-- begin OOP1_CITY
create table OOP1_CITY (
ID varchar(36) not null,
VERSION integer not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
NAME varchar(50) not null,
PHONE_CODE integer,
--
primary key (ID)
)^
-- end OOP1_CITY
-- begin OOP1_SERVICE
create table OOP1_SERVICE (
ID varchar(36) not null,
VERSION integer not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
DESCRIPTION varchar(255) not null,
Employee_ID varchar(36),
--
primary key (ID)
)^
-- end OOP1_SERVICE
-- begin OOP1_WORK_SHOP
create table OOP1_WORK_SHOP (
ID varchar(36) not null,
VERSION integer not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
NAME varchar(30) not null,
PHONE_NUMBER integer not null,
CITY_ID varchar(36),
ADDRESS varchar(255),
SERVICE_ID varchar(36),
WORK_SHOP_ID varchar(36),
--
primary key (ID)
)^
-- end OOP1_WORK_SHOP
-- begin OOP1_INDIVIDUAL
create table OOP1_INDIVIDUAL (
ID varchar(36) not null,
--
PASSPORT_NO integer,
--
primary key (ID)
)^
-- end OOP1_INDIVIDUAL
-- begin OOP1_COMPANY
create table OOP1_COMPANY (
ID varchar(36) not null,
--
INN integer,
--
primary key (ID)
)^
-- end OOP1_COMPANY
-- begin OOP1_CUSTOMER
create table OOP1_CUSTOMER (
ID varchar(36) not null,
VERSION integer not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
DTYPE varchar(31),
--
NAME varchar(50),
PHONE integer,
EMAIL varchar(50),
WORK_SHOP_ID varchar(36),
--
primary key (ID)
)^
-- end OOP1_CUSTOMER
| true |
c937b91bb390617b24f4457a790c9a76d4ab3704 | SQL | sonikvvv/Project-for-DB | /Version 1/forDBproject~3.sql | UTF-8 | 162 | 3.421875 | 3 | [] | no_license | select s.sales_id,s.client_id, s.sale_date, e.employee_name from sales s
join employees e on e.employee_id = s.employee_id
order by s.sale_date, e.employee_name; | true |
286d73bd0343112a05714c98ffedfa69795900ff | SQL | QUANWEIRU/My-Work-In-OracleEBS | /FND/ValueSet_n_Lookup/Q_VS_Based_on_Independent_Type.sql | UTF-8 | 491 | 3.140625 | 3 | [] | no_license | SELECT ffvs.flex_value_set_id ,
ffvs.flex_value_set_name ,
ffvs.description set_description ,
ffvs.validation_type,
ffv.flex_value_id ,
ffv.flex_value ,
ffvt.flex_value_meaning ,
ffvt.description value_description
FROM fnd_flex_value_sets ffvs ,
fnd_flex_values ffv ,
fnd_flex_values_tl ffvt
WHERE
ffvs.flex_value_set_id = ffv.flex_value_set_id
and ffv.flex_value_id = ffvt.flex_value_id
AND ffvt.language = USERENV('LANG');
| true |
6d796e930547170111a4e3285988bedc053792f7 | SQL | souravrrp/AKG-SCIL-SQL | /QUERY/Queries/item on hand qty lot wise.sql | UTF-8 | 754 | 3.515625 | 4 | [] | no_license | select
msi.segment1||'.'||msi.segment2||'.'||msi.segment3 item_code,
msi.description,
ood.organization_code,
moq.subinventory_code,
moq.lot_number,
moq.transaction_quantity
from
APPS.MTL_ONHAND_QUANTITIES moq,
inv.mtl_system_items_b msi,
apps.org_organization_definitions ood
where
-- msi.organization_id=99
ood.operating_unit=99
and msi.organization_id=ood.organization_id
and msi.inventory_item_id=moq.inventory_item_id
and msi.organization_id=moq.organization_id
and msi.segment1||'.'||msi.segment2||'.'||msi.segment3 in ('RPAP.ORNI.0001')
-- and moq.lot_number='RPAP-14-AUG-2014-11'
-- and moq.SUBINVENTORY_CODE='CER-SP FLR'
-- and rownum<10
order by
moq.lot_number | true |
ea4e3f5ff6895e944340773f4ee403e13600bdf6 | SQL | jmaviz/Sprint2-Bases-de-dades | /mysql-estructura/consultes_optica.sql | UTF-8 | 306 | 2.796875 | 3 | [] | no_license | -- OPTICA
SELECT * FROM venda WHERE data_venda BETWEEN "2020-01-01" AND "2020-12-30";
SELECT u.marca FROM ulleres u JOIN venda v ON u.id=v.ulleres_id WHERE data_venda BETWEEN "2020-01-01" AND "2020-12-30";
SELECT * from proveidor p JOIN ulleres u ON p.DNI=u.DNI_proveidor JOIN venda v ON u.id=v.ulleres_id; | true |
edc97cbd056041d6bef323ddf713b3b19ccf2e39 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/low/day23/select1316.sql | UTF-8 | 178 | 2.671875 | 3 | [] | no_license |
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o
WHERE timestamp>'2017-11-22T13:16:00Z' AND timestamp<'2017-11-23T13:16:00Z' AND temperature>=26 AND temperature<=27
| true |
80793fdb7fccf0dbb99a24e47461900a0562c0fa | SQL | Marcos-Barranquero/BBDDAA-UAH | /PECL2/consulta_postgres.sql | UTF-8 | 1,085 | 3.78125 | 4 | [] | no_license | -- Consulta del ejercicio 13 para postgresql: casteando Precio a numeric.
select distinct "Musicos"."Nombre", "Musicos"."Codigo_grupo_Grupo"
from "Musicos" inner join "Grupo" on "Musicos"."Codigo_grupo_Grupo" = "Grupo"."Codigo_grupo"
inner join "Grupos_Tocan_Conciertos" on "Grupo"."Codigo_grupo" = "Grupos_Tocan_Conciertos"."Codigo_grupo_Grupo"
inner join "Conciertos" on "Grupos_Tocan_Conciertos"."Codigo_concierto_Conciertos" = "Conciertos"."Codigo_concierto"
inner join "Entradas" on "Conciertos"."Codigo_concierto" = "Entradas"."Codigo_concierto_Conciertos"
inner join "Discos" on "Grupo"."Codigo_grupo" = "Discos"."Codigo_grupo_Grupo"
inner join "Canciones" on "Discos"."Codigo_disco" = "Canciones"."Codigo_cancion"
where "Conciertos"."Pais" ='Spain' and ("Entradas"."Precio"::numeric) >= 20 and "Entradas"."Precio"::numeric <= 50 and "Discos"."Genero" ='rock'
and "Canciones"."Duracion" > '03:00:00'
and "Musicos"."Codigo_grupo_Grupo" in (select "Codigo_grupo_Grupo"
from "Musicos"
group by "Codigo_grupo_Grupo"
having(count(codigo_musico)>3));
| true |
cf3bc739990ba5bc43717caafd9dab8f7dfbbe4a | SQL | essaricy/MySchool | /Database/Postgres/schemas/public/CREATE/TABLES/notification.sql | UTF-8 | 2,828 | 3.671875 | 4 | [] | no_license | -- NOTIFICATION Module
CREATE TABLE NOTIFICATION_END_POINT (
END_POINT_ID int NOT NULL,
END_POINT_NAME varchar(16) NOT NULL,
PRIMARY KEY (END_POINT_ID)
);
ALTER TABLE NOTIFICATION_END_POINT ADD UNIQUE (END_POINT_ID);
ALTER TABLE NOTIFICATION_END_POINT ADD UNIQUE (END_POINT_NAME);
CREATE TABLE NOTIFICATION_MODE (
MODE_ID int NOT NULL,
MODE_NAME varchar(16) NOT NULL,
PRIMARY KEY (MODE_ID)
);
ALTER TABLE NOTIFICATION_MODE ADD UNIQUE (MODE_ID);
ALTER TABLE NOTIFICATION_MODE ADD UNIQUE (MODE_NAME);
CREATE TABLE NOTIFICATION_TYPE (
TYPE_ID int NOT NULL,
TYPE_NAME varchar(64) NOT NULL,
PRIMARY KEY (TYPE_ID)
);
ALTER TABLE NOTIFICATION_TYPE ADD UNIQUE (TYPE_ID);
ALTER TABLE NOTIFICATION_TYPE ADD UNIQUE (TYPE_NAME);
CREATE TABLE NOTIFICATION_TEMPLATE (
TEMPLATE_ID int NOT NULL,
END_POINT_ID int NOT NULL,
MODE_ID int NOT NULL,
TYPE_ID int NOT NULL,
PRIMARY KEY (TEMPLATE_ID)
);
ALTER TABLE NOTIFICATION_TEMPLATE ADD UNIQUE (TEMPLATE_ID);
ALTER TABLE NOTIFICATION_TEMPLATE ADD UNIQUE (END_POINT_ID, MODE_ID, TYPE_ID);
ALTER TABLE NOTIFICATION_TEMPLATE ADD CONSTRAINT FK_END_POINT_ID FOREIGN KEY (END_POINT_ID) REFERENCES NOTIFICATION_END_POINT (END_POINT_ID);
ALTER TABLE NOTIFICATION_TEMPLATE ADD CONSTRAINT FK_MODE_ID FOREIGN KEY (MODE_ID) REFERENCES NOTIFICATION_MODE (MODE_ID);
ALTER TABLE NOTIFICATION_TEMPLATE ADD CONSTRAINT FK_TYPE_ID FOREIGN KEY (TYPE_ID) REFERENCES NOTIFICATION_TYPE (TYPE_ID);
CREATE TABLE NOTIFICATION_STATUS (
STATUS_CODE varchar(16) NOT NULL,
DESCRIPTION varchar(256) NOT NULL,
PRIMARY KEY (STATUS_CODE)
);
ALTER TABLE NOTIFICATION_STATUS ADD UNIQUE (STATUS_CODE);
CREATE TABLE NOTIFICATION_HEADER (
HEADER_ID bigint NOT NULL,
END_POINT_ID int NOT NULL,
MODE_ID int NOT NULL,
TYPE_ID int NOT NULL,
STATUS_CODE varchar(16) NOT NULL,
REQUESTED_USER_ID int NOT NULL,
REQUESTED_DATE date NOT NULL,
PROCESSED_DATE date NULL,
COMPLETED_DATE date NULL,
LAST_UPDATED_USER_ID int NULL,
PRIMARY KEY (HEADER_ID)
);
ALTER TABLE NOTIFICATION_HEADER ADD UNIQUE (HEADER_ID);
ALTER TABLE NOTIFICATION_HEADER ADD CONSTRAINT FK_STATUS_CODE FOREIGN KEY (STATUS_CODE) REFERENCES NOTIFICATION_STATUS (STATUS_CODE);
CREATE TABLE NOTIFICATION_DETAIL (
DETAIL_ID bigint NOT NULL,
HEADER_ID bigint NOT NULL,
SEND_TO_ID int NOT NULL,
STATUS_CODE varchar(16) NOT NULL,
COMPLETED_DATE date NULL,
LAST_UPDATED_USER_ID int NULL,
PRIMARY KEY (DETAIL_ID)
);
ALTER TABLE NOTIFICATION_DETAIL ADD UNIQUE (DETAIL_ID);
ALTER TABLE NOTIFICATION_DETAIL ADD CONSTRAINT FK_HEADER_ID FOREIGN KEY (HEADER_ID) REFERENCES NOTIFICATION_HEADER (HEADER_ID);
ALTER TABLE NOTIFICATION_DETAIL ADD CONSTRAINT FK_STATUS_CODE FOREIGN KEY (STATUS_CODE) REFERENCES NOTIFICATION_STATUS (STATUS_CODE);
| true |
413f5de352bf51675e21f034c344cb0dbc628661 | SQL | kenethfv/DB_Project | /Scripts.sql | UTF-8 | 7,230 | 3.578125 | 4 | [] | no_license | /*TABLA DEPARTAMENTO*/
CREATE TABLE departamento (
id_depto NUMBER(9),
departamento VARCHAR2(150),
CONSTRAINT pk_departamento PRIMARY KEY ( id_depto )
);
/*TABLA CABECERA*/
CREATE TABLE cabecera (
id_cabecera NUMBER(9),
cabecera VARCHAR2(150),
id_depto NUMBER(9),
CONSTRAINT pk_cabecera PRIMARY KEY ( id_cabecera ),
CONSTRAINT fk_depto_id FOREIGN KEY ( id_depto ) REFERENCES departamento ( id_depto )
);
/*TABLA TIPO_VIAJE*/
CREATE TABLE tipo_viaje (
id_tipo_viaje NUMBER(9),
tipo VARCHAR2(150),
CONSTRAINT pk_tipo PRIMARY KEY ( id_tipo_viaje )
);
/*TABLA CATEGORIA*/
CREATE TABLE categoria (
id_categoria NUMBER(9),
categoria VARCHAR2(150),
CONSTRAINT pk_categoria PRIMARY KEY ( id_categoria )
);
/*TABLA TIPO_PLACA*/
CREATE TABLE tipo_placa (
id_tipo_placa NUMBER(9),
tipo_placa VARCHAR2(150),
CONSTRAINT pk_tipo_placa PRIMARY KEY ( id_tipo_placa )
);
/*TABLA MARCA*/
CREATE TABLE marca (
id_marca NUMBER(9),
marca VARCHAR2(150),
CONSTRAINT pk_marca PRIMARY KEY ( id_marca )
);
/*TABLA LINEA*/
CREATE TABLE linea (
id_linea NUMBER(9),
linea VARCHAR2(150),
id_marca NUMBER(9),
CONSTRAINT pk_linea PRIMARY KEY ( id_linea ),
CONSTRAINT fk_marca FOREIGN KEY ( id_marca ) REFERENCES marca ( id_marca )
);
/*TABLA COLOR*/
CREATE TABLE color (
id_color NUMBER(9),
color VARCHAR2(150),
CONSTRAINT pk_color PRIMARY KEY ( id_color )
);
/*TABLA TIPO_BUS*/
CREATE TABLE tipo_bus (
id_tipo_bus NUMBER(9),
tipo_bus VARCHAR2(150),
CONSTRAINT pk_tipo_bus PRIMARY KEY ( id_tipo_bus )
);
/*TABLA BUS*/
CREATE TABLE bus (
id_bus NUMBER(9),
placa VARCHAR2(8),
anio VARCHAR2(4),
no_pasajeros NUMBER(3),
estado_bus VARCHAR2(1),
id_tipo_bus NUMBER(9),
id_tipo_placa NUMBER(9),
id_color NUMBER(9),
id_linea NUMBER(9),
CONSTRAINT pk_bus PRIMARY KEY ( id_bus ),
CONSTRAINT fk_bus_tipo FOREIGN KEY ( id_tipo_bus )REFERENCES tipo_bus ( id_tipo_bus ),
CONSTRAINT fk_placa_tipo FOREIGN KEY ( id_tipo_placa ) REFERENCES tipo_placa ( id_tipo_placa ),
CONSTRAINT fk_color FOREIGN KEY ( id_color ) REFERENCES color ( id_color ),
CONSTRAINT fk_linea FOREIGN KEY ( id_linea ) REFERENCES linea ( id_linea )
);
/*TABLA TIPO_LICENCIA*/
CREATE TABLE tipo_licencia (
id_tipo_licencia NUMBER(9),
tipo_licencia VARCHAR2(1),
estado_licencia VARCHAR2(1),
CONSTRAINT pk_tipo_licencia PRIMARY KEY ( id_tipo_licencia )
);
/*TABLA PILOTO*/
CREATE TABLE piloto (
id_piloto NUMBER(9),
nombre VARCHAR2(1),
apellido VARCHAR2(1),
estado_piloto VARCHAR2(1),
no_licencia NUMBER(13),
id_tipo_licencia NUMBER(9),
CONSTRAINT pk_piloto PRIMARY KEY ( id_piloto ),
CONSTRAINT fk_licencia_tipo FOREIGN KEY ( id_tipo_licencia ) REFERENCES tipo_licencia ( id_tipo_licencia )
);
/*TABLA VIAJE*/
CREATE TABLE viaje (
id_viaje NUMBER(9),
id_cabecera_incio NUMBER(9),
id_cabecera_destino NUMBER(9),
id_tipo_viaje NUMBER(9),
id_piloto NUMBER(9),
id_bus NUMBER(9),
id_categoria NUMBER(9),
escala VARCHAR2(1),
fecha_hora_salida TIMESTAMP,
fecha_hora_llegada TIMESTAMP,
CONSTRAINT pk_viaje PRIMARY KEY ( id_viaje ),
CONSTRAINT fk_cabcera_inicio FOREIGN KEY ( id_cabecera_incio ) REFERENCES cabecera ( id_cabecera ),
CONSTRAINT fk_cabcera_destino FOREIGN KEY ( id_cabecera_destino ) REFERENCES cabecera ( id_cabecera ),
CONSTRAINT fk_viaje_tipo FOREIGN KEY ( id_tipo_viaje )REFERENCES tipo_viaje ( id_tipo_viaje ),
CONSTRAINT fk_piloto FOREIGN KEY ( id_piloto ) REFERENCES piloto ( id_piloto ),
CONSTRAINT fk_bus FOREIGN KEY ( id_bus ) REFERENCES bus ( id_bus ),
CONSTRAINT fk_categoria FOREIGN KEY ( id_categoria ) REFERENCES categoria ( id_categoria )
);
/*TABLA ESCALA_VIAJE*/
CREATE TABLE escala_viaje (
id_escala_viaje NUMBER(9),
id_viaje NUMBER(9),
id_cabecera_escala NUMBER(9),
CONSTRAINT pk_escala PRIMARY KEY ( id_escala_viaje ),
CONSTRAINT fk_viaje FOREIGN KEY ( id_viaje ) REFERENCES viaje ( id_viaje ),
CONSTRAINT fk_cabecera FOREIGN KEY ( id_cabecera_escala ) REFERENCES cabecera ( id_cabecera )
);
/*TABLA ENCOMIENDA*/
CREATE TABLE encomienda (
id_encomienda NUMBER(9),
peso NUMBER(13, 2),
precio NUMBER(13, 2),
descripcion VARCHAR2(150),
nombre_remitente VARCHAR2(150),
nombre_destinatario VARCHAR2(150),
telefono NUMBER(8),
CONSTRAINT pk_encomienda PRIMARY KEY ( id_encomienda )
);
/*TABLA TIPO_PAGO*/
CREATE TABLE tipo_pago (
id_tipo_pago NUMBER(9),
tipo_pago VARCHAR2(150),
banco VARCHAR2(150),
CONSTRAINT pk_tipo_pago PRIMARY KEY ( id_tipo_pago )
);
/*TABLA ESTADO_RESERVACION*/
CREATE TABLE estado_reservacion (
id_estado_reserva NUMBER(9),
estado VARCHAR2(150),
CONSTRAINT pk_estado_reserva PRIMARY KEY ( id_estado_reserva )
);
/*TABLA RESERVACION*/
CREATE TABLE reservacion (
id_reservacion NUMBER(9),
id_estado_reserva NUMBER(9),
id_viaje NUMBER(9),
id_tipo_pago NUMBER(9),
nombre VARCHAR2(150),
apellido VARCHAR2(150),
imagen BFILE,
asiento NUMBER(3),
CONSTRAINT pk_reservacion PRIMARY KEY ( id_reservacion ),
CONSTRAINT fk_id_estado_reser FOREIGN KEY ( id_estado_reserva )REFERENCES estado_reservacion ( id_estado_reserva ),
CONSTRAINT fk_viaje_reser FOREIGN KEY ( id_viaje )REFERENCES viaje ( id_viaje ),
CONSTRAINT fk_tipo_pago_reser FOREIGN KEY ( id_tipo_pago ) REFERENCES tipo_pago ( id_tipo_pago )
);
/*TABLA AUTORIZA_RESERVA*/
CREATE TABLE autoriza_reserva (
correlativo NUMBER(9),
id_tipo_pago NUMBER(9),
ID_RESERVACION NUMBER(9),
autorizado_por VARCHAR2(150),
fecha DATE,
CONSTRAINT pk_autoriza_reserva PRIMARY KEY ( correlativo ),
CONSTRAINT fk_pago_tipo FOREIGN KEY ( id_tipo_pago ) REFERENCES tipo_pago ( id_tipo_pago ),
CONSTRAINT fk_reser_id FOREIGN KEY (ID_RESERVACION) REFERENCES RESERVACION(ID_RESERVACION)
);
/*TABLA DETALLE_RESERVACION*/
CREATE TABLE detalle_reservacion (
id_detalle_reserva NUMBER(9),
id_reservacion NUMBER(9),
id_encomienda NUMBER(9),
pasajero NUMBER(3),
total NUMBER(13, 2),
CONSTRAINT pk_detalle_reserva PRIMARY KEY ( id_detalle_reserva ),
CONSTRAINT fk_reserva_deta FOREIGN KEY ( id_reservacion ) REFERENCES reservacion ( id_reservacion ),
CONSTRAINT fk_encomienda_deta FOREIGN KEY ( id_encomienda )REFERENCES encomienda ( id_encomienda )
);
/*TABLA DETALLE_PAGO*/
CREATE TABLE detalle_pago (
id_detalle_pago NUMBER(9),
id_reservacion NUMBER(9),
cantidad NUMBER(10),
precio NUMBER(10, 2),
serie VARCHAR2(30),
CONSTRAINT pk_detalle_pago PRIMARY KEY ( id_detalle_pago ),
CONSTRAINT fk_reserva FOREIGN KEY ( id_reservacion ) REFERENCES reservacion ( id_reservacion )
);
| true |
0f504c822614c53170f83145c670de319097857b | SQL | anshikanigam14/Hackearth-SQL-Challenges | /inventory_data.sql | UTF-8 | 264 | 3.34375 | 3 | [] | no_license | /*Language used: MYSQL*/
select item, sum((BuyQty - SellQty)) as NetQty,
concat(year(trandate),'/',month(trandate)) as MonthEnd
from Inventory
group by item, concat(year(trandate),'/',month(trandate))
order by
item asc, year(trandate) asc, month(trandate) asc; | true |
7ae80ab0f6ec7304e24f6bf146961cf1afb14863 | SQL | sortidocorps/chillyset | /src/main/resources/data.sql | UTF-8 | 1,646 | 3.625 | 4 | [] | no_license |
/**
CREATE TABLE `SIMPLE_OBJECT` (
`Id` BIGINT NOT NULL,
`Name` NVARCHAR(45) NOT NULL,
`CasualName` NVARCHAR(45),
`Location` NVARCHAR(20)
);
CREATE TABLE `HUGE_OBJECT` (
`Id` BIGINT NOT NULL,
`Name` NVARCHAR(45) NOT NULL,
`Comment` NVARCHAR(500)
);
*/
INSERT INTO SIMPLE_OBJECT VALUES (1, 'Apis Mellifera Mellifera', 'abeille noire', 'Europe');
INSERT INTO SIMPLE_OBJECT VALUES (2, 'Apis Mellifera Ligustica', 'abeille italienne', 'Italie');
INSERT INTO SIMPLE_OBJECT VALUES (3, 'Apis mellifera caucasica', 'abeille caucasienne', 'Europe');
INSERT INTO SIMPLE_OBJECT VALUES (4, 'Apis mellifera carnica', 'abeille carnolienne', 'Autriche');
INSERT INTO SIMPLE_OBJECT VALUES (5, 'Buckfast', 'abeille Buckfast', 'Angleterre');
/*
INSERT INTO HUGE_OBJECT VALUES (1, 'Ruche en paille', 'elle a la forme d’une voute, sans socle ni rayons, avec un trou par lequel les abeilles entrent et sortent de la ruche');
INSERT INTO HUGE_OBJECT VALUES (2, 'Ruche kenyane', 'modele de forme trapezoidale, inspire de la ruche traditionnelle grecque economique et facile a construire');
INSERT INTO HUGE_OBJECT VALUES (3, 'Ruche Dadant', 'son volume offre plus de de reserves pour les periodes d’hivernage. Sur notre boutique, voici un modele de ruche dadant');
INSERT INTO HUGE_OBJECT VALUES (4, 'Ruche Langstroth', 'un autre modele standard, tres prise par les apiculteurs. Sa conception tient compte du confort des abeilles et l’emplacement des cadres est ideal');
INSERT INTO HUGE_OBJECT VALUES (5, 'Ruche Layens', 'delaissee en France, mais encore presente en Espagne. C’est une ruche avec des hausses uniquement sur la longueur');
*/
| true |
95ce94722b155245418d5e1d42595c5f1f61ca4e | SQL | Ensembl/ensembl | /sql/patch_74_75_e.sql | UTF-8 | 1,568 | 2.59375 | 3 | [
"GPL-1.0-or-later",
"Artistic-2.0",
"Artistic-1.0",
"Apache-2.0",
"Artistic-1.0-Perl"
] | permissive | -- Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
-- Copyright [2016-2023] EMBL-European Bioinformatics Institute
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
# patch_74_75_e.sql
#
# title: Add unique constraint on attrib tables
#
# description:
# For all attrib related tables, attrib_type_id and value should be unique for a given object
ALTER TABLE seq_region_attrib ADD UNIQUE KEY region_attribx (seq_region_id, attrib_type_id, value(500));
ALTER TABLE gene_attrib ADD UNIQUE KEY gene_attribx (gene_id, attrib_type_id, value(500));
ALTER TABLE transcript_attrib ADD UNIQUE KEY transcript_attribx (transcript_id, attrib_type_id, value(500));
ALTER TABLE translation_attrib ADD UNIQUE KEY translation_attribx (translation_id, attrib_type_id, value(500));
ALTER TABLE misc_attrib ADD UNIQUE KEY misc_attribx (misc_feature_id, attrib_type_id, value(500));
# patch identifier
INSERT INTO meta (species_id, meta_key, meta_value) VALUES (NULL, 'patch', 'patch_74_75_e.sql|unique_attrib_key');
| true |
1b602b932afdd435101074026b04a46f2a9c36f3 | SQL | GayatriHushe/Swabhav-Database-Mysql | /TASK/dateFunc.sql | UTF-8 | 155 | 2.6875 | 3 | [] | no_license | DELIMITER //
CREATE FUNCTION GETMYDATE()
RETURNS VARCHAR(20)
BEGIN
RETURN DATE_FORMAT(NOW(), '%Y%m%d');
END; //
DELIMITER ;
SELECT GETMYDATE(); | true |
53a2b9903c915d04edb4acd80b7164dd82fb2591 | SQL | anisimovss/Anisimov_Sergey | /Task_10/Northwind/Tasks/Task_13.2.sql | UTF-8 | 370 | 3.28125 | 3 | [] | no_license | --select * from Northwind.Orders
alter procedure Northwind.ShippedOrdersDiff
@SpecifiedDelay int
as
begin
select OrderID,
OrderDate,
ShippedDate,
DATEDIFF(dd, OrderDate, ShippedDate) as 'ShippedDelay',
@SpecifiedDelay as 'SpecifiedDelay'
from Northwind.Orders
where (DATEDIFF(dd, OrderDate, ShippedDate) > @SpecifiedDelay) or (ShippedDate is null)
end | true |
eb1a43d5ce06036575f2cdf21875558214402ba9 | SQL | dgupta-apttus/EDA | /Snowflake/C1_Product_Metrics/Research/LICENSE_DIM_RESEARCH.sql | UTF-8 | 2,583 | 3.296875 | 3 | [] | no_license | select count(*), LICENSE_NAME, CRM_SOURCE --, LICENSE_ID
FROM APTTUS_DW.PRODUCT.LMA_LIC_PRODUCTLINE_CURRENT
group by LICENSE_NAME, CRM_SOURCE --LICENSE_ID
having count(*) > 1
;
select count(*), SUBSTR(CRM_SOURCE, 1, 1) || '-' || LICENSE_NAME
FROM APTTUS_DW.PRODUCT.LMA_LIC_PRODUCTLINE_CURRENT
group by SUBSTR(CRM_SOURCE, 1, 1) || '-' || LICENSE_NAME
having count(*) > 1
;
select * from APTTUS_DW.PRODUCT.LMA_LIC_PRODUCTLINE_CURRENT
;
CREATE OR REPLACE VIEW APTTUS_DW.PRODUCT.LMA_LICENSE_DIM
COMMENT = 'Attributes of LICENSE_ID'
AS
select LICENSE_ID
, CRM_SOURCE AS CRM
, DATA_SOURCE
, CUSTOMER_ORG
, LICENSE_NAME || '-' || SUBSTR(CRM_SOURCE, 1, 1) AS LICENSE_NAME
, LICENSE_SEAT_TYPE
, PACKAGE_ID
, PACKAGE_ID_AA
, CASE
WHEN IS_SANDBOX = true
THEN 'Sandbox'
WHEN IS_SANDBOX = false
AND (UPPER(STATUS) <> 'ACTIVE'
OR ORG_STATUS NOT IN ('ACTIVE', 'FREE', 'SIGNING_UP')
)
THEN 'Not Production'
WHEN UPPER(STATUS) = 'ACTIVE'
AND ORG_STATUS IN ('ACTIVE', 'FREE', 'SIGNING_UP')
AND IS_SANDBOX = false
AND ACCOUNT_ID is null
THEN 'Active w/o Acc'
WHEN UPPER(STATUS) = 'ACTIVE'
AND ORG_STATUS IN ('ACTIVE', 'FREE', 'SIGNING_UP')
AND IS_SANDBOX = false
THEN 'Active'
ELSE 'Unknown'
END AS COMPOSIT_LIC_STATUS
, STATUS
, ORG_STATUS
, IS_SANDBOX
, INSTALL_DATE
, UNINSTALL_DATE
, MONTHS_INSTALLED
, INSTALL_DATE_STRING
, EXPIRATION_DATE
, EXPIRATION_DATE_STRING
, ACCOUNT_ID
, OLDCRM_ACCOUNT_ID
, CONGA_ENFORCE_LMA__C
from APTTUS_DW.PRODUCT.LMA_LIC_PRODUCTLINE_CURRENT
where LAST_ACTIVITY_DATE >= (CURRENT_DATE()-366)
OR ( LAST_ACTIVITY_DATE < (CURRENT_DATE()-366)
AND UPPER(STATUS) = 'ACTIVE'
AND EXPIRATION_DATE_STRING NOT IN ('UNINSTALLED', 'EXPIRED')
AND ORG_STATUS NOT IN ('DELETED')
)
;
| true |
702d232ed834a00424600545beefed19e2c5e189 | SQL | kiirbs/AFPA_Work | /backend/Develop Datacomponant/Programmer des vues/View3.sql | UTF-8 | 151 | 2.796875 | 3 | [] | no_license | CREATE VIEW ListeResa
AS
SELECT reservation.*, CONCAT (cli_nom, ' ', cli_prenom) AS NomComplet FROM reservation, clients
WHERE cli_id = res_cli_id; | true |
8c686278e3915e0c4187ed4fcfde6c99619fb878 | SQL | dawxoje/SQL | /Con Marina/Profesores/DDL_Profesores.sql | UTF-8 | 700 | 3.546875 | 4 | [] | no_license | DROP TABLE Profesores;
DROP TABLE Asignaturas;
DROP TABLE Imparte;
CREATE TABLE Profesores(
dni varchar(10) NOT NULL,
nombre varchar(40),
categoria varchar(4),
ingreso date,
CONSTRAINT pk_profesores PRIMARY KEY(dni)
);
CREATE TABLE Asignaturas(
codigo varchar(5) NOT NULL,
descripcion varchar (35),
creditos numeric(4,1),
creditosp numeric(4,1),
CONSTRAINT pk_asignaturas PRIMARY KEY(codigo)
);
CREATE TABLE Imparte(
dni varchar(10) NOT NULL,
asignatura varchar(5) NOT NULL,
CONSTRAINT pk_imparte PRIMARY KEY(dni, asignatura),
CONSTRAINT fk1_imparte FOREIGN KEY(dni) REFERENCES Profesores(dni),
CONSTRAINT fk2_imparte FOREIGN KEY(asignatura) REFERENCES Asignaturas(codigo)
); | true |
57429f8775bac6cb0f6504ae0dc75c46b547027d | SQL | princesslisa/Learn_and-Practice_SQL | /Udacity/Lesson 2 - Joins/Lesson 2 - Summary on types of Joins.sql | UTF-8 | 575 | 3.546875 | 4 | [] | no_license | /*
INNER JOINS
these return rows that appear on both tables. this is like a cross-section between two tables.
a venn diagram can be used to represent these JOINS
the overlapping middle section shows the rowas for which the on clause is true. one table is selected as a left table and the other is selected as a RIGHT
TYPES OF JOINS
- LEFT JOIN
syntax
SELECT columns
FROM left table
LEFT JOIN right table
the result set will give all the results that match with the right table as well as any results in the left table that did not match
- RIGHT JOIN
- FULL OUTER JOIN
*/
| true |
e8fd735bdd380a50f456c8d8087c0917892757dd | SQL | NVSL/Appliancizer | /API Session.sql | UTF-8 | 2,879 | 3.625 | 4 | [] | no_license | --
-- User Table
--
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username VARCHAR(25) NOT NULL UNIQUE CHECK (LENGTH(username) > 0),
email VARCHAR(255) NOT NULL UNIQUE CHECK (LENGTH(email) > 0),
password VARCHAR(255) NOT NULL CHECK (LENGTH(password) >= 8),
security_level VARCHAR(20) NOT NULL DEFAULT 'user',
created_date TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO users (username, email, password) VALUES ('lal', 'jerobey@example.com',
'asdfasdf');
SELECT * FROM users;
-- TODO: Create a tentative user that has a registration link and
-- expiration date, when the user gets register it should get
-- added to users
--
-- Projects Table
--
CREATE TABLE IF NOT EXISTS projects (
id SERIAL PRIMARY KEY,
user_id INTEGER,
username VARCHAR(25) NOT NULL,
projectname VARCHAR(25) NOT NULL UNIQUE CHECK (LENGTH(projectname) > 0),
projectimage BYTEA,
project JSONB DEFAULT NULL,
updated_date TIMESTAMPTZ NOT NULL,
created_date TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) -- Foregin key enforces that the id must exists in users
);
-- weblink can be constructed with /username/projectname
INSERT INTO projects (user_id, username, projectname, projectimage, project, updated_date)
VALUES (1, 'jerom','pikachu',
lo_import('/mnt/c/Users/jorge/Documents/Github/Applianzer/server/demoImages/demo1.png'),
'{"project": "Hello User World 1"}', NOW());
INSERT INTO projects (user_id, username, projectname, projectimage, project, updated_date)
VALUES (1, 'jerom','bulbasy2',
pg_read_binary_file('demo1.png'),
'{"project": "Hello User World 2"}', NOW());
INSERT INTO projects (user_id, username, projectname, project, updated_date)
VALUES (2, 'admin', 'pidgoto','{"project": "Hello Admin World"}', NOW());
INSERT INTO projects (user_id, username, projectname, project, updated_date) VALUES (3, 'admin', 'charmander','{"project": "Hello Admin World"}', NOW());
SELECT * FROM projects;
SELECT project FROM projects WHERE user_id = 1;
---
--- JOINS
---
SELECT users.username, projects.project
FROM users
INNER JOIN projects ON users.id=projects.user_id;
--
-- Update Project
--
UPDATE projects SET project = '{"project": "Updated3"}', updated_date = NOW() WHERE username = 'jerom' AND projectname = 'pidgoto'
-- Get Project / project exists
SELECT project FROM projects WHERE username = 'jerom' AND projectname = 'pidgoto'
-- Using BYTEA requires pg_read_binary_file and moving the files to
-- api=# show data_directory;
-- else you get a error: ERROR: absolute path not allowed
-- INSERT INTO projects (user_id, username, projectname, projectimage, project, updated_date)
-- VALUES (1, 'jerom','bulbasy2',
-- pg_read_binary_file('/mnt/c/Users/jorge/Documents/Github/Applianzer/server/demoImages/demo1.png'),
-- '{"project": "Hello User World 2"}', NOW()); | true |
a8fdd1b9c8e05801744f5184c945bd5ce26287b2 | SQL | Gcarvalhu/2s2019-sprint-1-bd | /OpFlix/T_03_Gustavo_DQL.sql.sql | WINDOWS-1252 | 862 | 3.40625 | 3 | [
"MIT"
] | permissive | select * from Categoria
select * from Plataforma
SELECT * FROM Lancamentos
select * from Permissao
update Usuarios set IdPermissao = 1 where IdUsuario = 4;
select * from Usuarios
update Lancamentos set DataLanc = '08-07-1994' where IdLanc = 1;
update Lancamentos set Titulo = 'La Casa De Papel - 3 Temporada' where IdLanc = 8;
delete from Lancamentos where IdLanc = 11;
select * from Lancamentos where IdCategoria = 4;
CREATE PROCEDURE ListarFilmesDeFantasia
as
EXEC ListarFilmesDeFantasia;
CREATE PROCEDURE ListarFilmesString @Categoria VARCHAR(259)
AS
SELECT*FROM Lancamentos JOIN Categoria ON Lancamentos.IdCategoria = Categoria.IdCategoria
WHERE Categoria.NomeCategoria = @Categoria;
EXEC ListarFilmesString 'Acao';
CREATE VIEW vwPlataforma AS
SELECT IdPlataforma,Titulo,IdCategoria from Lancamentos
Select * from vwPlataforma
| true |
5822b80f7a27ab1e6fd63efbf3dc244267b31071 | SQL | cartershanklin/structor | /modules/benchmetrics/files/tpc/tpcds.realschema/queries/query16.sql | UTF-8 | 1,018 | 4.25 | 4 | [] | no_license | select
count(distinct cs_order_number) as `order count`
,sum(cs_ext_ship_cost) as `total shipping cost`
,sum(cs_net_profit) as `total net profit`
from
catalog_sales cs1
left semi join
(select distinct(cs_order_number) as cs2_cs_order_number, cs_warehouse_sk as cs2_cs_warehouse_sk
from catalog_sales) cs2
on cs1.cs_order_number = cs2_cs_order_number
left join
(select cr_order_number
from catalog_returns cr1) cr1
on cs1.cs_order_number = cr1.cr_order_number
join customer_address on cs1.cs_ship_addr_sk = ca_address_sk
join call_center on cs1.cs_call_center_sk = cc_call_center_sk
join date_dim on cs1.cs_ship_date_sk = d_date_sk
where
cs2_cs_order_number is not null
and cr1.cr_order_number is null
and ca_state = 'OH'
and cc_county in ('Ziebach County','Williamson County','Walker County','Ziebach County', 'Ziebach County')
and cs_warehouse_sk <> cs2_cs_warehouse_sk
and d_date between '1999-5-01' and (cast('1999-5-01' as date) + interval '60' day)
order by `order count`
limit 100;
| true |
4b250e8d72ef55b4cc78bf723ba6704b4dbad16e | SQL | danielrc14/tarea3grupo9 | /tarea3grupo9.sql | UTF-8 | 2,242 | 3.765625 | 4 | [
"MIT"
] | permissive | CREATE TABLE Users(
`id` int NOT NULL AUTO_INCREMENT,
`nombre` varchar(15) NOT NULL,
`apellido` varchar(15),
`avatar` varchar(20),
`email` varchar(30),
`username` varchar(10) NOT NULL UNIQUE,
`password` varchar(20) NOT NULL,
`status` int NOT NULL DEFAULT 0,
`registro` date,
`ultima_sesion` date,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE Tutorias(
`id` int NOT NULL AUTO_INCREMENT,
`titulo` varchar(15) NOT NULL,
`texto` text NOT NULL,
`fecha` date,
`cupos` real,
`tag` varchar(15),
`user` int NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`user`)
REFERENCES Users(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE Reviews(
`id` int NOT NULL AUTO_INCREMENT,
`review` text(200) NOT NULL,
`fecha` date,
`poster` int NOT NULL,
`tutoria` int NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`poster`)
REFERENCES Users(`id`),
FOREIGN KEY (`tutoria`)
REFERENCES Tutorias(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `Users` (`nombre`, `apellido`, `avatar`, `email`, `username`, `password`, `status`, `registro`, `ultima_sesion`) VALUES
('user01', 'user01', NULL, 'user01@xx.cl', 'user01', 'password', 0, NOW(), NOW()),
('user02', 'user02', NULL, 'user02@xx.cl', 'user02', 'password', 0, NOW(), NOW()),
('user03', 'user03', NULL, 'user03@xx.cl', 'user03', 'password', 0, NOW(), NOW()),
('user04', 'user04', NULL, 'user04@xx.cl', 'user04', 'password', 0, NOW(), NOW()),
('user05', 'user05', NULL, 'user05@xx.cl', 'user05', 'password', 0, NOW(), NOW()),
('user06', 'user06', NULL, 'user06@xx.cl', 'user06', 'password', 0, NOW(), NOW()),
('user07', 'user07', NULL, 'user07@xx.cl', 'user07', 'password', 0, NOW(), NOW()),
('user08', 'user08', NULL, 'user08@xx.cl', 'user08', 'password', 0, NOW(), NOW()),
('user09', 'user09', NULL, 'user09@xx.cl', 'user09', 'password', 0, NOW(), NOW()),
('user10', 'user10', NULL, 'user10@xx.cl', 'user10', 'password', 0, NOW(), NOW());
INSERT INTO `Tutorias` (`titulo`, `texto`, `fecha`, `cupos`, `tag`, `user`) VALUES
('Tutoria test', 'Esta es una tutoría test', NOW(), 20, 'test', 1);
INSERT INTO `Reviews` (`review`, `fecha`, `poster`, `tutoria`) VALUES
('Esta tutoría es muy mala, 0/10', NOW(), 2, 1),
('Esta tutoría es muy buena, 10/10', NOW(), 3, 1);
| true |
8284530e0f36ce00ca916341e3de9c03b0f72fb8 | SQL | dopos/dcape-app-powerdns | /setup.acme.sql | UTF-8 | 1,467 | 3.28125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
SET vars.domain TO :'ACME_DOMAIN';
SET vars.ns TO :'ACME_NS';
SET vars.admin TO :'NS_ADMIN';
DO $_$
DECLARE
v_domain text := current_setting('vars.domain'); -- domain name
v_ns text := current_setting('vars.ns'); -- master DNS host
v_ns_admin text := current_setting('vars.admin'); -- master DNS admin email
v_key text := '00'; -- zone serial suffix
v_domain_id integer; -- internal domain id
v_stamp text; -- zone timestamp
v_soa text; -- zone SOA
BEGIN
IF v_domain = '' THEN
RAISE NOTICE 'ACME_DOMAIN is not set. Skipping acme zone setup';
RETURN;
END IF;
RAISE NOTICE 'Setup acme zone % for nameserver %',v_domain,v_ns;
SELECT INTO v_domain_id id FROM domains WHERE name = v_domain;
IF FOUND THEN
-- no any changes needed after creation
RAISE NOTICE 'Zone already exists. Skipping';
RETURN;
END IF;
INSERT INTO domains (name, type) VALUES
(v_domain, 'NATIVE')
RETURNING id INTO v_domain_id
;
INSERT INTO domainmetadata(domain_id, kind, content) VALUES
(v_domain_id, 'SOA-EDIT-API', 'INCREASE')
;
v_stamp := to_char(current_timestamp, 'YYYYMMDD') || v_key;
v_soa := concat_ws(' ', v_ns, v_ns_admin, v_stamp, '10800 3600 604800 1800');
INSERT INTO records (domain_id, name, ttl, type, prio, content) VALUES
(v_domain_id, v_domain, 60, 'SOA', 0, v_soa)
, (v_domain_id, v_domain, 1800, 'NS', 0, v_ns)
;
END;
$_$;
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.