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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3d0922a1f4ef2dd88bc4a95cc5b0e1af4f14b1f1 | SQL | jramiloQV/Fonade | /FonadeDB/dbo/Stored Procedures/MD_CrearInformeVisita.sql | UTF-8 | 1,436 | 3.359375 | 3 | [] | no_license | /*
Fecha: 16/09/2014.
Nombre: Mauricio Arias Olave.
Procedimiento: MD_CrearInformeVisita
Descripción: Registrar o actualizar el informe de visita que se manipula
desde la ventana "AdicionarInformeVisitaProyecto.aspx".
*/
CREATE PROCEDURE MD_CrearInformeVisita
(
@PARAMETRO VARCHAR(11),
@NombreInforme NVARCHAR(255),
@CodCiudadOrigen INT,
@CodCiudadDestino INT,
@FechaSalida SMALLDATETIME,
@FechaRegreso SMALLDATETIME,
@CodEmpresa INT,
@CodInterventor INT,
@InformacionTecnica TEXT,
@InformacionFinanciera TEXT,
/*Parametros de actulización*/
@CostoVisita NUMERIC(18,0),
@Id_Informe INT
)
AS
IF @PARAMETRO = 'Nuevo'
BEGIN
INSERT INTO InformeVisitaInterventoria(NombreInforme,CodCiudadOrigen, CodCiudadDestino, FechaSalida,
FechaRegreso, CodEmpresa, FechaInforme, CodInterventor, InformacionTecnica, InformacionFinanciera, Estado)
VALUES(@NombreInforme,@CodCiudadOrigen,@CodCiudadDestino, @FechaSalida, @FechaRegreso, @CodEmpresa, GETDATE(),@CodInterventor, @InformacionTecnica, @InformacionFinanciera,0)
END
IF @PARAMETRO = 'Actualizar'
BEGIN
UPDATE InformeVisitaInterventoria
SET NombreInforme = @NombreInforme,
CodCiudadOrigen = @CodCiudadOrigen,
CodCiudadDestino = @CodCiudadDestino,
FechaSalida = @FechaSalida,
FechaRegreso = @FechaRegreso,
CostoVisita = @CostoVisita,
InformacionTecnica = @InformacionTecnica,
InformacionFinanciera = @InformacionFinanciera
WHERE Id_Informe = @Id_Informe
END | true |
4854c1cf83f757a5668cf4da145e91c0569b196b | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/low/day25/select1453.sql | UTF-8 | 178 | 2.671875 | 3 | [] | no_license |
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o
WHERE timestamp>'2017-11-24T14:53:00Z' AND timestamp<'2017-11-25T14:53:00Z' AND temperature>=12 AND temperature<=79
| true |
09a5d8af8692531fc15abea48c80a4c178864792 | SQL | nisngyo/bf_shop | /install/install.sql | UTF-8 | 10,418 | 2.90625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- 主机: localhost
-- 生成日期: 2020-04-25 13:16:35
-- 服务器版本: 5.7.26
-- PHP 版本: 7.3.4
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 */;
--
-- 数据库: `faka`
--
-- --------------------------------------------------------
--
-- 表的结构 `bf_admin`
--
CREATE TABLE `bf_admin` (
`id` int(11) NOT NULL,
`username` text NOT NULL,
`password` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bf_admin`
--
INSERT INTO `bf_admin` (`id`, `username`, `password`) VALUES
(1, 'admin', 'f6eaa20e3d6599c031e59b1f20d13a81');
-- --------------------------------------------------------
--
-- 表的结构 `bf_config`
--
CREATE TABLE `bf_config` (
`id` int(11) NOT NULL,
`gg` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '公告',
`name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '网站名字',
`upkey` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`rec` int(11) NOT NULL COMMENT '首页推荐数量',
`kf` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '客服',
`monit` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '邮件key',
`copy` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '网站底部',
`link` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '友情链接',
`emailfk` int(11) NOT NULL DEFAULT '0',
`stockno` int(11) NOT NULL DEFAULT '0' COMMENT '库存显示',
`querygg` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT '查询页公告',
`early` int(11) NOT NULL DEFAULT '0',
`earlylim` int(11) NOT NULL DEFAULT '0',
`sold` int(11) NOT NULL DEFAULT '0',
`pcgg` text,
`template` int(11) NOT NULL DEFAULT '1',
`logo` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bf_config`
--
INSERT INTO `bf_config` (`id`, `gg`, `name`, `upkey`, `rec`, `kf`, `monit`, `copy`, `link`, `emailfk`, `stockno`, `querygg`, `early`, `earlylim`, `sold`, `pcgg`, `template`, `logo`) VALUES
(1, '<p style=\"color:red\">欢迎使用BF发卡系统</p>', 'BF发卡网', '76978050', 4, '123456', '77058492', '版权所有 BF发卡网 ', '<a href=\"https://osuu.net\">捕风阁</a>', 0, 2, '请输入联系方式或商户单号查询,交易单号无法查询', 0, 3, 0, '测试测试测试测试测试测试测试测试', 1, '1587790283.png');
-- --------------------------------------------------------
--
-- 表的结构 `bf_email`
--
CREATE TABLE `bf_email` (
`id` int(11) NOT NULL,
`mail_stmp` text,
`mail_port` text,
`mail_usr` text,
`mail_pwd` text,
`mail_rece` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bf_email`
--
INSERT INTO `bf_email` (`id`, `mail_stmp`, `mail_port`, `mail_usr`, `mail_pwd`, `mail_rece`) VALUES
(1, '', '465', '', '', '');
-- --------------------------------------------------------
--
-- 表的结构 `bf_goods`
--
CREATE TABLE `bf_goods` (
`id` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`info` longtext,
`img` varchar(110) DEFAULT NULL,
`type_id` int(11) NOT NULL,
`price` float DEFAULT NULL,
`minbuy` int(11) DEFAULT NULL,
`maxbuy` int(11) DEFAULT NULL,
`state` int(11) DEFAULT '1',
`weight` int(4) DEFAULT '1',
`sales` int(11) DEFAULT '0',
`time` int(11) NOT NULL,
`sm1` text,
`sm2` text,
`sm3` text
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bf_goods`
--
INSERT INTO `bf_goods` (`id`, `name`, `info`, `img`, `type_id`, `price`, `minbuy`, `maxbuy`, `state`, `weight`, `sales`, `time`, `sm1`, `sm2`, `sm3`) VALUES
(16, 'BF_TEST_GOODS2', '', '1587790736.png', 15, 5, 1, 9999, 1, 0, 0, 1587704463, '官方正品', '', ''),
(17, 'BF_TEST_GOODS3', '', '1587790750.png', 16, 5, 1, 9999, 1, 0, 0, 1587704475, '', '', ''),
(18, 'BF_TEST_GOODS4', '', '1587790783.png', 13, 5, 1, 9999, 1, 0, 0, 1587704490, '', '', ''),
(19, 'BF_TEST_GOODS5', '', '1587790834.png', 15, 5, 1, 9999, 1, 0, 0, 1587704508, '', '', ''),
(13, 'BF_TEST_GOODS1', '', '1587790718.png', 13, 6, 1, 10, 1, 13, 0, 1587650592, '官方正品', '自动发货', '7天无理由');
-- --------------------------------------------------------
--
-- 表的结构 `bf_km`
--
CREATE TABLE `bf_km` (
`id` int(11) NOT NULL,
`goodsid` int(11) NOT NULL,
`km` text,
`starttime` int(11) DEFAULT NULL,
`endtime` int(11) DEFAULT NULL,
`out_trade_no` varchar(100) DEFAULT NULL,
`trade_no` varchar(100) DEFAULT NULL,
`user` varchar(50) DEFAULT NULL,
`status` int(11) DEFAULT '0',
`gName` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `bf_order`
--
CREATE TABLE `bf_order` (
`id` int(11) NOT NULL,
`out_trade_no` varchar(100) DEFAULT NULL,
`trade_no` varchar(100) DEFAULT NULL,
`goodsid` int(11) DEFAULT NULL,
`money` float DEFAULT NULL,
`user` varchar(30) DEFAULT NULL,
`type` varchar(20) DEFAULT NULL,
`startTime` int(11) DEFAULT NULL,
`endTime` int(11) DEFAULT NULL,
`number` int(11) DEFAULT NULL,
`status` int(11) DEFAULT '0',
`gName` text,
`flag` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `bf_pay`
--
CREATE TABLE `bf_pay` (
`id` int(11) NOT NULL,
`alipay` int(11) NOT NULL DEFAULT '0',
`wxpay` int(11) NOT NULL DEFAULT '0',
`qqpay` int(11) NOT NULL DEFAULT '0',
`epayurl` text,
`epayid` text,
`epaykey` text,
`codeid` text,
`codekey` text,
`ali_partner` text,
`ali_seller` text,
`ali_key` text,
`f2f_appid` text,
`f2f_public` text,
`f2f_private` text,
`wx_appid` text,
`wx_mchid` text,
`wx_key` text,
`wx_secret` text,
`qq_mchid` text,
`qq_mchkey` text
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bf_pay`
--
INSERT INTO `bf_pay` (`id`, `alipay`, `wxpay`, `qqpay`, `epayurl`, `epayid`, `epaykey`, `codeid`, `codekey`, `ali_partner`, `ali_seller`, `ali_key`, `f2f_appid`, `f2f_public`, `f2f_private`, `wx_appid`, `wx_mchid`, `wx_key`, `wx_secret`, `qq_mchid`, `qq_mchkey`) VALUES
(1, 0, 0, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
-- --------------------------------------------------------
--
-- 表的结构 `bf_promotion`
--
CREATE TABLE `bf_promotion` (
`id` int(11) NOT NULL,
`name` varchar(100) DEFAULT NULL,
`endtime` int(11) NOT NULL,
`goodsid` int(11) DEFAULT NULL,
`discount` int(11) NOT NULL,
`gName` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bf_promotion`
--
INSERT INTO `bf_promotion` (`id`, `name`, `endtime`, `goodsid`, `discount`, `gName`) VALUES
(29, '新品', 1588780800, 13, 4, 'BF_TEST_GOODS1');
-- --------------------------------------------------------
--
-- 表的结构 `bf_swiper`
--
CREATE TABLE `bf_swiper` (
`id` int(11) NOT NULL,
`img` text NOT NULL,
`url` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bf_swiper`
--
INSERT INTO `bf_swiper` (`id`, `img`, `url`) VALUES
(1, 'upload/1.JPG', 'http://osuu.net'),
(3, 'upload/2.JPG', 'http://mall.osuu.net'),
(6, 'upload/3.JPG', 'http://osuu.net');
-- --------------------------------------------------------
--
-- 表的结构 `bf_type`
--
CREATE TABLE `bf_type` (
`id` int(11) NOT NULL,
`name` varchar(100) DEFAULT NULL,
`starttime` int(11) NOT NULL,
`weight` int(11) DEFAULT '0',
`status` int(11) DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bf_type`
--
INSERT INTO `bf_type` (`id`, `name`, `starttime`, `weight`, `status`) VALUES
(13, 'BF_TEST_1', 1586837368, 9, 1),
(15, 'BF_TEST_2', 1587790623, 5, 1),
(16, 'BF_TEST_3', 1587790631, 5, 1);
--
-- 转储表的索引
--
--
-- 表的索引 `bf_admin`
--
ALTER TABLE `bf_admin`
ADD PRIMARY KEY (`id`),
ADD KEY `id` (`id`);
--
-- 表的索引 `bf_config`
--
ALTER TABLE `bf_config`
ADD PRIMARY KEY (`id`);
--
-- 表的索引 `bf_email`
--
ALTER TABLE `bf_email`
ADD PRIMARY KEY (`id`);
--
-- 表的索引 `bf_goods`
--
ALTER TABLE `bf_goods`
ADD PRIMARY KEY (`id`);
--
-- 表的索引 `bf_km`
--
ALTER TABLE `bf_km`
ADD PRIMARY KEY (`id`);
--
-- 表的索引 `bf_order`
--
ALTER TABLE `bf_order`
ADD PRIMARY KEY (`id`);
--
-- 表的索引 `bf_pay`
--
ALTER TABLE `bf_pay`
ADD PRIMARY KEY (`id`);
--
-- 表的索引 `bf_promotion`
--
ALTER TABLE `bf_promotion`
ADD PRIMARY KEY (`id`);
--
-- 表的索引 `bf_swiper`
--
ALTER TABLE `bf_swiper`
ADD PRIMARY KEY (`id`),
ADD KEY `id` (`id`);
--
-- 表的索引 `bf_type`
--
ALTER TABLE `bf_type`
ADD PRIMARY KEY (`id`);
--
-- 在导出的表使用AUTO_INCREMENT
--
--
-- 使用表AUTO_INCREMENT `bf_config`
--
ALTER TABLE `bf_config`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
--
-- 使用表AUTO_INCREMENT `bf_email`
--
ALTER TABLE `bf_email`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- 使用表AUTO_INCREMENT `bf_goods`
--
ALTER TABLE `bf_goods`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;
--
-- 使用表AUTO_INCREMENT `bf_km`
--
ALTER TABLE `bf_km`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=257;
--
-- 使用表AUTO_INCREMENT `bf_order`
--
ALTER TABLE `bf_order`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=50;
--
-- 使用表AUTO_INCREMENT `bf_pay`
--
ALTER TABLE `bf_pay`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- 使用表AUTO_INCREMENT `bf_promotion`
--
ALTER TABLE `bf_promotion`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=30;
--
-- 使用表AUTO_INCREMENT `bf_swiper`
--
ALTER TABLE `bf_swiper`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- 使用表AUTO_INCREMENT `bf_type`
--
ALTER TABLE `bf_type`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
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 |
41b8393c9bfa5bcc02fc1e468c639de690302913 | SQL | cs50/problems | /songs/setup.sql | UTF-8 | 22,919 | 3.203125 | 3 | [] | no_license | -- Create tables
CREATE TABLE movies (
id INTEGER,
title TEXT NOT NULL,
year TEXT,
PRIMARY KEY(id)
);
CREATE TABLE people (
id INTEGER,
name TEXT NOT NULL,
birth TEXT,
PRIMARY KEY(id)
);
CREATE TABLE stars (
movie_id INTEGER NOT NULL,
person_id INTEGER NOT NULL
);
CREATE TABLE directors (
movie_id INTEGER NOT NULL,
person_id INTEGER NOT NULL
);
CREATE TABLE ratings (
movie_id INTEGER NOT NULL,
rating REAL NOT NULL,
votes INTEGER NOT NULL,
PRIMARY KEY(movie_id)
);
-- Movies and Ratings
INSERT INTO movies (title, year) VALUES ("A Few Good Men", 1992);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "A Few Good Men"), 7.7, 218512);
INSERT INTO movies (title, year) VALUES ("The Shawshank Redemption", 1994);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "The Shawshank Redemption"), 9.3, 2150648);
INSERT INTO movies (title, year) VALUES ("Toy Story", 1995);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Toy Story"), 8.3, 819238);
INSERT INTO movies (title, year) VALUES ("Apollo 13", 1995);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Apollo 13"), 7.6, 250710);
INSERT INTO movies (title, year) VALUES ("Catch Me If You Can", 2002);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Catch Me If You Can"), 8.1, 741363);
INSERT INTO movies (title, year) VALUES ("Harry Potter and the Chamber of Secrets", 2002);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Harry Potter and the Chamber of Secrets"), 7.4, 504212);
INSERT INTO movies (title, year) VALUES ("Harry Potter and the Sorcerer's Stone", 2001);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Harry Potter and the Sorcerer's Stone"), 7.6, 582405);
INSERT INTO movies (title, year) VALUES ("Harry Potter and the Prisoner of Azkaban", 2004);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Harry Potter and the Prisoner of Azkaban"), 7.9, 500820);
INSERT INTO movies (title, year) VALUES ("The Incredibles", 2004);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "The Incredibles"), 8.0, 616425);
INSERT INTO movies (title, year) VALUES ("Corpse Bride", 2005);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Corpse Bride"), 7.3, 227219);
INSERT INTO movies (title, year) VALUES ("Charlie and the Chocolate Factory", 2005);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Charlie and the Chocolate Factory"), 6.6, 396753);
INSERT INTO movies (title, year) VALUES ("Harry Potter and the Goblet of Fire", 2005);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Harry Potter and the Goblet of Fire"), 7.7, 499613);
INSERT INTO movies (title, year) VALUES ("The Departed", 2006);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "The Departed"), 8.5, 1099707);
INSERT INTO movies (title, year) VALUES ("Harry Potter and the Order of the Phoenix", 2007);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Harry Potter and the Order of the Phoenix"), 7.5, 464255);
INSERT INTO movies (title, year) VALUES ("The Dark Knight", 2008);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "The Dark Knight"), 9.0, 2121210);
INSERT INTO movies (title, year) VALUES ("Iron Man", 2008);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Iron Man"), 7.9, 884358);
INSERT INTO movies (title, year) VALUES ("Slumdog Millionaire", 2008);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Slumdog Millionaire"), 8.0, 757439);
INSERT INTO movies (title, year) VALUES ("Kung Fu Panda", 2008);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Kung Fu Panda"), 7.5, 389857);
INSERT INTO movies (title, year) VALUES ("Harry Potter and the Half-Blood Prince", 2009);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Harry Potter and the Half-Blood Prince"), 7.6, 428590);
INSERT INTO movies (title, year) VALUES ("Alice in Wonderland", 2010);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Alice in Wonderland"), 6.4, 363967);
INSERT INTO movies (title, year) VALUES ("The King's Speech", 2010);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "The King's Speech"), 8.0, 602856);
INSERT INTO movies (title, year) VALUES ("Harry Potter and the Deathly Hallows: Part 1", 2010);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Harry Potter and the Deathly Hallows: Part 1"), 7.7, 435733);
INSERT INTO movies (title, year) VALUES ("Shutter Island", 2010);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Shuttler Island"), 8.1, 1031803);
INSERT INTO movies (title, year) VALUES ("How to Train Your Dragon", 2010);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "How to Train Your Dragon"), 8.1, 623307);
INSERT INTO movies (title, year) VALUES ("Toy Story 3", 2010);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Toy Story 3"), 8.3, 704300);
INSERT INTO movies (title, year) VALUES ("Iron Man 2", 2010);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Iron Man 2"), 7.0, 674548);
INSERT INTO movies (title, year) VALUES ("Inception", 2010);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Inception"), 8.8, 1885009);
INSERT INTO movies (title, year) VALUES ("Harry Potter and the Deathly Hallows: Part 2", 2011);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Harry Potter and the Deathly Hallows: Part 2"), 8.1, 705872);
INSERT INTO movies (title, year) VALUES ("X-Men: First Class", 2011);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "X-Men: First Class"), 7.7, 619146);
INSERT INTO movies (title, year) VALUES ("Looper", 2012);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Looper"), 7.4, 507656);
INSERT INTO movies (title, year) VALUES ("Django Unchained", 2012);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Django Unchained"), 8.4, 1244109);
INSERT INTO movies (title, year) VALUES ("Prometheus", 2012);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Prometheus"), 7.0, 545157);
INSERT INTO movies (title, year) VALUES ("The Avengers", 2012);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "The Avengers"), 8.0, 1203836);
INSERT INTO movies (title, year) VALUES ("Life of Pi", 2012);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Life of Pi"), 7.9, 545552);
INSERT INTO movies (title, year) VALUES ("42", 2013);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "42"), 7.5, 79004);
INSERT INTO movies (title, year) VALUES ("The Wolf of Wall Street", 2013);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "The Wolf of Wall Street"), 8.2, 1064692);
INSERT INTO movies (title, year) VALUES ("Boyhood", 2014);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Boyhood"), 7.9, 319637);
INSERT INTO movies (title, year) VALUES ("Interstellar", 2014);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Interstellar"), 8.6, 1340748);
INSERT INTO movies (title, year) VALUES ("Get on Up", 2014);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Get on Up"), 6.9, 19303);
INSERT INTO movies (title, year) VALUES ("Draft Day", 2014);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Draft Day"), 6.8, 49763);
INSERT INTO movies (title, year) VALUES ("The Revenant", 2015);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "The Revenant"), 8.0, 639623);
INSERT INTO movies (title, year) VALUES ("Alice Through the Looking Glass", 2016);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Alice Through the Looking Glass"), 6.2, 82595);
INSERT INTO movies (title, year) VALUES ("Message from the King", 2016);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Message from the King"), 6.4, 10031);
INSERT INTO movies (title, year) VALUES ("Harry Potter: A History of Magic", 2017);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Harry Potter: A History of Magic"), 7.2, 213);
INSERT INTO movies (title, year) VALUES ("Marshall", 2017);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Marshall"), 7.2, 547247);
INSERT INTO movies (title, year) VALUES ("Black Panther", 2018);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Black Panther"), 7.3, 546919);
INSERT INTO movies (title, year) VALUES ("Avengers: Infinity War", 2018);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Avengers: Infinity War"), 8.5, 718385);
INSERT INTO movies (title, year) VALUES ("Roma", 2018);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Roma"), 7.4, 10594);
INSERT INTO movies (title, year) VALUES ("Incredibles 2", 2018);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Incredibles 2"), 7.7, 217333);
INSERT INTO movies (title, year) VALUES ("Eighth Grade", 2018);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Eighth Grade"), 7.5, 328713);
INSERT INTO movies (title, year) VALUES ("The Professor", 2018);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "The Professor"), 6.7, 12778);
INSERT INTO movies (title, year) VALUES ("Toy Story 4", 2019);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Toy Story 4"), 8.0, 118112);
INSERT INTO movies (title, year) VALUES ("Gemini Man", 2019);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Gemini Man"), 5.7, 13752);
INSERT INTO movies (title, year) VALUES ("Happy Times", 2019);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Happy Times"), 10.0, 6);
INSERT INTO movies (title, year) VALUES ("Kirklet", 2019);
INSERT INTO ratings (movie_id, rating, votes) VALUES
((SELECT id FROM movies WHERE title = "Kirklet"), 10.0, 555);
-- People
INSERT INTO people (name, birth) VALUES ("Colin Firth", 1960);
INSERT INTO people (name, birth) VALUES ("Don Rickles", 1926);
INSERT INTO people (name, birth) VALUES ("Christopher Nolan", 1970);
INSERT INTO people (name, birth) VALUES ("Bill Paxton", 1955);
INSERT INTO people (name, birth) VALUES ("Brad Bird", 1957);
INSERT INTO people (name, birth) VALUES ("Frank Darabont", 1959);
INSERT INTO people (name, birth) VALUES ("Gary Sinise", 1955);
INSERT INTO people (name, birth) VALUES ("James McAvoy", 1979);
INSERT INTO people (name, birth) VALUES ("Tom Cruise", 1962);
INSERT INTO people (name, birth) VALUES ("Jim Varney", 1949);
INSERT INTO people (name, birth) VALUES ("Emma Watson", 1990);
INSERT INTO people (name, birth) VALUES ("Jennifer Lawrence", 1990);
INSERT INTO people (name, birth) VALUES ("Emma Stone", 1988);
INSERT INTO people (name, birth) VALUES ("Mackenzie Foy", 2000);
INSERT INTO people (name, birth) VALUES ("Anne Hathaway", 1982);
INSERT INTO people (name, birth) VALUES ("Ethan Hawke", 1970);
INSERT INTO people (name, birth) VALUES ("Michael Fassbender", 1977);
INSERT INTO people (name, birth) VALUES ("Tom Hanks", 1956);
INSERT INTO people (name, birth) VALUES ("Helena Bonham Carter", 1966);
INSERT INTO people (name, birth) VALUES ("Yimou Zhang", 1951);
INSERT INTO people (name, birth) VALUES ("Tim Allen", 1953);
INSERT INTO people (name, birth) VALUES ("Jessica Chastain", 1977);
INSERT INTO people (name, birth) VALUES ("Johnny Depp", 1963);
INSERT INTO people (name, birth) VALUES ("Kevin Bacon", 1958);
INSERT INTO people (name, birth) VALUES ("Leonardo DiCaprio", 1974);
INSERT INTO people (name, birth) VALUES ("Matthew McConaughey", 1969);
INSERT INTO people (name, birth) VALUES ("Ellar Coltrane", 1994);
INSERT INTO people (name, birth) VALUES ("Patricia Arquette", 1968);
INSERT INTO people (name, birth) VALUES ("Chadwick Boseman", 1977);
INSERT INTO people (name, birth) VALUES ("Samuel L. Jackson", 1948);
INSERT INTO people (name, birth) VALUES ("Holly Hunter", 1958);
INSERT INTO people (name, birth) VALUES ("Jason Lee", 1970);
INSERT INTO people (name, birth) VALUES ("Craig T. Nelson", 1944);
INSERT INTO people (name, birth) VALUES ("Richard Griffifths", 1947);
INSERT INTO people (name, birth) VALUES ("Rupert Grint", 1988);
INSERT INTO people (name, birth) VALUES ("Daniel Radcliffe", 1989);
-- Stars
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Tom Hanks"),
(SELECT id FROM movies WHERE title = "Toy Story"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Tim Allen"),
(SELECT id FROM movies WHERE title = "Toy Story"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Don Rickles"),
(SELECT id FROM movies WHERE title = "Toy Story"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Jim Varney"),
(SELECT id FROM movies WHERE title = "Toy Story"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Ellar Coltrane"),
(SELECT id FROM movies WHERE title = "Boyhood"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Patricia Arquette"),
(SELECT id FROM movies WHERE title = "Boyhood"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Ethan Hawke"),
(SELECT id FROM movies WHERE title = "Boyhood"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Matthew McConaughey"),
(SELECT id FROM movies WHERE title = "Interstellar"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Anne Hathaway"),
(SELECT id FROM movies WHERE title = "Interstellar"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Jessica Chastain"),
(SELECT id FROM movies WHERE title = "Interstellar"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Mackenzie Foy"),
(SELECT id FROM movies WHERE title = "Interstellar"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Leonardo DiCaprio"),
(SELECT id FROM movies WHERE title = "Inception"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Leonardo DiCaprio"),
(SELECT id FROM movies WHERE title = "The Departed"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Leonardo DiCaprio"),
(SELECT id FROM movies WHERE title = "Django Unchained"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Leonardo DiCaprio"),
(SELECT id FROM movies WHERE title = "The Wolf of Wall Street"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Leonardo DiCaprio"),
(SELECT id FROM movies WHERE title = "Catch Me If You Can"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Leonardo DiCaprio"),
(SELECT id FROM movies WHERE title = "The Revenant"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Johnny Depp"),
(SELECT id FROM movies WHERE title = "Corpse Bride"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Helena Bonham Carter"),
(SELECT id FROM movies WHERE title = "Corpse Bride"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Johnny Depp"),
(SELECT id FROM movies WHERE title = "Charlie and the Chocolate Factory"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Helena Bonham Carter"),
(SELECT id FROM movies WHERE title = "Charlie and the Chocolate Factory"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Johnny Depp"),
(SELECT id FROM movies WHERE title = "Alice in Wonderland"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Helena Bonham Carter"),
(SELECT id FROM movies WHERE title = "Alice in Wonderland"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Johnny Depp"),
(SELECT id FROM movies WHERE title = "Alice Through the Looking Glass"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Helena Bonham Carter"),
(SELECT id FROM movies WHERE title = "Alice Through the Looking Glass"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Johnny Depp"),
(SELECT id FROM movies WHERE title = "The Professor"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Helena Bonham Carter"),
(SELECT id FROM movies WHERE title = "The King's Speech"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Colin Firth"),
(SELECT id FROM movies WHERE title = "The King's Speech"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Kevin Bacon"),
(SELECT id FROM movies WHERE title = "X-Men: First Class"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Kevin Bacon"),
(SELECT id FROM movies WHERE title = "Apollo 13"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Kevin Bacon"),
(SELECT id FROM movies WHERE title = "A Few Good Men"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "James McAvoy"),
(SELECT id FROM movies WHERE title = "X-Men: First Class"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Michael Fassbender"),
(SELECT id FROM movies WHERE title = "X-Men: First Class"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Jennifer Lawrence"),
(SELECT id FROM movies WHERE title = "X-Men: First Class"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Tom Hanks"),
(SELECT id FROM movies WHERE title = "Apollo 13"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Bill Paxton"),
(SELECT id FROM movies WHERE title = "Apollo 13"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Gary Sinise"),
(SELECT id FROM movies WHERE title = "Apollo 13"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Tom Cruise"),
(SELECT id FROM movies WHERE title = "A Few Good Men"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Chadwick Boseman"),
(SELECT id FROM movies WHERE title = "42"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Chadwick Boseman"),
(SELECT id FROM movies WHERE title = "Black Panther"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Chadwick Boseman"),
(SELECT id FROM movies WHERE title = "Marshall"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Chadwick Boseman"),
(SELECT id FROM movies WHERE title = "Get on Up"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Chadwick Boseman"),
(SELECT id FROM movies WHERE title = "Draft Day"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Chadwick Boseman"),
(SELECT id FROM movies WHERE title = "Message from the King"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Samuel L. Jackson"),
(SELECT id FROM movies WHERE title = "The Incredibles"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Holly Hunter"),
(SELECT id FROM movies WHERE title = "The Incredibles"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Jason Lee"),
(SELECT id FROM movies WHERE title = "The Incredibles"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Craig T. Nelson"),
(SELECT id FROM movies WHERE title = "The Incredibles"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Richard Griffifths"),
(SELECT id FROM movies WHERE title = "Harry Potter and the Prisoner of Azkaban"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Rupert Grint"),
(SELECT id FROM movies WHERE title = "Harry Potter and the Prisoner of Azkaban"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Daniel Radcliffe"),
(SELECT id FROM movies WHERE title = "Harry Potter and the Prisoner of Azkaban"));
INSERT INTO stars (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Emma Watson"),
(SELECT id FROM movies WHERE title = "Harry Potter and the Prisoner of Azkaban"));
-- Directors
INSERT INTO directors (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Christopher Nolan"),
(SELECT id FROM movies WHERE title = "The Dark Knight"));
INSERT INTO directors (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Yimou Zhang"),
(SELECT id FROM movies WHERE title = "Happy Times"));
INSERT INTO directors (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Brad Bird"),
(SELECT id FROM movies WHERE title = "Incredibles 2"));
INSERT INTO directors (person_id, movie_id) VALUES (
(SELECT id FROM people WHERE name = "Frank Darabont"),
(SELECT id FROM movies WHERE title = "The Shawshank Redemption"));
| true |
708105e1a4208a3cd57d660d55cacf6401d238cb | SQL | Venkatalakshmi78/Simple-Project-Management-App | /app_db.sql | UTF-8 | 1,698 | 3.40625 | 3 | [
"MIT"
] | permissive | CREATE DATABASE APP_DB;
USE `app_db`;
/*Table structure for table `project_info` */
DROP TABLE IF EXISTS `project_info`;
CREATE TABLE `project_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`project_title` varchar(60) DEFAULT NULL,
`project_start_date` varchar(20) DEFAULT NULL,
`project_end_date` varchar(20) DEFAULT NULL,
`project_status` varchar(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1;
/*Table structure for table `task_details` */
DROP TABLE IF EXISTS `task_details`;
CREATE TABLE `task_details` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`task_id` int(11) DEFAULT NULL,
`user_name` varchar(30) DEFAULT NULL,
`task_comments` varchar(300) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1;
/*Table structure for table `task_info` */
DROP TABLE IF EXISTS `task_info`;
CREATE TABLE `task_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`project_id` int(4) NOT NULL,
`task_title` varchar(60) NOT NULL,
`task_start_date` varchar(20) DEFAULT NULL,
`task_end_date` varchar(20) DEFAULT NULL,
`task_owner` varchar(30) DEFAULT NULL,
`task_status` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=latin1;
/*Table structure for table `user_info` */
DROP TABLE IF EXISTS `user_info`;
CREATE TABLE `user_info` (
`id` int(5) NOT NULL AUTO_INCREMENT,
`email_id` varchar(40) NOT NULL,
`user_name` varchar(25) NOT NULL,
`user_pwd` varchar(25) NOT NULL,
`account_status` varchar(1) NOT NULL,
`account_creation_date` bigint(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=latin1;
| true |
4f70d7a7c47eee31d809512123c27cc6ce93eaf0 | SQL | elixneto/DB1.MestreDosCodigos.SQL | /Escudeiro/dataload.sql | UTF-8 | 1,962 | 3.8125 | 4 | [] | no_license | USE mestredoscodigos;
DELETE atendimento;
DELETE usuario;
DELETE paciente;
DELETE clinica_profissional;
DELETE profissional;
DELETE tipo_profissional;
DELETE clinica;
-----------------------------------------------------------------
INSERT INTO clinica (cnpj, nome_fantasia) VALUES
('04204018000166', 'DB1 CLINICA');
INSERT INTO tipo_profissional (descricao) VALUES
('MÉDICO'),
('FISIOTERAPEUTA'),
('PSIQUIATRA');
INSERT INTO profissional (id_tipo_profissional, nome) VALUES
((SELECT id FROM tipo_profissional WHERE descricao = 'MÉDICO'), 'ÉLIX NETO');
INSERT INTO clinica_profissional (id_clinica, id_profissional)
SELECT c.id, p.id
FROM profissional p
CROSS JOIN clinica c;
INSERT INTO paciente (nome, data_nascimento) VALUES
('TESTE 1', '2000-01-01'),
('TESTE 2', '2000-02-15'),
('TESTE 3', '2000-03-17'),
('TESTE 4', '2000-04-21'),
('TESTE 5', '2000-05-18'),
('TESTE 6', '2000-06-09');
INSERT INTO usuario (email, nome, hash_senha) VALUES
('superuser@db1.com.br', 'ADMIN', 'UuK7O2BhEM+q/Gz+hi/1E+RVbDQ9q7UUIw9Zhm8YwbFx/cMrtx+6tA==');
WITH ElixNeto_DB1 AS (
SELECT TOP 1 id_clinica, id_profissional
FROM clinica_profissional cp
INNER JOIN clinica c ON c.id = cp.id_clinica
INNER JOIN profissional p ON p.id = cp.id_profissional
WHERE c.nome_fantasia = 'DB1 CLINICA'
AND p.nome = 'ÉLIX NETO'
)
INSERT INTO atendimento (id_clinica, id_profissional, id_paciente, id_usuario_inclusao, data_atendimento, aprovado)
SELECT ElixNeto_DB1.id_clinica,
ElixNeto_DB1.id_profissional,
p.id,
u.id,
DATEADD(day, (ABS(CHECKSUM(NEWID())) % 2), GETDATE()),
1
FROM paciente p
CROSS JOIN ElixNeto_DB1
CROSS JOIN usuario u
WHERE u.nome = 'ADMIN';
-----------------------------------------------------------------
-- SELECT * FROM clinica;
-- SELECT * FROM tipo_profissional;
-- SELECT * FROM profissional;
-- SELECT * FROM clinica_profissional;
-- SELECT * FROM paciente;
-- SELECT * FROM usuario;
-- SELECT * FROM atendimento;
| true |
ae1a645d695bf2d54b5f29af4832cfa8e527f305 | SQL | corykitchens/cci-ransomware | /db/schema_dev.sql | UTF-8 | 3,394 | 3.765625 | 4 | [] | no_license | --
-- Table Definitions
--
create table public.contest (
contest_id int not null,
event_date date,
winner_id int
);
create table public.flag (
flag_id int not null,
value varchar(100) not null
);
create table public.team (
team_id int not null,
name varchar(100) not null,
password varchar(100),
admin boolean not null default false
);
create table public.contest_flag (
contest_id int not null,
flag_id int not null
);
create table public.contest_team (
contest_id int not null,
team_id int not null
);
create table public.team_flag (
team_id int not null,
flag_id int not null,
attempt timestamp
);
--
-- Primary Keys
--
alter table public.contest
add constraint contest_pkey primary key (contest_id);
alter table public.flag
add constraint flag_pkey primary key(flag_id);
alter table public.team
add constraint team_pkey primary key(team_id);
--
-- Foreign Keys
--
alter table public.contest
add constraint fk_winner_id foreign key(winner_id)
references public.team (team_id);
alter table public.contest_flag
add constraint fk_contest_id foreign key (contest_id)
references public.contest (contest_id);
alter table public.contest_flag
add constraint fk_flag_id foreign key (flag_id)
references public.flag (flag_id);
alter table public.contest_team
add constraint fk_contest_id foreign key (contest_id)
references public.contest (contest_id);
alter table public.contest_team
add constraint fk_team_id foreign key (team_id)
references public.team (team_id);
alter table public.team_flag
add constraint fk_team_id foreign key (team_id)
references public.team (team_id);
alter table public.team_flag
add constraint fk_flag_id foreign key (flag_id)
references public.flag (flag_id);
-- Create Contest
insert into public.contest
values (1, '2018-06-24');
--
-- Create Passwords
--
insert into public.flag
values (1, 'hello');
insert into public.flag
values (2, 'password123');
insert into public.flag
values (3, 'helloworld');
insert into public.flag
values (4, 'letmein');
insert into public.flag
values (5, 'abc123');
insert into public.flag
values (6, 'mypassword');
--
-- Create Teams
--
insert into public.team(team_id, name, password)
values (1, 'team1', 'team1');
insert into public.team(team_id, name, password)
values (2, 'team2', 'team2');
insert into public.team(team_id, name, password)
values (3, 'team3', 'team3');
insert into public.team(team_id, name, password)
values (4, 'team4', 'team4');
insert into public.team(team_id, name, password, admin)
values(5, 'admin', 'admin', '1');
--
-- Assign Teams to the Contest
--
insert into public.contest_team(contest_id, team_id)
values(1, 1);
insert into public.contest_team(contest_id, team_id)
values(1, 2);
insert into public.contest_team(contest_id, team_id)
values(1, 3);
insert into public.contest_team(contest_id, team_id)
values(1, 4);
insert into public.contest_team(contest_id, team_id)
values(1, 5);
--
-- Assign the Flags to the Contest
--
insert into public.contest_flag(contest_id, flag_id)
values (1, 1);
insert into public.contest_flag(contest_id, flag_id)
values (1, 2);
insert into public.contest_flag(contest_id, flag_id)
values (1, 3);
insert into public.contest_flag(contest_id, flag_id)
values (1, 4);
insert into public.contest_flag(contest_id, flag_id)
values (1, 5);
insert into public.contest_flag(contest_id, flag_id)
values (1, 6);
| true |
e08c3637c3666c9b838f0505fdceb0a966daf81a | SQL | 2002javareact/project-0-Gerard-Cancino | /sql/create-tables.sql | UTF-8 | 1,050 | 3.5625 | 4 | [] | no_license |
drop table if exists "reimbursement";
drop table if exists "user";
drop table if exists "role";
drop table if exists "reimbursement_status";
drop table if exists "reimbursement_type";
create table "role" (
id serial primary key,
"name" varchar not null
);
create table "user" (
id serial primary key,
username varchar unique not null,
"password" varchar not null,
first_name varchar not null,
last_name varchar not null,
email varchar not null,
role_id int4 references "role"(id) not null
);
create table reimbursement_status (
id serial primary key,
status varchar not null
);
create table reimbursement_type(
id serial primary key,
"type" varchar not null
);
create table reimbursement (
id serial primary key,
author_id int4 references "user"(id) not null,
amount numeric not null,
date_submitted int8 not null,
date_resolved int8 not null,
description varchar not null,
resolver_id int4 references "user"(id),
status_id int4 references reimbursement_status(id) not null,
"type" int4 references reimbursement_type(id)
) | true |
72e9565d29f9f211ff114e66a26b0a29e875d410 | SQL | Asbaharoon/ERP_Garment_Ver-1 | /ERP_Garment_Ver-1/MySqlDump/garmentsystem_Raw_Materials.sql | UTF-8 | 2,939 | 2.78125 | 3 | [] | no_license | CREATE DATABASE IF NOT EXISTS `garmentsystem` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `garmentsystem`;
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: itp2016ver1fdgd.cht0bvbob1wj.us-west-2.rds.amazonaws.com Database: garmentsystem
-- ------------------------------------------------------
-- Server version 5.6.27-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `Raw_Materials`
--
DROP TABLE IF EXISTS `Raw_Materials`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Raw_Materials` (
`Material_id` varchar(45) NOT NULL DEFAULT '',
`Material_Name` varchar(45) DEFAULT NULL,
`Material_cost` varchar(45) DEFAULT NULL,
`Material_qty` varchar(45) DEFAULT NULL,
`Material_Value` varchar(45) DEFAULT NULL,
`Material_reorder` varchar(45) DEFAULT NULL,
`Material_date` date DEFAULT NULL,
PRIMARY KEY (`Material_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Raw_Materials`
--
LOCK TABLES `Raw_Materials` WRITE;
/*!40000 ALTER TABLE `Raw_Materials` DISABLE KEYS */;
INSERT INTO `Raw_Materials` VALUES ('mat123','Cotton','1000','100','100000','100','2017-02-17'),('MAT131ecc3fa','LinenFabrickBlack','450','200','90000.0','100','2017-04-03'),('MAT132750492','Silk','500',' 10','5000.0','5','2017-04-03'),('MAT1bcb611fe','LinenFabrickBlack','450','10','4500.0','100','2017-04-30'),('MAT1ddb2a4f4','fabrickBlue','500','30','15000.0','15','2017-05-10'),('MAT1e6252c94','LinenFabrickBlack','450','25','11250.0','100','2017-05-08'),('MAT1e63a3022','jsndjksns','500','20','10000.0','10','2017-05-08'),('MAT1e68163e0','dfdfds','500','30','15000.0','15','2017-05-08');
/*!40000 ALTER TABLE `Raw_Materials` 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 2017-05-08 17:48:43
| true |
dd531c47ac552a15d1c002c0a0fbca1b85abd655 | SQL | musama619/SQL | /OrderBy/OrderBy.sql | UTF-8 | 323 | 3.03125 | 3 | [] | no_license | -- Showing data in order
-- Ascending order
SELECT *
FROM [P12-OrderBreakdown]
ORDER BY [Product Name]
-- Descending Order
SELECT *
FROM [P12-OrderBreakdown]
ORDER BY [Product Name] DESC
-- When data type is not float or integer for numerical data
SELECT *
FROM [P12-OrderBreakdown]
ORDER BY CAST([Sales] as FLOAT) DESC
| true |
dcdc80c4f37bd37fbfb44b32a5cce20dcb760563 | SQL | kklipski/BDProject | /Generator/Tables/Views.sql | WINDOWS-1250 | 1,514 | 2.8125 | 3 | [
"MIT"
] | permissive | ----========================================================================================================================----
----===------------------------------------------Dodawanie widokw bazy--------------------------------------------------===----
----========================================================================================================================----
CREATE OR REPLACE VIEW uczestnicy_uslugi AS SELECT Klienci_Numer_klienta, Baseny_Numer_obiektu FROM UCZESTNICY_LEKCJI
INNER JOIN LEKCJE_PLYWANIA ON UCZESTNICY_LEKCJI.Lekcje_plywania_Numer_lekcji = LEKCJE_PLYWANIA.Numer_lekcji
INNER JOIN OGOLNE ON LEKCJE_PLYWANIA.Ogolne_Numer_uslugi = OGOLNE.Numer_uslugi
INNER JOIN USLUGI ON USLUGI.Ogolne_Numer_uslugi = OGOLNE.Numer_uslugi;
CREATE OR REPLACE VIEW pracownicy_stanowiska AS SELECT Numer_identyfikacyjny, Baseny_numer_obiektu, Nazwa FROM PRACOWNICY
INNER JOIN STANOWISKA ON PRACOWNICY.Stanowiska_Numer_stanowiska = STANOWISKA.Numer_stanowiska;
CREATE OR REPLACE VIEW uczestnicy_lekcje AS SELECT Data_i_godzina, Klienci_numer_klienta FROM LEKCJE_PLYWANIA
INNER JOIN UCZESTNICY_LEKCJI ON UCZESTNICY_LEKCJI.Lekcje_plywania_Numer_lekcji = LEKCJE_PLYWANIA.Numer_lekcji;
CREATE OR REPLACE VIEW rezerwacje_uslugi AS SELECT Baseny_numer_obiektu, Data_i_godzina, Numer_toru, Klienci_numer_klienta FROM REZERWACJE_TORU
INNER JOIN OGOLNE ON OGOLNE.Numer_uslugi = REZERWACJE_TORU.Ogolne_Numer_uslugi
INNER JOIN USLUGI ON USLUGI.Ogolne_Numer_uslugi = OGOLNE.Numer_uslugi; | true |
d4703d92b0b1250eb3be21647c8c48df88dbe667 | SQL | azavea/district-builder-dtl-pa | /sql/011_add_multi_member_districts.sql | UTF-8 | 2,342 | 2.765625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | -- Add columns to configure multi-member districts in the legislative body
SET search_path to publicmapping;
ALTER TABLE redistricting_legislativebody ADD COLUMN multi_members_allowed boolean;
UPDATE redistricting_legislativebody SET multi_members_allowed = false;
ALTER TABLE redistricting_legislativebody ALTER COLUMN multi_members_allowed SET NOT NULL;
ALTER TABLE redistricting_legislativebody ADD COLUMN multi_district_label_format character varying(32);
UPDATE redistricting_legislativebody SET multi_district_label_format = '';
ALTER TABLE redistricting_legislativebody ALTER COLUMN multi_district_label_format SET NOT NULL;
ALTER TABLE redistricting_legislativebody ADD COLUMN min_multi_districts integer;
UPDATE redistricting_legislativebody SET min_multi_districts = 0;
ALTER TABLE redistricting_legislativebody ALTER COLUMN min_multi_districts SET NOT NULL;
ALTER TABLE redistricting_legislativebody ADD COLUMN max_multi_districts integer;
UPDATE redistricting_legislativebody SET max_multi_districts = 0;
ALTER TABLE redistricting_legislativebody ALTER COLUMN max_multi_districts SET NOT NULL;
ALTER TABLE redistricting_legislativebody ADD COLUMN min_multi_district_members integer;
UPDATE redistricting_legislativebody SET min_multi_district_members = 0;
ALTER TABLE redistricting_legislativebody ALTER COLUMN min_multi_district_members SET NOT NULL;
ALTER TABLE redistricting_legislativebody ADD COLUMN max_multi_district_members integer;
UPDATE redistricting_legislativebody SET max_multi_district_members = 0;
ALTER TABLE redistricting_legislativebody ALTER COLUMN max_multi_district_members SET NOT NULL;
ALTER TABLE redistricting_legislativebody ADD COLUMN min_plan_members integer;
UPDATE redistricting_legislativebody SET min_plan_members = 0;
ALTER TABLE redistricting_legislativebody ALTER COLUMN min_plan_members SET NOT NULL;
ALTER TABLE redistricting_legislativebody ADD COLUMN max_plan_members integer;
UPDATE redistricting_legislativebody SET max_plan_members = 0;
ALTER TABLE redistricting_legislativebody ALTER COLUMN max_plan_members SET NOT NULL;
-- Add column to district table for keeping a tally of members
ALTER TABLE redistricting_district ADD COLUMN num_members integer;
UPDATE redistricting_district SET num_members = 1;
ALTER TABLE redistricting_district ALTER COLUMN num_members SET NOT NULL;
| true |
45701d214bbd834a477fcd4dd84ca7c89f591ddc | SQL | PDSW-POSGRADO-ECI/posgrado | /tables.sql | UTF-8 | 7,563 | 3.515625 | 4 | [] | no_license | --- Created by Vertabelo (http://vertabelo.com)
-- Last modification date: 2017-05-02 22:08:34.818
-- tables
-- Table: Asignatura
CREATE TABLE Asignatura (
id int NOT NULL,
nombre varchar(100) NOT NULL,
Posgrado_id int NOT NULL
);
-- Table: Clase
CREATE TABLE Clase (
id int NOT NULL,
hora_inicio time NOT NULL,
hora_fin time NOT NULL,
fecha date NOT NULL,
MateriaCohorte_Materia_sigla varchar(5) NOT NULL,
MateriaCohorte_Cohorte_id int NOT NULL,
MateriaCohorte_Profesor_documento int NOT NULL
);
-- Table: Cohorte
CREATE TABLE Cohorte (
id int NOT NULL,
Periodo_periodo varchar(6) NOT NULL
);
-- Table: Horario
CREATE TABLE Horario (
hora_inicio time NOT NULL,
hora_fin time NOT NULL,
fecha date NOT NULL,
id int NOT NULL
);
-- Table: Materia
CREATE TABLE Materia (
sigla varchar(5) NOT NULL,
nombre varchar(100) NOT NULL,
creditos int NOT NULL,
Asignatura_id int NOT NULL,
descripcion varchar NOT NULL
);
-- Table: MateriaCohorte
CREATE TABLE MateriaCohorte (
Materia_sigla varchar(5) NOT NULL,
Cohorte_id int NOT NULL,
Profesor_documento int NOT NULL
);
-- Table: Periodo
CREATE TABLE Periodo (
periodo varchar(6) NOT NULL,
fecha_inicio date NOT NULL,
fecha_fin date NOT NULL
);
-- Table: Posgrado
CREATE TABLE Posgrado (
id int NOT NULL,
nombre varchar(100) NOT NULL,
creditos int NOT NULL
);
-- Table: PrerequisitoMateria
CREATE TABLE PrerequisitoMateria (
materia_sigla varchar(5) NOT NULL,
prerrequisito_sigla varchar(5) NOT NULL,
correquisito boolean NOT NULL
);
-- Table: Profesor
CREATE TABLE Profesor (
documento int NOT NULL,
nombre varchar NOT NULL,
correo varchar(50) NOT NULL,
telefono int NOT NULL,
tipo_documento varchar(30) NOT NULL
);
-- Table: ProfesorXHorario
CREATE TABLE ProfesorXHorario (
Profesor_documento int NOT NULL,
Horario_id int NOT NULL
);
-- Table: Recurso
CREATE TABLE Recurso (
id int NOT NULL,
recurso varchar(100) NOT NULL,
disponible boolean NOT NULL,
cantidad int NOT NULL
);
-- Table: RecursoClase
CREATE TABLE RecursoClase (
Clase_id int NOT NULL,
Recurso_id int NOT NULL,
cantidadUSE int NOT NULL
);
-- Table: Salon
CREATE TABLE Salon (
especificaciones varchar(30) NOT NULL,
Clase_id int NOT NULL
);
-- Table: Usr
CREATE TABLE Usr (
usuario varchar(10) NOT NULL,
pwd varchar(100) NOT NULL,
salt varchar(5) NOT NULL,
nombre varchar(50) NOT NULL,
rol varchar(30) NOT NULL
);
-- Table: rol
CREATE TABLE rol (
rol varchar(30) NOT NULL
);
-- Table: usrXrol
CREATE TABLE usrXrol (
rol_rol varchar(30) NOT NULL,
usr_usuario int NOT NULL );
-- primary keys unique keys
ALTER TABLE Asignatura ADD CONSTRAINT Asignatura_pk PRIMARY KEY (id);
ALTER TABLE Clase ADD CONSTRAINT Clase_pk PRIMARY KEY (id);
ALTER TABLE Cohorte ADD CONSTRAINT Cohorte_pk PRIMARY KEY (id);
ALTER TABLE Horario ADD CONSTRAINT Horario_pk PRIMARY KEY (id);
ALTER TABLE Materia ADD CONSTRAINT Sigla PRIMARY KEY (sigla);
ALTER TABLE Posgrado ADD CONSTRAINT Posgrado_pk PRIMARY KEY (id);
ALTER TABLE Profesor ADD CONSTRAINT Profesor_pk PRIMARY KEY (documento);
ALTER TABLE Salon ADD CONSTRAINT Salon_pk PRIMARY KEY (Clase_id);
ALTER TABLE rol ADD CONSTRAINT rol_pk PRIMARY KEY (rol);
ALTER TABLE usr ADD CONSTRAINT usr_pk PRIMARY KEY (usuario);
ALTER TABLE RecursoClase ADD CONSTRAINT RecursoClase_pk PRIMARY KEY (Clase_id,Recurso_id);
ALTER TABLE usrXrol ADD CONSTRAINT usrXrol_pk PRIMARY KEY (rol_rol,usr_usuario);
ALTER TABLE Periodo ADD CONSTRAINT Periodo_pk PRIMARY KEY (periodo);
ALTER TABLE PrerequisitoMateria ADD CONSTRAINT PrerequisitoMateria_pk PRIMARY KEY (materia_sigla,prerrequisito_sigla);
ALTER TABLE ProfesorXHorario ADD CONSTRAINT ProfesorXHorario_pk PRIMARY KEY (Profesor_documento,Horario_id);
ALTER TABLE MateriaCohorte ADD CONSTRAINT MateriaCohorte_pk PRIMARY KEY (Materia_sigla,Cohorte_id,Profesor_documento);
-- unique keys
ALTER TABLE Clase ADD CONSTRAINT uk_clase UNIQUE (id) ;
ALTER TABLE Profesor ADD CONSTRAINT Profesor_ak_1 UNIQUE (correo) ;
ALTER TABLE Posgrado ADD CONSTRAINT Posgrado_ak_1 UNIQUE (nombre) ;
ALTER TABLE Asignatura ADD CONSTRAINT Asignatura_ak_1 UNIQUE (nombre) ;
ALTER TABLE recurso ADD CONSTRAINT recurso_ak_1 UNIQUE (recurso) ;
-- foreign keys
-- Reference: Asignatura_Posgrado (table: Asignatura)
ALTER TABLE Asignatura ADD CONSTRAINT Asignatura_Posgrado
FOREIGN KEY (Posgrado_id)
REFERENCES Posgrado (id)
;
-- Reference: Clase_MateriaCohorte (table: Clase)
ALTER TABLE Clase ADD CONSTRAINT Clase_MateriaCohorte
FOREIGN KEY (MateriaCohorte_Materia_sigla, MateriaCohorte_Cohorte_id, MateriaCohorte_Profesor_documento)
REFERENCES MateriaCohorte (Materia_sigla, Cohorte_id, Profesor_documento)
;
-- Reference: Cohorte_Periodo (table: Cohorte)
ALTER TABLE Cohorte ADD CONSTRAINT Cohorte_Periodo
FOREIGN KEY (Periodo_periodo)
REFERENCES Periodo (periodo)
;
-- Reference: MateriaCohorte_Cohorte (table: MateriaCohorte)
ALTER TABLE MateriaCohorte ADD CONSTRAINT MateriaCohorte_Cohorte
FOREIGN KEY (Cohorte_id)
REFERENCES Cohorte (id)
;
-- Reference: MateriaCohorte_Materia (table: MateriaCohorte)
ALTER TABLE MateriaCohorte ADD CONSTRAINT MateriaCohorte_Materia
FOREIGN KEY (Materia_sigla)
REFERENCES Materia (sigla)
;
-- Reference: MateriaCohorte_Profesor (table: MateriaCohorte)
ALTER TABLE MateriaCohorte ADD CONSTRAINT MateriaCohorte_Profesor
FOREIGN KEY (Profesor_documento)
REFERENCES Profesor (documento)
;
-- Reference: Materia_Asignatura (table: Materia)
ALTER TABLE Materia ADD CONSTRAINT Materia_Asignatura
FOREIGN KEY (Asignatura_id)
REFERENCES Asignatura (id)
;
-- Reference: PrerequisitoMateria_Materia (table: PrerequisitoMateria)
ALTER TABLE PrerequisitoMateria ADD CONSTRAINT PrerequisitoMateria_Materia
FOREIGN KEY (materia_sigla)
REFERENCES Materia (sigla)
;
-- Reference: PrerequisitoMateria_Materia2 (table: PrerequisitoMateria)
ALTER TABLE PrerequisitoMateria ADD CONSTRAINT PrerequisitoMateria_Materia2
FOREIGN KEY (prerrequisito_sigla)
REFERENCES Materia (sigla)
;
-- Reference: ProfesorXHorario_Horario (table: ProfesorXHorario)
ALTER TABLE ProfesorXHorario ADD CONSTRAINT ProfesorXHorario_Horario
FOREIGN KEY (Horario_id)
REFERENCES Horario (id)
;
-- Reference: ProfesorXHorario_Profesor (table: ProfesorXHorario)
ALTER TABLE ProfesorXHorario ADD CONSTRAINT ProfesorXHorario_Profesor
FOREIGN KEY (Profesor_documento)
REFERENCES Profesor (documento)
;
-- Reference: Salon_Clase (table: Salon)
ALTER TABLE Salon ADD CONSTRAINT Salon_Clase
FOREIGN KEY (Clase_id)
REFERENCES Clase (id)
;
-- Reference: Table_33_Clase (table: RecursoClase)
ALTER TABLE RecursoClase ADD CONSTRAINT Table_33_Clase
FOREIGN KEY (Clase_id)
REFERENCES Clase (id)
;
-- Reference: Table_33_Recurso (table: RecursoClase)
ALTER TABLE RecursoClase ADD CONSTRAINT Table_33_Recurso
FOREIGN KEY (Recurso_id)
REFERENCES Recurso (id)
;
-- Reference: usr_rol (table: Usr)
ALTER TABLE Usr ADD CONSTRAINT usr_rol
FOREIGN KEY (rol)
REFERENCES rol (rol)
;
-- Reference: usrXrol_rol (table: usrXrol)
ALTER TABLE usrXrol ADD CONSTRAINT usrXrol_rol
FOREIGN KEY (rol_rol)
REFERENCES rol (rol) ;
--Reference: usrXrol_usr (table: usrXrol)
ALTER TABLE usrXrol ADD CONSTRAINT usrXrol_usr
FOREIGN KEY (usr_usuario)
REFERENCES usr (usuario) ;
-- End of file
| true |
d200555825e821f279a0fa5a13b9b2a8691565f8 | SQL | Lozov-Petr/programming-semester-5 | /Database/pets2.sql | UTF-8 | 846 | 4.03125 | 4 | [] | no_license | -- 1 Питомцы по возрасту
SELECT Age, COUNT(*) FROM A0_Pet GROUP BY Age;
-- 2 Типы питомцев по возрасту
SELECT Name, Age, COUNT(*) FROM A0_Pet
JOIN A0_Pet_Type ON A0_Pet.Pet_Type_ID = A0_Pet.Pet_Type_ID
GROUP BY Age, Name;
-- Типы питомцев - средний возраст
SELECT Name, AVG(CAST (A0_Pet.Age AS DECIMAL)) FROM A0_Pet
JOIN A0_Pet_Type ON A0_Pet.Pet_Type_ID = A0_Pet_Type.Pet_Type_ID
GROUP BY Name
HAVING AVG(CAST (A0_Pet.Age AS DECIMAL)) < 6;
-- Заказчики - количество выполненных заказов
SELECT Last_name, COUNT(*) FROM A0_Owner
JOIN A0_Person ON A0_Person.Person_ID = A0_Owner.Person_ID
JOIN A0_Order ON A0_Order.Owner_ID = A0_Owner.Owner_ID
WHERE A0_Order.Is_Done = 1
GROUP BY A0_Owner.Owner_ID, Last_Name
HAVING COUNT(*) > 5; | true |
d31fbb8899ed279e578853ca0e43258da2a5ce1b | SQL | somi00138/SI2020-Project | /Database/Tables.sql | UTF-8 | 2,905 | 3.640625 | 4 | [] | no_license | CREATE TABLE [Orders] (
ID int NOT NULL IDENTITY,
FirstName varchar(50) NULL,
LastName varchar(50) NULL,
Country varchar(100) NULL,
City varchar(100) NULL,
Street varchar(200) NULL,
PostalCode int DEFAULT NULL,
PRIMARY KEY (ID)
);
CREATE TABLE [Roles] (
ID int NOT NULL IDENTITY,
Name varchar(50) NULL,
PRIMARY KEY (ID)
);
SET IDENTITY_INSERT [Roles] ON
INSERT INTO [Roles] (ID, Name) VALUES (1, N'Customer')
INSERT INTO [Roles] (ID, Name) VALUES (2, N'Manager')
INSERT INTO [Roles] (ID, Name) VALUES (3, N'Admin')
SET IDENTITY_INSERT [Roles] OFF
CREATE TABLE [Users] (
ID int NOT NULL IDENTITY,
Email varchar(100) NULL,
Password varchar(255) DEFAULT NULL,
RoleID int DEFAULT 1,
PRIMARY KEY (ID),
FOREIGN KEY (RoleID) REFERENCES [Roles] (ID)
);
CREATE TABLE [Manufacturers] (
ID int NOT NULL IDENTITY,
Name varchar(50) NULL,
PRIMARY KEY (ID)
);
CREATE TABLE [VehicleModels] (
ID int NOT NULL IDENTITY,
Name varchar(50) NULL,
PRIMARY KEY (ID)
);
CREATE TABLE [VehicleTypes] (
ID int NOT NULL IDENTITY,
Name varchar(50) DEFAULT NULL,
PRIMARY KEY (ID)
);
CREATE TABLE [Features] (
ID int NOT NULL IDENTITY,
CruiseControl bit DEFAULT NULL,
ParkingSensors bit DEFAULT NULL,
ElectricWindows bit DEFAULT NULL,
Sunroof bit DEFAULT NULL,
XenonHeadlights bit DEFAULT NULL,
Multimedia bit DEFAULT NULL,
PowerAssistedSteering bit DEFAULT NULL,
AirConditioning bit DEFAULT NULL,
Navigation bit DEFAULT NULL,
PRIMARY KEY (ID)
);
CREATE TABLE [Security] (
ID int NOT NULL IDENTITY,
ABS bit DEFAULT NULL,
Airbag bit DEFAULT NULL,
ESP bit DEFAULT NULL,
ASR bit DEFAULT NULL,
ChildLock bit DEFAULT NULL,
Immobiliser bit DEFAULT NULL,
CentralLocking bit DEFAULT NULL,
PRIMARY KEY (ID)
);
CREATE TABLE [Images] (
ID int NOT NULL IDENTITY,
Link NVARCHAR(255),
PRIMARY KEY (ID)
);
CREATE TABLE [Vehicles] (
ID int NOT NULL IDENTITY,
Price decimal(16,2) DEFAULT NULL,
Mileage decimal DEFAULT NULL,
Year int DEFAULT NULL,
Color varchar(20) NULL,
Fuel varchar(20) DEFAULT NULL,
CubicCapacity int DEFAULT NULL,
HorsePower int DEFAULT NULL,
Description varchar(1000) DEFAULT NULL,
ManufacturerID int DEFAULT NULL,
ModelID int DEFAULT NULL,
TypeID int DEFAULT NULL,
FeaturesID int DEFAULT NULL,
SecurityID int DEFAULT NULL,
ImagesID int DEFAULT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (ManufacturerID) REFERENCES [Manufacturers] (ID),
FOREIGN KEY (ModelID) REFERENCES [VehicleModels] (ID),
FOREIGN KEY (TypeID) REFERENCES [VehicleTypes] (ID),
FOREIGN KEY (FeaturesID) REFERENCES Features (ID),
FOREIGN KEY (SecurityID) REFERENCES Security (ID),
FOREIGN KEY (ImagesID) REFERENCES Images (ID)
);
CREATE TABLE [SoldVehicles] (
ID int NOT NULL IDENTITY,
Date date DEFAULT NULL,
VehicleID int DEFAULT NULL,
OrderID int DEFAULT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (VehicleID) REFERENCES [Vehicles] (ID),
FOREIGN KEY (OrderID) REFERENCES [Orders] (ID)
); | true |
ba25f91884d4ab19b3881a667fa7e60574bf81ce | SQL | user062/stoa | /events.sql | UTF-8 | 632 | 2.953125 | 3 | [] | no_license | -- show processlist;-- to show the processes in our case to check event_scheduler
-- set global event_scheduler= on; to enable the event scheduler
-- set global event_scheduler= off;-- to desable the event_scheduler
-- show events ; to list all the events
-- -----------------------------------------------------------------------
-- ------------------------------------------------------------------------
-- validation event 1 --
create event if not exists E1
on schedule every 1 hour
starts current_timestamp
do
delete from compte
where
vcode <> 0
and
{fn TIMESTAMPDIFF(SQL_TSI_hour,date_inscrit,current_timestamp)} > 6;
| true |
dd977b2e1f61c4d67da110136655e239f57e91e9 | SQL | jovi1410/Sedia.in | /DB fixxx.sql | UTF-8 | 10,114 | 2.796875 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Dec 05, 2020 at 01:04 AM
-- Server version: 10.1.38-MariaDB
-- PHP Version: 7.3.2
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `sediain`
--
-- --------------------------------------------------------
--
-- Table structure for table `meja`
--
CREATE TABLE `meja` (
`no_meja` bigint(20) UNSIGNED NOT NULL,
`warung_id` bigint(20) UNSIGNED 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 for table `meja`
--
INSERT INTO `meja` (`no_meja`, `warung_id`, `created_at`, `updated_at`) VALUES
(1, 1, '2020-12-04 22:48:41', '2020-12-04 22:48:41'),
(2, 1, '2020-12-04 22:48:41', '2020-12-04 22:48:41'),
(3, 1, '2020-12-04 22:48:41', '2020-12-04 22:48:41'),
(4, 1, '2020-12-04 22:48:41', '2020-12-04 22:48:41'),
(5, 1, '2020-12-04 22:48:41', '2020-12-04 22:48:41'),
(6, 1, '2020-12-04 22:48:41', '2020-12-04 22:48:41'),
(7, 1, '2020-12-04 22:48:41', '2020-12-04 22:48:41'),
(8, 1, '2020-12-04 22:48:41', '2020-12-04 22:48:41');
-- --------------------------------------------------------
--
-- Table structure for table `menu_tabel`
--
CREATE TABLE `menu_tabel` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_warung` int(11) NOT NULL,
`nama_menu` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`jenis_menu` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`harga` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`stok` int(11) NOT NULL,
`avatar` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_by` int(11) DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `menu_tabel`
--
INSERT INTO `menu_tabel` (`id`, `id_warung`, `nama_menu`, `jenis_menu`, `harga`, `stok`, `avatar`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 1, 'Johnny Walker', 'minuman', '21000', 42, 'ES-TEH.jpg', 1, NULL, '2020-12-04 22:51:20', '2020-12-04 22:51:20'),
(2, 1, 'Lemen Skuos', 'minuman', '13000', 433, '5725228_1da63a43-4e85-4659-b893-4448ed5f09f9_452_452.jpg', 1, NULL, '2020-12-04 22:51:50', '2020-12-04 22:51:50'),
(3, 1, 'oskab', 'makanan', '10000', 345, 'images (1).jfif', 1, NULL, '2020-12-04 22:52:20', '2020-12-04 22:52:20'),
(4, 1, 'otos koya', 'makanan', '11000', 353, 'soto ayam.jpg', 1, NULL, '2020-12-04 22:52:57', '2020-12-04 22:52:57'),
(5, 1, 'deng oseng celeng', 'Makanan', '13500', 890, 'jGmh3Ytb10.jpg', 1, NULL, '2020-12-04 22:54:19', '2020-12-04 22:54:33');
-- --------------------------------------------------------
--
-- Table structure for table `migrations`
--
CREATE TABLE `migrations` (
`id` int(10) UNSIGNED NOT NULL,
`migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `migrations`
--
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2014_10_12_000000_create_users_table', 1),
(2, '2014_10_12_100000_create_password_resets_table', 1),
(3, '2020_11_20_171628_create_menu_tabel', 1),
(4, '2020_11_29_140143_create_warung_table', 1),
(5, '2020_12_02_161349_create_meja_table', 1),
(6, '2020_12_02_192155_create_transaksi_table', 1);
-- --------------------------------------------------------
--
-- Table structure for table `password_resets`
--
CREATE TABLE `password_resets` (
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `transaksi`
--
CREATE TABLE `transaksi` (
`id` bigint(20) UNSIGNED NOT NULL,
`nama_pembeli` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`no_meja` bigint(20) UNSIGNED NOT NULL,
`warung_id` bigint(20) UNSIGNED NOT NULL,
`menu_id` bigint(20) UNSIGNED NOT NULL,
`jumlah` int(11) NOT NULL,
`metode_pemesanan` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`status_meja` int(11) 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 for table `transaksi`
--
INSERT INTO `transaksi` (`id`, `nama_pembeli`, `no_meja`, `warung_id`, `menu_id`, `jumlah`, `metode_pemesanan`, `status_meja`, `created_at`, `updated_at`) VALUES
(1, 'Mas Jopiiih', 2, 1, 4, 3, 'offline', 1, '2020-12-04 22:55:55', '2020-12-04 22:59:51'),
(2, 'Mas Jopiiih', 2, 1, 1, 1, 'offline', 1, '2020-12-04 22:55:56', '2020-12-04 22:59:51'),
(3, 'Jovv', 7, 1, 5, 3, 'offline', 1, '2020-12-04 23:33:02', '2020-12-04 23:33:02'),
(4, 'Jovv', 7, 1, 2, 1, 'offline', 1, '2020-12-04 23:33:02', '2020-12-04 23:33:02'),
(5, 'Jovv', 7, 1, 3, 1, 'offline', 1, '2020-12-04 23:33:02', '2020-12-04 23:33:02'),
(6, 'jovi', 1, 1, 5, 1, 'offline', 1, '2020-12-05 00:00:57', '2020-12-05 00:00:57'),
(7, 'jovi', 1, 1, 2, 1, 'offline', 1, '2020-12-05 00:00:57', '2020-12-05 00:00:57'),
(8, 'joo', 99, 1, 4, 2, 'offline', 0, '2020-12-05 00:01:49', '2020-12-05 00:01:49');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`role` int(11) NOT NULL,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `role`, `remember_token`, `created_at`, `updated_at`) VALUES
(1, 'Joviiih', 'jovi@sediain.com', NULL, '$2y$10$IEnobcoeWV/orEyf8sx8y.1ezawKzxpMsdWX.O/./eEAHhk3EkIPC', 2, NULL, '2020-12-04 22:45:25', '2020-12-04 22:45:25');
-- --------------------------------------------------------
--
-- Table structure for table `warung`
--
CREATE TABLE `warung` (
`id_warung` bigint(20) UNSIGNED NOT NULL,
`nama_warung` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`user_id` bigint(20) UNSIGNED NOT NULL,
`stok_meja` int(11) 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 for table `warung`
--
INSERT INTO `warung` (`id_warung`, `nama_warung`, `user_id`, `stok_meja`, `created_at`, `updated_at`) VALUES
(1, 'Warung Mas Joviiih', 1, 8, '2020-12-04 22:47:34', '2020-12-04 22:47:34');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `meja`
--
ALTER TABLE `meja`
ADD PRIMARY KEY (`no_meja`),
ADD KEY `meja_warung_id_foreign` (`warung_id`);
--
-- Indexes for table `menu_tabel`
--
ALTER TABLE `menu_tabel`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`);
--
-- Indexes for table `transaksi`
--
ALTER TABLE `transaksi`
ADD PRIMARY KEY (`id`),
ADD KEY `transaksi_warung_id_foreign` (`warung_id`),
ADD KEY `transaksi_menu_id_foreign` (`menu_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- Indexes for table `warung`
--
ALTER TABLE `warung`
ADD PRIMARY KEY (`id_warung`),
ADD KEY `warung_user_id_foreign` (`user_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `meja`
--
ALTER TABLE `meja`
MODIFY `no_meja` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `menu_tabel`
--
ALTER TABLE `menu_tabel`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `transaksi`
--
ALTER TABLE `transaksi`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `warung`
--
ALTER TABLE `warung`
MODIFY `id_warung` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `meja`
--
ALTER TABLE `meja`
ADD CONSTRAINT `meja_warung_id_foreign` FOREIGN KEY (`warung_id`) REFERENCES `warung` (`id_warung`);
--
-- Constraints for table `transaksi`
--
ALTER TABLE `transaksi`
ADD CONSTRAINT `transaksi_menu_id_foreign` FOREIGN KEY (`menu_id`) REFERENCES `menu_tabel` (`id`),
ADD CONSTRAINT `transaksi_warung_id_foreign` FOREIGN KEY (`warung_id`) REFERENCES `warung` (`id_warung`);
--
-- Constraints for table `warung`
--
ALTER TABLE `warung`
ADD CONSTRAINT `warung_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`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 |
d549b5a67f9dcac75c2f248c8666b78839a0359c | SQL | raphaelaraujo/estacionamento | /adm-leader/recursos/Todos os recursos utilizados no projeto/SQL/estacionar.sql | UTF-8 | 2,022 | 3.1875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | -- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Tempo de geração: 17-Abr-2020 às 03:53
-- Versão do servidor: 10.4.11-MariaDB
-- versão do PHP: 7.4.4
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Banco de dados: `estacionamento`
--
-- --------------------------------------------------------
--
-- Estrutura da tabela `estacionar`
--
CREATE TABLE `estacionar` (
`estacionar_id` int(11) NOT NULL,
`estacionar_precificacao_id` int(11) NOT NULL,
`estacionar_forma_pagamento_id` int(11) DEFAULT NULL,
`estacionar_valor_hora` varchar(20) NOT NULL,
`estacionar_numero_vaga` int(11) NOT NULL,
`estacionar_placa_veiculo` varchar(8) NOT NULL,
`estacionar_marca_veiculo` varchar(30) NOT NULL,
`estacionar_modelo_veiculo` varchar(20) NOT NULL,
`estacionar_data_entrada` datetime NOT NULL DEFAULT current_timestamp(),
`estacionar_data_saida` datetime DEFAULT NULL,
`estacionar_tempo_decorrido` varchar(20) DEFAULT NULL,
`estacionar_valor_devido` varchar(30) DEFAULT NULL,
`estacionar_status` tinyint(1) NOT NULL,
`estacionar_data_alteracao` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Índices para tabelas despejadas
--
--
-- Índices para tabela `estacionar`
--
ALTER TABLE `estacionar`
ADD PRIMARY KEY (`estacionar_id`);
--
-- AUTO_INCREMENT de tabelas despejadas
--
--
-- AUTO_INCREMENT de tabela `estacionar`
--
ALTER TABLE `estacionar`
MODIFY `estacionar_id` int(11) NOT NULL AUTO_INCREMENT;
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 |
033502f412344039c5e699cd9ecd9569864e06c4 | SQL | kaelsilva/BD2-T03 | /q16.sql | UTF-8 | 988 | 4.03125 | 4 | [
"WTFPL"
] | permissive | DROP VIEW IF EXISTS responsavelrico CASCADE;
DROP VIEW IF EXISTS responsavelgenerico CASCADE;
DROP VIEW IF EXISTS gerenteresponsavel CASCADE;
DROP VIEW IF EXISTS listadegerentes CASCADE;
CREATE VIEW listadegerentes AS
SELECT f.nome, f.codigo, f.coddepto, f.salario
FROM funcionario f RIGHT JOIN departamento d
ON f.codigo = d.codgerente
ORDER BY f.coddepto ASC;
CREATE VIEW gerenteresponsavel AS
SELECT DISTINCT lg.nome
FROM projeto p LEFT JOIN listadegerentes lg
ON p.codresponsavel = lg.codigo
ORDER BY lg.nome ASC;
CREATE VIEW responsavelgenerico AS
SELECT DISTINCT f.nome, f.coddepto, f.codigo, f.salario
FROM funcionario f LEFT JOIN projeto p
ON f.codigo = p.codresponsavel
ORDER BY f.coddepto ASC;
CREATE VIEW responsavelrico AS
SELECT DISTINCT rg.nome
FROM responsavelgenerico rg, listadegerentes lg
WHERE rg.salario > lg.salario AND rg.coddepto = lg.coddepto;
SELECT *
FROM responsavelrico
WHERE nome IS NOT NULL
UNION
SELECT *
FROM gerenteresponsavel
WHERE nome IS NOT NULL; | true |
7f33e7d7ac0909af3e796e6a679c9ef1a9247694 | SQL | kritikabajpai111/project1 | /hotwire/db_objects/Stored Procedure/SP_GET_CONTACT_BY_EMAIL.sql | UTF-8 | 835 | 3.296875 | 3 | [] | no_license | DELIMITER $$
USE `hwc_mobile`$$
DROP PROCEDURE IF EXISTS `SP_GET_USER_BY_EMAIL`$$
CREATE DEFINER=`root`@`%` PROCEDURE `SP_GET_USER_BY_EMAIL`(IN reference NVARCHAR(200))
BEGIN
/* *****************************************************************************************
-- Name SP_GET_USER_BY_EMAIL
-- Description The following procedure is used to get the user object by phone.
-- Maintainence History
-- Developer Date Modification Made
-- Kritika Bajpai 19/12/16 Create Procedure
-- ******************************************************************************************
*/
DECLARE id INT;
SELECT user_id INTO id FROM contact WHERE `contact_content` = reference AND active = 1 LIMIT 1;
CALL SP_Get_User(id);
COMMIT;
END$$
DELIMITER ; | true |
fcb8c9bd60a67891183db02f590e0aa58d865d8b | SQL | duanyong/duanyong.tk | /dev/conf/201208aiyuji_user.sql | UTF-8 | 3,178 | 2.984375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 3.4.10.1deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 10, 2012 at 02:10 AM
-- Server version: 5.5.24
-- PHP Version: 5.3.10-1ubuntu3.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 utf8 */;
--
-- Database: `test`
--
-- --------------------------------------------------------
--
-- Table structure for table `201208aiyuji_user`
--
CREATE TABLE IF NOT EXISTS `201208aiyuji_user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`token` char(64) NOT NULL DEFAULT '' COMMENT '用户标识',
`username` char(64) NOT NULL DEFAULT '' COMMENT '用户手机',
`password` char(32) NOT NULL DEFAULT '' COMMENT '用户密码',
`nickname` varchar(32) NOT NULL DEFAULT '' COMMENT '用户昵称',
`firstname` varchar(32) NOT NULL DEFAULT '' COMMENT '用户姓氏',
`lastname` varchar(32) NOT NULL DEFAULT '' COMMENT '用户名字',
`sex` tinyint(1) NOT NULL DEFAULT '0' COMMENT '用户性别',
`regip` varchar(32) NOT NULL DEFAULT '' COMMENT '注册IP',
`sum` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '留言总数',
`regtime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '通过reg方式注册的时间',
`tokentime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '通过token方式注册的时间',
`nicktime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '通过nickname方式注册的时间',
`time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '注册时间',
`status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '当前状态',
PRIMARY KEY (`id`),
KEY `idx_token` (`token`),
KEY `idx_username` (`username`),
KEY `idx_nickname` (`nickname`),
KEY `idx_status` (`status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='用户信息表' AUTO_INCREMENT=4 ;
--
-- Dumping data for table `201208aiyuji_user`
--
INSERT INTO `201208aiyuji_user` (`id`, `token`, `username`, `password`, `nickname`, `firstname`, `lastname`, `sex`, `regip`, `sum`, `regtime`, `tokentime`, `nicktime`, `time`, `status`) VALUES
(1, 'sbyldrnrpgmyplenvssyoragqcmleqqrlgklidruwfxudsocgvkktpftqxqmk', 'dd-up@hotmail.com', '54bf525e28a75bc57830248edb256339', '啊段', '', '', 0, '', 2, '2012-10-10 02:03:26', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1349805806, 4),
(2, 'sbyldrnrpgmyplenvssyoragqcmleqqrlgklidruwfxudsocgvkktpftqxqmk', 'oxzifkgrtuktembaizsfemnxqvweqyqegyunozjtjceaoognsddqoozbzztb', 'f386fda3743db0e6fe37f4bcbe1c5d89', '宝宝', '', '', 0, '', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '2012-10-10 02:06:34', 1349805994, 2),
(3, 'sbyldrnrpgmyplenvssyoragqcmleqqrlgklidruwfxudsocgvkktpftqxqmk', 'iojhoxbfeuceqlhtsglxlefazkbmdtulhlzzfdcnxmgslxqqvyrfuviwvyfqip', 'e4fee685b5dd28142494a45a08651972', '爸爸妈妈', '', '', 0, '', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '2012-10-10 02:07:14', 1349806034, 2);
/*!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 |
41499abfb1f70fb7c7df437498d6678622421369 | SQL | michaellee2245/group-project | /db/board/name_search.sql | UTF-8 | 584 | 4.15625 | 4 | [] | no_license | /* find boards that you can access with names that start with the search term */
SELECT
board.id AS id,
board.name AS name,
board.description AS description,
board.team AS team_id,
board.owner AS owner_id,
owner.name AS owner,
owner.profile_pic AS owner_pic,
team.name AS team FROM board
JOIN person AS owner ON owner.id = board.owner
JOIN team ON board.team = team.id
WHERE board.name ILIKE $1 AND (team.id IN (
SELECT id FROM team
WHERE manager_id = $2
UNION ALL
SELECT team_id FROM team_member
WHERE user_id = $2
AND approved
) OR board.owner = $2);
| true |
6bf2aa677c21a6e1542f808252433421be3be3d7 | SQL | emanoelmiranda/php-ddd-cargo-sample | /scripts/cargo_sample.sql | UTF-8 | 1,071 | 3.4375 | 3 | [] | no_license |
--
-- Datenbank: `cargo_sample`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `cargo`
--
CREATE TABLE IF NOT EXISTS `cargo` (
`tracking_id` varchar(36) NOT NULL,
`origin` varchar(250) NOT NULL,
`route_specification_id` int(11) NOT NULL,
`itinerary_id` int(11) DEFAULT NULL,
PRIMARY KEY (`tracking_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `itinerary`
--
CREATE TABLE IF NOT EXISTS `itinerary` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`legs` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `route_specification`
--
CREATE TABLE IF NOT EXISTS `route_specification` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`origin` varchar(250) NOT NULL,
`destination` varchar(250) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=25 ;
| true |
e97add4b771e31b045390abd57cf597175bf5ea4 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/high/day12/select0938.sql | UTF-8 | 262 | 2.984375 | 3 | [] | no_license |
SELECT sen.name
FROM SENSOR sen, SENSOR_TYPE st, COVERAGE_INFRASTRUCTURE ci
WHERE sen.SENSOR_TYPE_ID=st.id AND st.name='WiFiAP' AND sen.id=ci.SENSOR_ID AND ci.INFRASTRUCTURE_ID=ANY(array['5013','4066','2099','4212','2019','2214','4209','5061','5081','5074'])
| true |
f3553200b0bf869fddff55050b0af96531430ea1 | SQL | gguilherme42/CursoMySQL | /Aulas/aula13/aula13.sql | UTF-8 | 339 | 3.515625 | 4 | [
"MIT"
] | permissive | USE cadastro;
SELECT carga FROM cursos
GROUP BY carga ORDER BY carga;
SELECT carga, COUNT(nome)
FROM cursos
GROUP BY carga
ORDER BY carga;
SELECT carga, COUNT(nome)
FROM cursos GROUP BY carga
HAVING COUNT(nome) > 3;
SELECT carga, COUNT(*)
FROM cursos WHERE ano > 2015
GROUP BY carga
HAVING carga > (SELECT AVG(carga)
FROM cursos);
| true |
55580c94dfffc1b67e9ded907f2754dc6482da11 | SQL | LuizdosReis/credit-card-control-api | /src/main/resources/db/migration/V7__installments.sql | UTF-8 | 301 | 3.21875 | 3 | [] | no_license | DROP TABLE IF EXISTS installments;
CREATE TABLE installments
(
id BIGSERIAL,
value NUMERIC NOT NULL,
date TIMESTAMP NOT NULL ,
expense_id BIGINT NOT NULL,
CONSTRAINT installments_pk PRIMARY KEY (id),
CONSTRAINT installments_fk_expense FOREIGN KEY (expense_id) REFERENCES expenses (id)
); | true |
26ee9900f3b55c27516eef13091b26e0ae9fbd49 | SQL | memo1994/trabajo-de-campo | /database/db_gym.sql | UTF-8 | 4,556 | 3.578125 | 4 | [] | no_license | CREATE DATABASE db_gym;
USE db_gym;
CREATE TABLE persona (
id INT(11) NOT NULL,
nombres VARCHAR(50) NOT NULL,
apellidos VARCHAR(50) NOT NULL,
documento VARCHAR(12) NOT NULL,
codigo VARCHAR(12) NOT NULL,
celular VARCHAR(15),
email VARCHAR(140) NOT NULL,
rol VARCHAR(15),
created_at timestamp NOT NULL DEFAULT current_timestamp,
UNIQUE(documento, codigo)
);
ALTER TABLE persona
ADD PRIMARY KEY (id);
ALTER TABLE persona
MODIFY id INT(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 1;
INSERT INTO persona (id, nombres, apellidos, documento, codigo, celular, email, rol)
VALUES (1, 'enrique','sanchez', '123456789', '201911111', '3111111111', 'enriquesan@uptc.edu.co', 'ADMINISTRADOR');
CREATE TABLE datos_personales (
id INT(11) NOT NULL,
id_persona INT(11) NOT NULL,
fecha_nacimiento DATE NOT NULL,
edad INT(2) NOT NULL,
genero VARCHAR(10) NOT NULL,
eps VARCHAR(50) NOT NULL,
rh VARCHAR(5) NOT NULL,
arl VARCHAR(50),
alergia VARCHAR(2) NOT NULL,
c_alergia VARCHAR(100),
pariente VARCHAR(100) NOT NULL,
tel_pariente VARCHAR(15) NOT NULL,
parentesco VARCHAR(20) NOT NULL,
CONSTRAINT fk_per_dp FOREIGN KEY(id_persona) REFERENCES persona(id)
);
ALTER TABLE datos_personales
ADD PRIMARY KEY (id);
ALTER TABLE datos_personales
MODIFY id INT(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 1;
-- HISTORIA MÉDICA Y HÁBITOS
CREATE TABLE hm_ha (
id INT(11) NOT NULL,
id_persona INT(11) NOT NULL,
HM1 VARCHAR(2) NOT NULL,
HM1C VARCHAR(80),
HM2 VARCHAR(2) NOT NULL,
HM2C VARCHAR(80),
HM3 VARCHAR(2) NOT NULL,
HM4 VARCHAR(2) NOT NULL,
HM5 VARCHAR(2) NOT NULL,
HM6 VARCHAR(2) NOT NULL,
HM6C VARCHAR(80),
HM7 VARCHAR(2) NOT NULL,
HM7C VARCHAR(80),
HM8 VARCHAR(2) NOT NULL,
HM9 VARCHAR(2) NOT NULL,
HM9C VARCHAR(80),
HM10 VARCHAR(2) NOT NULL,
HM10C VARCHAR(80),
HM10C2 VARCHAR(80),
HM11 VARCHAR(2) NOT NULL,
HM11C VARCHAR(80),
HA1 VARCHAR(2) NOT NULL,
HA1C VARCHAR(80),
HA2C INT(1),
HA3C INT(2),
HA4C INT(2),
HA2 VARCHAR(30) NOT NULL,
CONSTRAINT fk_per_hmha FOREIGN KEY(id_persona) REFERENCES persona(id)
);
ALTER TABLE hm_ha
ADD PRIMARY KEY (id);
ALTER TABLE hm_ha
MODIFY id INT(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 1;
-- BENEFICIOS
CREATE TABLE ben (
id INT(50) NOT NULL,
id_persona INT(11),
beneficio VARCHAR(30),
CONSTRAINT fk_per_ben FOREIGN KEY(id_persona) REFERENCES persona(id)
);
ALTER TABLE ben
ADD PRIMARY KEY (id);
ALTER TABLE ben
MODIFY id INT(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 1;
CREATE TABLE asistencia (
id INT(11) NOT NULL,
id_persona INT(11) NOT NULL,
id_instructor INT(11) NOT NULL,
asistencia DATE,
CONSTRAINT fk_per_asi FOREIGN KEY(id_persona) REFERENCES persona(id),
CONSTRAINT fk_ins_asi FOREIGN KEY(id_instructor) REFERENCES persona(id)
);
ALTER TABLE asistencia
ADD PRIMARY KEY (id);
ALTER TABLE asistencia
MODIFY id INT(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 1;
CREATE TABLE ejercicio (
id INT(5) NOT NULL,
nombre VARCHAR(50) NOT NULL,
descripcion VARCHAR(300) NOT NULL,
musculo VARCHAR(50) NOT NULL,
img_musculo BLOB,
img_ejercicio BLOB,
id_instructor INT(11),
CONSTRAINT fk_ins_eje FOREIGN KEY(id_instructor) REFERENCES persona(id)
);
ALTER TABLE ejercicio
ADD PRIMARY KEY (id);
ALTER TABLE ejercicio
MODIFY id INT(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 1;
CREATE TABLE rut_ejer (
id INT(5) NOT NULL,
id_ejercicio INT(5) NOT NULL,
repeticiones INT(3) NOT NULL,
series INT(2) NOT NULL,
CONSTRAINT fk_eje_ruej FOREIGN KEY(id_ejercicio) REFERENCES ejercicio(id)
);
ALTER TABLE rut_ejer
ADD PRIMARY KEY (id);
ALTER TABLE rut_ejer
MODIFY id INT(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 1;
CREATE TABLE rutina (
id INT(5) NOT NULL,
id_rut_ejer INT(5) NOT NULL,
id_persona INT(11) NOT NULL,
id_instructor INT(11) NOT NULL,
CONSTRAINT fk_ruej_rut FOREIGN KEY(id_rut_ejer) REFERENCES rut_ejer(id),
CONSTRAINT fk_per_rut FOREIGN KEY(id_persona) REFERENCES persona(id),
CONSTRAINT fk_ins_rut FOREIGN KEY(id_instructor) REFERENCES persona(id)
);
ALTER TABLE rutina
ADD PRIMARY KEY (id);
ALTER TABLE rutina
MODIFY id INT(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 1;
CREATE TABLE users (
id INT(5) NOT NULL,
usuario VARCHAR(12) NOT NULL,
contrasena VARCHAR(12) NOT NULL,
id_persona INT(11) NOT NULL,
CONSTRAINT fk_usua_use FOREIGN KEY(id_persona) REFERENCES persona(id)
);
ALTER TABLE users
ADD PRIMARY KEY (id);
ALTER TABLE users
MODIFY id INT(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 1; | true |
69fb4516dda05b4d33c3f17da563892769cf98c9 | SQL | anastmigk/SocialGreen_dev | /Sql Files/userbadges_trigger.sql | UTF-8 | 477 | 3.53125 | 4 | [] | no_license | USE `sgalpha`;
DELIMITER $$
CREATE TRIGGER `userscore_trigger` AFTER INSERT ON activity FOR EACH ROW
-- Edit trigger body code below this line. Do not edit lines above this one
BEGIN
SET sum_leaves = (SELECT ((sum(act.aluminium)*3)+(sum(act.glass)*1)+(sum(act.plastic)*2)) as LEAVES
FROM sgalpha.activity as act
WHERE act.userid = NEW.userid );
UPDATE sgalpha.accounts SET points = sum_leaves WHERE accounts.id= NEW.userid ;
IF sum_leaves > 10
END$$
DELIMITER ; | true |
385da3d7a839b6880945f1fdc3aea25aa8e42c43 | SQL | michaelcw02/AdministracionBD2 | /I/bd2/Proc2.sql | UTF-8 | 9,698 | 3.59375 | 4 | [
"MIT"
] | permissive | --Sinónimos:
--Publicos (Global, para todos los usuarios es el mismo)
--Privados (para un usuario específico)
--Puntero
--Facilidad, unificar,
--Seguridad, para ocultar.
--Cuando un usuario crea objetos globales
--Ej: ROLES, SINONIMOS PUBLICOS, TABLESPACES, USUARIOS
--cuando el usuario se borra aunque sea cascade, el objeto permanece!
--con el drop user cascade lo que se borra son los objetos propios del usuario (usuario.objeto)
--ej: tablas (PK, FK, CK, TRIGGERS), vistas, secuencias, sinonimos privados, procedimientos, funciones, paquetes.
host cls
spool Proc2.log
prompt CONECTADO CON SYSTEM
conn system/root
prompt DROP USER PROYECTO
drop user proyecto cascade;
drop user ana cascade;
drop user juan cascade;
drop user pedro cascade;
drop role ROL_GIMNASIO;
drop public synonym prc_ins_instructor;
drop public synonym prc_prueba;
--CREATE USER
create user proyecto identified by pro1234;
create user ana identified by ana123;
create user juan identified by juan123;
create user pedro identified by pedro123;
--seccion de permisos
grant dba to proyecto;
grant create session to ana;
grant create session to juan;
grant create session to pedro;
conn proyecto/pro1234;
create role ROL_GIMNASIO;
--CREATE TABLES--
prompt CREACION DE TABLAS
create table INSTRUCTORES(
cedula number,
nombre varchar2(20) not null,
apellidos varchar2(25) not null,
genero varchar(1) not null,
edad number not null);
create table CLIENTES(
cedula_Cliente number,
nombre varchar2(20) not null,
apellidos varchar2(25) not null,
genero varchar2(1) not null,
edad number not null,
estado varchar2(2) not null,
peso number not null,
unidad_peso varchar2(2) not null,
instructor number not null,
matricula number not null,
fecha_incripcion date not null,
fecha_vencimiento date not null);
--PK--
prompt LLAVES PRIMARIAS
alter table INSTRUCTORES add constraint instructor_pk primary key(cedula);
alter table CLIENTES add constraint cliente_pk primary key(cedula_Cliente);
--FK--
prompt LLAVES FORANEAS
alter table CLIENTES add constraint cliente_fk01 foreign key (instructor) references INSTRUCTORES;
--CK--
prompt CHECK CONSTRAINTS
alter table CLIENTES add constraint cliente_ck01 check (genero in ('M','F'));
alter table CLIENTES add constraint cliente_ck04 check(edad > 13);
alter table INSTRUCTORES add constraint instructor_ck01 check (genero in('M','F'));
alter table INSTRUCTORES add constraint instructor_ck02 check(edad > 19);
---
---------------------------------------------------------
PROMPT Proyecto2 Inicia acá
---------------------------------------------------------
---------------------------------------------------------
---------------------------------------------------------
---------------------------------------------------------
--host cls
--conn system/root
conn proyecto/pro1234;
-----------------PROCEDURES-------------------------
prompt Procedimientos inserts
prompt prc insert Instructores
create or replace procedure prc_ins_instructor(PCedInst in number,PNombreInst in varchar2,PApellInst in varchar2,PGeneroInst in varchar2,PEdadInst in number) is
begin
insert into INSTRUCTORES(cedula,nombre,apellidos,genero,edad) values (PCedInst,PNombreInst,PApellInst,PGeneroInst,PEdadInst);
commit;
end prc_ins_instructor;
/
show error
--No valida que el objeto apuntado exista!
create public synonym prc_ins_instructor for proyecto.prc_ins_instructor;
create public synonym prc_prueba for proyecto.prc_ins_instructor;
--
prompt prc insert Clientes
create or replace procedure prc_ins_cliente(PCedCliente in number, PNomClie in varchar2,PApellClie in varchar2,PGenClie in varchar2,PEdadClie in number,PEstClie in varchar2,PPesoClie in number,PUniPesoClie in varchar2,PInstru in number,PMatri in number,PFechInsc in date, PFechVen in date) is
begin
insert into CLIENTES(cedula_Cliente,nombre,apellidos,genero,edad,estado,peso,unidad_peso,instructor,matricula,fecha_incripcion,fecha_vencimiento) values (PCedCliente,PNomClie,PApellClie,PGenClie,PEdadClie,PEstClie,PPesoClie,PUniPesoClie,PInstru,PMatri,PFechInsc,PFechVen);
commit;
end prc_ins_cliente;
/
show error
---------------------------Fin de Procedures INSERTS------------------------
---------------------------PROCEDURE ACTUALIZAR-----------------------------
prompt PRC ACTUALIZAR INSTRUCTORES
prompt PRC ACTUALIZAR NOMBRE INSTRUCTORES
create or replace procedure prc_act_nom_instructor(PCedInst in number, PNombreInst in varchar2) is
begin
update INSTRUCTORES set nombre=PNombreInst where cedula=PCedInst;
commit;
end prc_act_nom_instructor;
/
show error
prompt PRC ACTUALIZAR APELLIDOS INSTRUCTORES
create or replace procedure prc_act_apell_instructor(PCedInst in number, PApellInst in varchar2) is
begin
update INSTRUCTORES set apellidos=PApellInst where cedula=PCedInst;
commit;
end prc_act_apell_instructor;
/
show error
prompt PRC ACTUALIZAR EDAD INSTRUCTORES
create or replace procedure prc_act_edad_instructor(PCedInst in number, PEdadInstr in number) is
begin
update INSTRUCTORES set edad=PEdadInstr where cedula=PCedInst;
commit;
end prc_act_edad_instructor;
/
show error
prompt PRC ACTUALIZAR GENERO INSTRUCTORES
create or replace procedure prc_act_gen_instructor(PCedInst in number, PGenInst in varchar2) is
begin
update INSTRUCTORES set genero=PGenInst where cedula=PCedInst;
commit;
end prc_act_gen_instructor;
/
show error
prompt PRC ACTUALIZAR CLIENTES
prompt PRC ACTUALIZAR NOMBRE CLIENTES
create or replace procedure prc_act_nom_cliente(PCedCliente in number, PNomClie in varchar2) is
begin
update CLIENTES set nombre=PNomClie where cedula_Cliente=PCedCliente;
commit;
end prc_act_nom_cliente;
/
show error
prompt PRC ACTUALIZAR APELLIDOS CLIENTES
create or replace procedure prc_act_apell_cliente(PCedCliente in number, PApellClie in varchar2) is
begin
update CLIENTES set apellidos=PApellClie where cedula_Cliente=PCedCliente;
commit;
end prc_act_apell_cliente;
/
show error
prompt PRC ACTUALIZAR GENERO CLIENTES
create or replace procedure prc_act_gen_cliente(PCedCliente in number, PGenClie in varchar2) is
begin
update CLIENTES set genero=PGenClie where cedula_Cliente=PCedCliente;
commit;
end prc_act_gen_cliente;
/
show error
prompt PRC ACTUALIZAR EDAD CLIENTES
create or replace procedure prc_act_edad_cliente(PCedCliente in number, PEdadClie in number) is
begin
update CLIENTES set edad=PEdadClie where cedula_Cliente=PCedCliente;
commit;
end prc_act_edad_cliente;
/
show error
prompt PRC ACTUALIZAR PESO CLIENTES
create or replace procedure prc_act_peso_cliente(PCedCliente in number, PPesoClie in number) is
begin
update CLIENTES set peso=PPesoClie where cedula_Cliente=PCedCliente;
commit;
end prc_act_peso_cliente;
/
show error
prompt PRC ACTUALIZAR ESTADO CLIENTES
create or replace procedure prc_act_est_cliente(PCedCliente in number, PEstClie in varchar2) is
begin
update CLIENTES set estado=PEstClie where cedula_Cliente=PCedCliente;
commit;
end prc_act_est_cliente;
/
show error
prompt PRC ACTUALIZAR INSTRUCTOR CLIENTES
create or replace procedure prc_act_inst_cliente(PCedCliente in number, PInstClie in number) is
begin
update CLIENTES set instructor=PInstClie where cedula_Cliente=PCedCliente;
commit;
end prc_act_inst_cliente;
/
show error
prompt PRC ACTUALIZAR FECHA INSCRIPCION CLIENTES
create or replace procedure prc_act_fecIns_cliente(PCedCliente in number, PFechIns in date) is
begin
update CLIENTES set fecha_incripcion=PFechIns where cedula_Cliente=PCedCliente;
commit;
end prc_act_fecIns_cliente;
/
show error
------------------------FIN PROCEDURES ACTUALIZAR----------------------------
------------------------PROCEDURES BORRAR------------------------------------
prompt procedures borrado
prompt procedure BORRAR INSTRUCTOR
create or replace procedure prc_bor_instructor(PCedInst in number) is
begin
delete INSTRUCTORES where cedula=PCedInst;
commit;
end prc_bor_instructor;
/
show error
prompt procedure BORRAR CLIENTE
create or replace procedure prc_bor_cliente(PCedCliente in number) is
begin
delete CLIENTES where cedula_Cliente=PCedCliente;
commit;
end prc_bor_cliente;
/
show error
------------------------FIN ROCEDURES BORRAR----------------------------------
---------------------------EXUCUTE DE PROCEDURES INSERTAR-------------------
prompt EXECUTE INSERTAR INSTRUCTORES
execute prc_ins_instructor(12345,'A','A C','M',30);
execute prc_ins_instructor(123456,'B','B C','F',25);
prompt EXECUTE INSERTAR CLIENTES
execute prc_ins_cliente(402300598,'C1','C1','M',21,'AD',60,'KG',123456,1,sysdate,sysdate);
execute prc_ins_cliente(402200675,'C3','C2','M',23,'AT',150,'LB',12345,2,sysdate,sysdate);
grant execute on prc_ins_instructor to juan;
grant execute on prc_ins_instructor to ROL_GIMNASIO;
grant execute on prc_ins_cliente to ana;
grant execute on prc_ins_cliente to ROL_GIMNASIO;
--host pause
grant ROL_GIMNASIO to pedro;
--host pause
prompt usuario ana
conn ana/ana123
prompt Ana ejecuta procedimiento
execute proyecto.prc_ins_cliente(402200679,'C3','C2','M',23,'AT',150,'LB',12345,2,sysdate,sysdate);
prompt usuario juan
conn juan/juan123
prompt Juan ejecuta procedimiento Insertar INSTRUCTOR
execute proyecto.prc_ins_instructor(12349,'A','A C','M',30);
--select * from proyecto.INSTRUCTORES;
PROMPT no puedo insertar directamente
--insert into proyecto.INSTRUCTORES(cedula,nombre,apellidos,genero,edad) values (12348,'A','A C','M',30);
--commit;
prompt usuario pedro
conn pedro/pedro123
execute proyecto.prc_ins_cliente(102200679,'C3','C2','M',23,'AT',150,'LB',12345,2,sysdate,sysdate);
prompt Con sinonimo global prc_prueba
execute prc_prueba(22349,'A','A C','M',30);
spool off
| true |
f89880dbc150bc79b1ffb98b0a222bc36e9abfdf | SQL | ajlane17/cit225 | /apply_mysql_lab11.sql | UTF-8 | 11,777 | 3.875 | 4 | [] | no_license | -- ----------------------------------------------------------------------
-- Instructions:
-- ----------------------------------------------------------------------
-- The two scripts contain spooling commands, which is why there
-- isn't a spooling command in this script. When you run this file
-- you first connect to the Oracle database with this syntax:
--
-- mysql -ustudent -pstudent
--
-- or, you can fully qualify the port with this syntax:
--
-- mysql -ustudent -pstudent -P3306
--
-- Then, you call this script with the following syntax:
--
-- mysql> \. apply_mysql_lab11.sql
--
-- or, the more verbose syntax:
--
-- mysql> source apply_mysql_lab11.sql
--
-- ----------------------------------------------------------------------
-- Call the basic seeding scripts, this scripts TEE their own log
-- files. That means this script can only start a TEE after they run.
\. /home/student/Data/cit225/mysql/lab10/apply_mysql_lab10.sql
-- Add your lab here:
-- ----------------------------------------------------------------------
USE studentdb;
-- Insert into rental table
REPLACE INTO rental (
SELECT DISTINCT
r.rental_id AS rental_id,
c.contact_id AS customer_id,
tu.check_out_date AS check_out_date,
tu.return_date AS return_date,
1003 AS created_by,
UTC_DATE() AS creation_date,
1003 AS last_updated_by,
UTC_DATE() AS last_update_date
FROM member m INNER JOIN contact c
ON m.member_id = c.member_id INNER JOIN transaction_upload tu
ON c.first_name = tu.first_name
AND IFNULL(c.middle_name,'x') = IFNULL(tu.middle_name,'x')
AND c.last_name = tu.last_name
AND tu.account_number = m.account_number LEFT JOIN rental r
ON c.contact_id = r.customer_id
AND tu.check_out_date = r.check_out_date
AND tu.return_date = r.return_date
);
-- FIRST update transaction_upload values to match actual keys, source table did not match
UPDATE transaction_upload SET item_id = 1001 WHERE item_id = 1;
UPDATE transaction_upload SET item_id = 1012 WHERE item_id = 12;
-- Insert into rental_item table
SET FOREIGN_KEY_CHECKS=0;
-- I had to do this because it kept failing for created_by
REPLACE INTO rental_item (
SELECT
ri.rental_item_id AS rental_item_id,
r.rental_id AS rental_id,
tu.item_id AS item_id,
DATEDIFF(r.return_date, r.check_out_date) AS rental_item_price,
cl.common_lookup_id AS rental_item_type,
1003 AS created_by,
UTC_DATE() AS creation_date,
1003 AS last_updated_by,
UTC_DATE() AS last_update_date
FROM member m INNER JOIN contact c
ON m.member_id = c.member_id INNER JOIN transaction_upload tu
ON c.first_name = tu.first_name
AND IFNULL(c.middle_name,'x') = IFNULL(tu.middle_name,'x')
AND c.last_name = tu.last_name
AND tu.account_number = m.account_number LEFT JOIN rental r
ON c.contact_id = r.customer_id
AND tu.check_out_date = r.check_out_date
AND tu.return_date = r.return_date INNER JOIN common_lookup cl
ON cl.common_lookup_table = 'RENTAL_ITEM'
AND cl.common_lookup_column = 'RENTAL_ITEM_TYPE'
AND cl.common_lookup_type = tu.rental_item_type LEFT JOIN rental_item ri
ON r.rental_id = ri.rental_id
);
SET FOREIGN_KEY_CHECKS=1;
-- Insert into the transaction table
REPLACE INTO transaction (
SELECT
t.transaction_id as transaction_id,
tu.payment_account_number AS transaction_account,
cl1.common_lookup_id AS transaction_type,
tu.transaction_date AS transaction_date,
(SUM(tu.transaction_amount) / 1.06) AS transaction_amount,
r.rental_id as rental_id,
cl2.common_lookup_id AS payment_method_type,
m.credit_card_number AS payment_account_number,
1003 AS created_by,
UTC_DATE() AS creation_date,
1003 AS last_updated_by,
UTC_DATE() AS last_update_date
FROM member m INNER JOIN contact c
ON m.member_id = c.member_id INNER JOIN transaction_upload tu
ON c.first_name = tu.first_name
AND IFNULL(c.middle_name,'x') = IFNULL(tu.middle_name,'x')
AND c.last_name = tu.last_name
AND tu.account_number = m.account_number LEFT JOIN rental r
ON c.contact_id = r.customer_id
AND tu.check_out_date = r.check_out_date
AND tu.return_date = r.return_date INNER JOIN common_lookup cl1
ON cl1.common_lookup_table = 'TRANSACTION'
AND cl1.common_lookup_column = 'TRANSACTION_TYPE'
AND cl1.common_lookup_type = tu.transaction_type INNER JOIN common_lookup cl2
ON cl2.common_lookup_table = 'TRANSACTION'
AND cl2.common_lookup_column = 'PAYMENT_METHOD_TYPE'
AND cl2.common_lookup_type = tu.payment_method_type LEFT JOIN transaction t
ON t.transaction_account = tu.payment_account_number
AND t.rental_id = r.rental_id
AND t.transaction_type = cl1.common_lookup_type
AND t.transaction_date = tu.transaction_date
AND t.payment_method_type = cl2.common_lookup_id
AND t.payment_account_number = m.credit_card_number
GROUP BY transaction_id,
transaction_account,
transaction_type,
transaction_date,
rental_id,
payment_method_type,
payment_account_number,
created_by,
creation_date,
last_updated_by,
last_update_date
);
-- Create transaction_upload procedure
-- Conditionally drop the procedure.
DROP PROCEDURE IF EXISTS transaction_upload;
-- Reset the execution delimiter to create a stored program.
DELIMITER $$
-- The parentheses after the procedure name must be there or the MODIFIES SQL DATA raises an compile time exception.
CREATE PROCEDURE transaction_upload() MODIFIES SQL DATA
BEGIN
/* Declare a handler variables. */
DECLARE duplicate_key INT DEFAULT 0;
DECLARE foreign_key INT DEFAULT 0;
/* Declare a duplicate key handler */
DECLARE CONTINUE HANDLER FOR 1062 SET duplicate_key = 1;
DECLARE CONTINUE HANDLER FOR 1216 SET foreign_key = 1;
/* ---------------------------------------------------------------------- */
/* Start transaction context. */
START TRANSACTION;
/* Set savepoint. */
SAVEPOINT both_or_none;
/* Replace into rental table. */
REPLACE INTO rental (
SELECT DISTINCT
r.rental_id AS rental_id,
c.contact_id AS customer_id,
tu.check_out_date AS check_out_date,
tu.return_date AS return_date,
1003 AS created_by,
UTC_DATE() AS creation_date,
1003 AS last_updated_by,
UTC_DATE() AS last_update_date
FROM member m INNER JOIN contact c
ON m.member_id = c.member_id INNER JOIN transaction_upload tu
ON c.first_name = tu.first_name
AND IFNULL(c.middle_name,'x') = IFNULL(tu.middle_name,'x')
AND c.last_name = tu.last_name
AND tu.account_number = m.account_number LEFT JOIN rental r
ON c.contact_id = r.customer_id
AND tu.check_out_date = r.check_out_date
AND tu.return_date = r.return_date
);
/* Replace into rental_item table. */
UPDATE transaction_upload SET item_id = 1001 WHERE item_id = 1;
UPDATE transaction_upload SET item_id = 1012 WHERE item_id = 12;
SET FOREIGN_KEY_CHECKS=0;
REPLACE INTO rental_item (
SELECT
ri.rental_item_id AS rental_item_id,
r.rental_id AS rental_id,
tu.item_id AS item_id,
DATEDIFF(r.return_date, r.check_out_date) AS rental_item_price,
cl.common_lookup_id AS rental_item_type,
1003 AS created_by,
UTC_DATE() AS creation_date,
1003 AS last_updated_by,
UTC_DATE() AS last_update_date
FROM member m INNER JOIN contact c
ON m.member_id = c.member_id INNER JOIN transaction_upload tu
ON c.first_name = tu.first_name
AND IFNULL(c.middle_name,'x') = IFNULL(tu.middle_name,'x')
AND c.last_name = tu.last_name
AND tu.account_number = m.account_number LEFT JOIN rental r
ON c.contact_id = r.customer_id
AND tu.check_out_date = r.check_out_date
AND tu.return_date = r.return_date INNER JOIN common_lookup cl
ON cl.common_lookup_table = 'RENTAL_ITEM'
AND cl.common_lookup_column = 'RENTAL_ITEM_TYPE'
AND cl.common_lookup_type = tu.rental_item_type LEFT JOIN rental_item ri
ON r.rental_id = ri.rental_id
);
SET FOREIGN_KEY_CHECKS=1;
/* Replace into transaction table. */
REPLACE INTO transaction (
SELECT
t.transaction_id as transaction_id,
tu.payment_account_number AS transaction_account,
cl1.common_lookup_id AS transaction_type,
tu.transaction_date AS transaction_date,
(SUM(tu.transaction_amount) / 1.06) AS transaction_amount,
r.rental_id as rental_id,
cl2.common_lookup_id AS payment_method_type,
m.credit_card_number AS payment_account_number,
1003 AS created_by,
UTC_DATE() AS creation_date,
1003 AS last_updated_by,
UTC_DATE() AS last_update_date
FROM member m INNER JOIN contact c
ON m.member_id = c.member_id INNER JOIN transaction_upload tu
ON c.first_name = tu.first_name
AND IFNULL(c.middle_name,'x') = IFNULL(tu.middle_name,'x')
AND c.last_name = tu.last_name
AND tu.account_number = m.account_number LEFT JOIN rental r
ON c.contact_id = r.customer_id
AND tu.check_out_date = r.check_out_date
AND tu.return_date = r.return_date INNER JOIN common_lookup cl1
ON cl1.common_lookup_table = 'TRANSACTION'
AND cl1.common_lookup_column = 'TRANSACTION_TYPE'
AND cl1.common_lookup_type = tu.transaction_type INNER JOIN common_lookup cl2
ON cl2.common_lookup_table = 'TRANSACTION'
AND cl2.common_lookup_column = 'PAYMENT_METHOD_TYPE'
AND cl2.common_lookup_type = tu.payment_method_type LEFT JOIN transaction t
ON t.transaction_account = tu.payment_account_number
AND t.rental_id = r.rental_id
AND t.transaction_type = cl1.common_lookup_type
AND t.transaction_date = tu.transaction_date
AND t.payment_method_type = cl2.common_lookup_id
AND t.payment_account_number = m.credit_card_number
GROUP BY transaction_id,
transaction_account,
transaction_type,
transaction_date,
rental_id,
payment_method_type,
payment_account_number,
created_by,
creation_date,
last_updated_by,
last_update_date
);
/* ---------------------------------------------------------------------- */
/* This acts as an exception handling block. */
IF duplicate_key = 1 OR foreign_key = 1 THEN
/* This undoes all DML statements to this point in the procedure. */
ROLLBACK TO SAVEPOINT both_or_none;
ELSE
/* This commits the writes. */
COMMIT;
END IF;
END;
$$
-- Reset the delimiter to the default.
DELIMITER ;
CALL transaction_upload();
SELECT c1.rental_count
, c2.rental_item_count
, c3.transaction_count
FROM (SELECT COUNT(*) AS rental_count FROM rental) c1 CROSS JOIN
(SELECT COUNT(*) AS rental_item_count FROM rental_item) c2 CROSS JOIN
(SELECT COUNT(*) AS transaction_count FROM transaction) c3;
-- Create a query to present the financial data from 2009 by month
SELECT
il.month AS 'MONTH YEAR',
il.base AS 'BASE_REVENUE',
il.plus10 AS '10_PLUS',
il.plus20 AS '20_PLUS',
il.only10 AS '10_PLUS_LESS_BASE',
il.only20 AS '20_PLUS_LESS_BASE'
FROM (SELECT
CONCAT(EXTRACT(MONTH FROM t.transaction_date),CONCAT('-',EXTRACT(YEAR FROM t.transaction_date))) AS MONTH,
EXTRACT(MONTH FROM t.transaction_date) AS sortkey,
CONCAT('$',FORMAT(SUM(t.transaction_amount),2)) AS base,
CONCAT('$',FORMAT(SUM(t.transaction_amount) * 1.1,2)) AS plus10,
CONCAT('$',FORMAT(SUM(t.transaction_amount) * 1.2,2)) AS plus20,
CONCAT('$',FORMAT(SUM(t.transaction_amount) * 0.1,2)) AS only10,
CONCAT('$',FORMAT(SUM(t.transaction_amount) * 0.2,2)) AS only20
FROM transaction t
WHERE EXTRACT(YEAR FROM t.transaction_date) = 2009
GROUP BY CONCAT(EXTRACT(MONTH FROM t.transaction_date),CONCAT('-',EXTRACT(YEAR FROM t.transaction_date))),
EXTRACT(MONTH FROM t.transaction_date)) il
ORDER BY il.sortkey; | true |
6e15aea4c0a8d0f66b80c0490cbcc2446e579973 | SQL | sled30/osint1 | /db/osint_create_catalog.sql | UTF-8 | 5,456 | 2.59375 | 3 | [] | no_license | -- MySQL Script generated by MySQL Workbench
-- Сб 01 дек 2018 13:35:20
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema osint
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema osint
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `osint` DEFAULT CHARACTER SET utf8 ;
SHOW WARNINGS;
USE `osint` ;
-- -----------------------------------------------------
-- Table `auto_model`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto_model` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto_model` (
`id` INT NOT NULL AUTO_INCREMENT,
`model_name` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `auto_modif`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto_modif` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto_modif` (
`id` INT NOT NULL AUTO_INCREMENT,
`auto_modifcol` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `auto_year`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto_year` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto_year` (
`id` INT NOT NULL AUTO_INCREMENT,
`auto_yearcol` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `auto_kpp`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto_kpp` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto_kpp` (
`id` INT NOT NULL AUTO_INCREMENT,
`auto_kppcol` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `auto_dvs`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto_dvs` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto_dvs` (
`id` INT NOT NULL AUTO_INCREMENT,
`auto_dvscol` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `auto_own`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto_own` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto_own` (
`id` INT NOT NULL AUTO_INCREMENT,
`auto_owncol` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `auto_exchange`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto_exchange` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto_exchange` (
`id` INT NOT NULL AUTO_INCREMENT,
`auto_exchangecol` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `auto_status`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto_status` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto_status` (
`id` INT NOT NULL AUTO_INCREMENT,
`auto_statuscol` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `auto_condition`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto_condition` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto_condition` (
`id` INT NOT NULL AUTO_INCREMENT,
`auto_conditioncol` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `auto_body`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto_body` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto_body` (
`id` INT NOT NULL AUTO_INCREMENT,
`auto_bodycol` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `auto`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `auto` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `auto` (
`id` INT NOT NULL AUTO_INCREMENT,
`auto_model_id` INT NOT NULL,
`auto_modif_id` INT NOT NULL,
`auto_year_id` INT NOT NULL,
`auto_kpp_id` INT NOT NULL,
`auto_dvs_id` INT NOT NULL,
`auto_own_id` INT NOT NULL,
`auto_exchange_id` INT NOT NULL,
`auto_status_id` INT NOT NULL,
`auto_condition_id` INT NOT NULL,
`phone_id` INT NOT NULL,
`dict_rudder_id` INT NOT NULL,
`auto_body_id` INT NOT NULL,
`avito_avtor_name_id` INT NOT NULL,
`probeg` VARCHAR(100) NULL,
`sell` VARCHAR(100) NULL,
`avito_sity_id` INT NOT NULL,
PRIMARY KEY (`id`, `auto_model_id`, `auto_modif_id`, `auto_year_id`, `auto_kpp_id`, `auto_dvs_id`, `auto_own_id`, `auto_exchange_id`, `auto_status_id`, `auto_condition_id`, `phone_id`, `dict_rudder_id`, `auto_body_id`, `avito_avtor_name_id`, `avito_sity_id`))
ENGINE = InnoDB;
SHOW WARNINGS;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
| true |
043616cfca7ceab15816d11c8d4aad3e382cf9f1 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/low/day23/select1327.sql | UTF-8 | 178 | 2.671875 | 3 | [] | no_license |
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o
WHERE timestamp>'2017-11-22T13:27:00Z' AND timestamp<'2017-11-23T13:27:00Z' AND temperature>=12 AND temperature<=22
| true |
50b6f7e556f61432bd6bcf9cb10ac74fd0abf484 | SQL | dccfmatos/SQL_Exercicios | /Exercicios_w3resourcecom-sql-retrieve-from-table.sql | UTF-8 | 11,886 | 4.34375 | 4 | [] | no_license | #https://www.w3resource.com/sql-exercises/sql-retrieve-from-table.php
create database Exercicios;
use Exercicios;
create table salesman(
salesman_id int AUTO_INCREMENT primary key,
name varchar(30),
city varchar(30),
comission decimal(3,2)
);
desc salesman;
alter table salesman
modify comission decimal (3,2) not null;
ALTER TABLE salesman AUTO_INCREMENT = 5000; #alterar valor inicial do incremento
INSERT INTO `exercicios`.`salesman` (`salesman_id`, `name`, `city`, `comission`) VALUES ('5001', 'James Hoog', 'New York', '0.15');
INSERT INTO `exercicios`.`salesman` (`salesman_id`, `name`, `city`, `comission`) VALUES ('5002', 'Nail Knite', 'Paris', '0.13');
INSERT INTO `exercicios`.`salesman` (`salesman_id`, `name`, `city`, `comission`) VALUES ('5005', 'Pit Alex ', 'London', '0.11');
INSERT INTO `exercicios`.`salesman` (`salesman_id`, `name`, `city`, `comission`) VALUES ('5006', 'Mc Lyon', 'Paris', '0.14');
INSERT INTO `exercicios`.`salesman` (`salesman_id`, `name`, `city`, `comission`) VALUES ('5007', 'Paul Adam', 'Rome', '0.13');
INSERT INTO `exercicios`.`salesman` (`salesman_id`, `name`, `city`, `comission`) VALUES ('5003', 'Lauson Hen', 'San Jose', '0.12');
#drop table salesman;
-------------------------------------------------------------------
#1. Write a SQL statement to display all the information of all salesmen.
select * from salesman;
------------------------------
-------------------------------------------------------------------
#2. Write a SQL statement to display a string "This is SQL Exercise, Practice and Solution"
SELECT 'This is SQL Exercise, Practice and Solution';
-----------------------------
-------------------------------------------------------------------
#3. Write a query to display three numbers in three columns.
select 1,2,3;
-----------------------------
-------------------------------------------------------------------
#4. Write a query to display the sum of two numbers 10 and 15 from RDMS sever.
select 10+5;
-----------------------------
-------------------------------------------------------------------
#5. Write a query to display the result of an arithmetic expression.
select 10+5*2-1;
-----------------------------
-------------------------------------------------------------------
#6. Write a SQL statement to display specific columns like name and commission for all the salesmen.
select name, comission from salesman;
-----------------------------
-------------------------------------------------------------------
#7. Write a query to display the columns in a specific order like order date, salesman id, order number and purchase amount from for all the orders.
#criar tabela
create table orders(
ord_no int primary key,
purch_amt decimal (8,2),
ord_date date,
costumer_id int,
salesman_id int,
foreign key(salesman_id) references salesman(salesman_id) #coluna da tabela anterior
)default charset = utf8mb4;
drop table orders;
desc orders;
select * from orders;
select ord_date, salesman_id, ord_no, purch_amt from orders;
-----------------------------
-------------------------------------------------------------------
#8. Write a query which will retrieve the value of salesman id of all salesmen, getting orders from the customers in orders table without any repeats.
select salesman_id from orders; #vai mostrar repetido, apenas queremos ver a listagem dos dierentes vendedores
select distinct salesman_id from orders;
-----------------------------
-------------------------------------------------------------------
#9. Write a SQL statement to display names and city of salesman, who belongs to the city of Paris.
desc salesman;
select salesman_id, name, city from salesman
where city='Paris';
-----------------------------
-------------------------------------------------------------------
#10. Write a SQL statement to display all the information for those customers with a grade of 200.
create table costumer(
costumer_id numeric(5) primary key,
cust_name varchar(30),
city varchar(15),
grade numeric(3),
salesman_id int(5),
foreign key(salesman_id) references salesman(salesman_id)
)default charset = utf8mb4;
desc costumer;
select * from costumer;
select * from costumer
where grade='200';
-----------------------------
-------------------------------------------------------------------
#11. Write a SQL query to display the order number followed by order
#date and the purchase amount for each order which will be delivered by the salesman who is holding the ID 5001.
desc orders;
select ord_no, ord_date, purch_amt
from orders
where salesman_id='5001';
-----------------------------
-------------------------------------------------------------------
#12. Write a SQL query to display the Nobel prizes for 1970.
create table nobel_win(
year numeric(4),
subject varchar(30),
winner varchar(30) primary key,
country varchar(15),
category varchar(30)
)default charset = utf8mb4;
desc nobel_win;
select*from nobel_win;
#drop table nobel_win;
select * from nobel_win
where year='1970';
-----------------------------
-------------------------------------------------------------------
#13. Write a SQL query to know the winner of the 1971 prize for Linguist.
select winner, year, category from nobel_win
where year='1971' && category='Linguist';
-----------------------------
-------------------------------------------------------------------
#14. Write a SQL query to display the year and subject that won 'Dennis Gabor' his prize.
select winner, year, subject
from nobel_win
where winner='Dennis Gabor';
-----------------------------
-------------------------------------------------------------------
#15. Write a SQL query to give the name of the 'Physics' winners since the year 1950
select year, winner
from nobel_win
where year >='1950' && subject='Physics';
-----------------------------
-------------------------------------------------------------------
#16. Write a SQL query to Show all the details (year, subject, winner, country ) of the Chemistry prize winners between the year 1965 to 1975 inclusive.
select *
from nobel_win
where year >='1965' && year<='1975' && subject='Chemistry';
-----------------------------
-------------------------------------------------------------------
#17. Write a SQL query to show all details of the Prime Ministerial winners after 1972 of Menachem Begin and Yitzhak Rabin.
select *
from nobel_win
where year >'1972'
AND winner IN ('Menachem Begin','Yitzhak Rabin');
-----------------------------
-------------------------------------------------------------------
#18. Write a SQL query to show all the details of the winners with first name Louis.
select *
from nobel_win
where winner like 'Louis%';
-----------------------------
-------------------------------------------------------------------
#19. Write a SQL query to show all the winners in Physics for 1970 together with the winner of Economics for 1971.
select *
from nobel_win where (subject='Physics' && year='1970')
union
(select *
from nobel_win where (subject='Economics' && year='1971'));
-----------------------------
-------------------------------------------------------------------
#20. Write a SQL query to show all the winners of nobel prize in the year 1970 except the subject Physiology and Economics.
select *
from nobel_win
where year=1970 && subject<>'Physiology' && subject<>'Economics';
select *
from nobel_win
where year=1970 &&
subject NOT IN('Physiology','Economics');
-----------------------------
-------------------------------------------------------------------
#21. Write a SQL query to show the winners of a 'Physiology' prize in an early year before 1971 together with winners of a 'Peace' prize in a later year on and after the 1974.
select *
from nobel_win where (subject='Physiology' && year<'1971')
union
(select *
from nobel_win where (subject='Peace' && year>'1974'));
-----------------------------
-------------------------------------------------------------------
#22. Write a SQL query to find all details of the prize won by Johannes Georg Bednorz.
select *
from nobel_win
where winner='Johannes Georg Bednorz';
-----------------------------
-------------------------------------------------------------------
#23. Write a SQL query to find all the details of the nobel winners for the subject not started with the letter 'P' and arranged the list as the most recent comes first, then by name in order.
select *
from nobel_win
where subject not like'P%'
order by year desc, winner;
-----------------------------
-------------------------------------------------------------------
#24. Write a SQL query to find all the details of 1970 winners by the ordered to subject and winner name; but the list contain the subject Economics and Chemistry at last.
select *
from nobel_win
where year= 1970
order by
CASE
WHEN subject IN ('Economics','Chemistry') THEN 1
ELSE 0
END ASC,
subject, winner;
-----------------------------
-------------------------------------------------------------------
#25. Write a SQL query to find all the products with a price between Rs.200 and Rs.600
create table item_mast(
PRO_ID numeric(3) primary key,
PRO_NAME varchar(30),
PRO_PRICE numeric(5),
PRO_COM numeric(2)
)default charset = utf8mb4;
desc item_mast;
select*from item_mast;
#drop table item_mast;
select *
from item_mast
where pro_price between 200 and 600; #aqui o && nao funciona
-----------------------------
-------------------------------------------------------------------
#26. Write a SQL query to calculate the average price of all products of the manufacturer which code is 16.
select avg(pro_price)
from item_mast
where pro_com=16;
-----------------------------
-------------------------------------------------------------------
#27. Write a SQL query to find the item name and price in Rs.
desc item_mast;
select pro_name as "Item Name", pro_price as "Price in Rs."
from item_mast;
-----------------------------
-------------------------------------------------------------------
#28. Write a SQL query to display the name and price of all the items with a price is equal or more than Rs.250, and the list contain the larger price first and then by name in ascending order.
select pro_name as "Item Name", pro_price as "Price in Rs."
from item_mast
where pro_price >= 250
order by
pro_price desc,
pro_name;
-----------------------------
-------------------------------------------------------------------
#29. Write a SQL query to display the average price of the items for each company, showing only the company code.
select avg(pro_price), pro_com
from item_mast
group by pro_com;
-----------------------------
-------------------------------------------------------------------
#30. Write a SQL query to find the name and price of the cheapest item(s).
select pro_name, pro_price
from item_mast
where pro_price=
(select min(pro_price) from item_mast);
-----------------------------
-------------------------------------------------------------------
#31. Write a query in SQL to find the last name of all employees, without duplicates.
create table emp_details(
EMP_IDNO numeric(6) primary key,
EMP_FNAME varchar(15),
EMP_LNAME varchar(15),
EMP_DEPT numeric(2)
)default charset = utf8mb4;
desc emp_details;
select*from emp_details;
#drop table emp_details;
select emp_lname
from emp_details
group by emp_lname;
select distinct emp_lname as "Last name"
from emp_details;
-----------------------------
-------------------------------------------------------------------
#32. Write a query in SQL to find the data of employees whose last name is 'Snares'.
select *
from emp_details
where emp_lname='Snares';
-----------------------------
-------------------------------------------------------------------
#33. Write a query in SQL to display all the data of employees that work in the department 57
desc emp_details;
select *
from emp_details
where emp_dept='57';
-----------------------------
| true |
24e0325e1b8f85f37b2150ccbb5ffacd6d337108 | SQL | jstiago/sql | /show_dumpfile_info.sql | UTF-8 | 8,203 | 2.84375 | 3 | [] | no_license | CREATE OR REPLACE PROCEDURE show_dumpfile_info(
p_dir VARCHAR2 DEFAULT 'DATA_PUMP_DIR',
p_file VARCHAR2 DEFAULT 'EXPDAT.DMP')
AS
v_separator VARCHAR2(80) := '----------';
v_path all_directories.directory_path%type := '?';
v_filetype NUMBER; -- 0=unknown 1=expdp 2=exp
v_fileversion VARCHAR2(15); -- 0.1=10gR1 1.1=10gR2 2.1=11g
v_info_table sys.ku$_dumpfile_info; -- PL/SQL table with file info
type valtype IS VARRAY(22) OF VARCHAR2(2048);
var_values valtype := valtype();
no_file_found EXCEPTION;
PRAGMA exception_init(no_file_found, -39211);
BEGIN
-- Show generic info:
-- ==================
dbms_output.put_line(v_separator);
dbms_output.put_line('Purpose..: Obtain details about export ' ||
'dumpfile. Version: 19-MAR-2008');
dbms_output.put_line('Required.: RDBMS version: 10.2.0.1.0 or higher');
dbms_output.put_line('. ' ||
'Export dumpfile version: 7.3.4.0.0 or higher');
dbms_output.put_line('. ' ||
'Export Data Pump dumpfile version: 10.1.0.1.0 or higher');
dbms_output.put_line('Usage….: ' ||
'execute show_dumpfile_info("DIRECTORY", "DUMPFILE");');
dbms_output.put_line('Example..: ' ||
'exec show_dumpfile_info("MY_DIR", "expdp_s.dmp")');
dbms_output.put_line(v_separator);
dbms_output.put_line('Filename.: ' || p_file);
dbms_output.put_line('Directory: ' || p_dir);
-- Retrieve Export dumpfile details:
-- =================================
SELECT directory_path INTO v_path FROM all_directories
WHERE directory_name = p_dir
OR directory_name = UPPER(p_dir);
dbms_datapump.get_dumpfile_info(
filename => p_file, directory => UPPER(p_dir),
info_table => v_info_table, filetype => v_filetype);
var_values.EXTEND(22);
FOR i in 1 .. 22 LOOP
BEGIN
SELECT value INTO var_values(i) FROM TABLE(v_info_table)
WHERE item_code = i;
EXCEPTION WHEN OTHERS THEN var_values(i) := '';
END;
END LOOP;
-- Show dumpfile details:
-- ======================
-- For Oracle10g Release 2 and higher:
-- dbms_datapump.KU$_DFHDR_FILE_VERSION CONSTANT NUMBER := 1;
-- dbms_datapump.KU$_DFHDR_MASTER_PRESENT CONSTANT NUMBER := 2;
-- dbms_datapump.KU$_DFHDR_GUID CONSTANT NUMBER := 3;
-- dbms_datapump.KU$_DFHDR_FILE_NUMBER CONSTANT NUMBER := 4;
-- dbms_datapump.KU$_DFHDR_CHARSET_ID CONSTANT NUMBER := 5;
-- dbms_datapump.KU$_DFHDR_CREATION_DATE CONSTANT NUMBER := 6;
-- dbms_datapump.KU$_DFHDR_FLAGS CONSTANT NUMBER := 7;
-- dbms_datapump.KU$_DFHDR_JOB_NAME CONSTANT NUMBER := 8;
-- dbms_datapump.KU$_DFHDR_PLATFORM CONSTANT NUMBER := 9;
-- dbms_datapump.KU$_DFHDR_INSTANCE CONSTANT NUMBER := 10;
-- dbms_datapump.KU$_DFHDR_LANGUAGE CONSTANT NUMBER := 11;
-- dbms_datapump.KU$_DFHDR_BLOCKSIZE CONSTANT NUMBER := 12;
-- dbms_datapump.KU$_DFHDR_DIRPATH CONSTANT NUMBER := 13;
-- dbms_datapump.KU$_DFHDR_METADATA_COMPRESSED CONSTANT NUMBER := 14;
-- dbms_datapump.KU$_DFHDR_DB_VERSION CONSTANT NUMBER := 15;
-- For Oracle11gR1:
-- dbms_datapump.KU$_DFHDR_MASTER_PIECE_COUNT CONSTANT NUMBER := 16;
-- dbms_datapump.KU$_DFHDR_MASTER_PIECE_NUMBER CONSTANT NUMBER := 17;
-- dbms_datapump.KU$_DFHDR_DATA_COMPRESSED CONSTANT NUMBER := 18;
-- dbms_datapump.KU$_DFHDR_METADATA_ENCRYPTED CONSTANT NUMBER := 19;
-- dbms_datapump.KU$_DFHDR_DATA_ENCRYPTED CONSTANT NUMBER := 20;
-- For Oracle11gR2:
-- dbms_datapump.KU$_DFHDR_COLUMNS_ENCRYPTED CONSTANT NUMBER := 21;
-- dbms_datapump.KU$_DFHDR_ENCPWD_MODE CONSTANT NUMBER := 22;
-- For Oracle10gR2: KU$_DFHDR_MAX_ITEM_CODE CONSTANT NUMBER := 15;
-- For Oracle11gR1: KU$_DFHDR_MAX_ITEM_CODE CONSTANT NUMBER := 20;
-- For Oracle11gR2: KU$_DFHDR_MAX_ITEM_CODE CONSTANT NUMBER := 22;
dbms_output.put_line('Disk Path: ' || v_path);
IF v_filetype = 1 OR v_filetype = 2 THEN
-- Get characterset name:
BEGIN
SELECT var_values(5) || ' (' || nls_charset_name(var_values(5)) ||
')' INTO var_values(5) FROM dual;
EXCEPTION WHEN OTHERS THEN null;
END;
IF v_filetype = 2 THEN
dbms_output.put_line(
'Filetype.: ' || v_filetype || ' (Original Export dumpfile)');
dbms_output.put_line(v_separator);
SELECT DECODE(var_values(13), '0', '0 (Conventional Path)',
'1', '1 (Direct Path)', var_values(13))
INTO var_values(13) FROM dual;
dbms_output.put_line('…Characterset ID.: ' || var_values(5));
dbms_output.put_line('…Direct Path…..: ' || var_values(13));
dbms_output.put_line('…Export Version..: ' || var_values(15));
ELSIF v_filetype = 1 THEN
dbms_output.put_line(
'Filetype.: ' || v_filetype || ' (Export Data Pump dumpfile)');
dbms_output.put_line(v_separator);
SELECT SUBSTR(var_values(1), 1, 15) INTO v_fileversion FROM dual;
SELECT DECODE(var_values(1),
'0.1', '0.1 (Oracle10g Release 1: 10.1.0.x)',
'1.1', '1.1 (Oracle10g Release 2: 10.2.0.x)',
'2.1', '2.1 (Oracle11g Release 1: 11.1.0.x)',
'3.1', '3.1 (Oracle11g Release 2: 11.2.0.x)',
var_values(1)) INTO var_values(1) FROM dual;
SELECT DECODE(var_values(2), '0', '0 (No)', '1', '1 (Yes)',
var_values(2)) INTO var_values(2) FROM dual;
SELECT DECODE(var_values(14), '0', '0 (No)', '1', '1 (Yes)',
var_values(14)) INTO var_values(14) FROM dual;
SELECT DECODE(var_values(18), '0', '0 (No)', '1', '1 (Yes)',
var_values(18)) INTO var_values(18) FROM dual;
SELECT DECODE(var_values(19), '0', '0 (No)', '1', '1 (Yes)',
var_values(19)) INTO var_values(19) FROM dual;
SELECT DECODE(var_values(20), '0', '0 (No)', '1', '1 (Yes)',
var_values(20)) INTO var_values(20) FROM dual;
SELECT DECODE(var_values(21), '0', '0 (No)', '1', '1 (Yes)',
var_values(21)) INTO var_values(21) FROM dual;
SELECT DECODE(var_values(22),
'1', '1 (Unknown)',
'2', '2 (None)',
'3', '3 (Password)',
'4', '4 (Dual)',
'5', '5 (Transparent)',
var_values(22)) INTO var_values(22) FROM dual;
dbms_output.put_line('…File Version….: ' || var_values(1));
dbms_output.put_line('…Master Present..: ' || var_values(2));
dbms_output.put_line('…GUID…………: ' || var_values(3));
dbms_output.put_line('…File Number…..: ' || var_values(4));
dbms_output.put_line('…Characterset ID.: ' || var_values(5));
dbms_output.put_line('…Creation Date…: ' || var_values(6));
dbms_output.put_line('…Flags………..: ' || var_values(7));
dbms_output.put_line('…Job Name……..: ' || var_values(8));
dbms_output.put_line('…Platform……..: ' || var_values(9));
IF v_fileversion >= '2.1' THEN
dbms_output.put_line('…Instance……..: ' || var_values(10));
END IF;
dbms_output.put_line('…Language……..: ' || var_values(11));
dbms_output.put_line('…Block size……: ' || var_values(12));
dbms_output.put_line('…Metadata Compres: ' || var_values(14));
IF dbms_datapump.KU$_DFHDR_MAX_ITEM_CODE > 15 THEN
dbms_output.put_line('…Data Compressed.: ' || var_values(18));
dbms_output.put_line('…Metadata Encrypt: ' || var_values(19));
dbms_output.put_line('…Data Encrypted..: ' || var_values(20));
dbms_output.put_line('…Column Encrypted: ' || var_values(21));
dbms_output.put_line('…Encrypt.pwd. mod: ' || var_values(22));
IF v_fileversion = '2.1' or v_fileversion = '3.1' THEN
dbms_output.put_line('…Master Piece Cnt: ' || var_values(16));
dbms_output.put_line('…Master Piece Num: ' || var_values(17));
END IF;
END IF;
IF v_fileversion >= '1.1' THEN
dbms_output.put_line('…Job Version…..: ' || var_values(15));
END IF;
dbms_output.put_line('…Max Items Code..: ' ||
dbms_datapump.KU$_DFHDR_MAX_ITEM_CODE);
END IF;
ELSE
dbms_output.put_line('Filetype.: ' || v_filetype);
dbms_output.put_line(v_separator);
dbms_output.put_line('ERROR….: Not an export dumpfile.');
END IF;
dbms_output.put_line(v_separator);
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line('Disk Path: ?');
dbms_output.put_line('Filetype.: ?');
dbms_output.put_line(v_separator);
dbms_output.put_line('ERROR….: Directory Object does not exist.');
dbms_output.put_line(v_separator);
WHEN no_file_found THEN
dbms_output.put_line('Disk Path: ' || v_path);
dbms_output.put_line('Filetype.: ?');
dbms_output.put_line(v_separator);
dbms_output.put_line('ERROR….: File does not exist.');
dbms_output.put_line(v_separator);
END;
/
| true |
967fe096d51ea11587e7f7818332963085d7e76c | SQL | yellowpad/sql-library-lab-web-0217 | /lib/insert.sql | UTF-8 | 1,381 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | INSERT INTO series VALUES
(1,"Book",1,2);
INSERT INTO series VALUES
(2,"Book2",2,3);
INSERT INTO books VALUES
(1,"Book1",1990,2);
INSERT INTO books VALUES
(2,"Book2",1990,2);
INSERT INTO books VALUES
(3,"Book3",1991,1);
INSERT INTO books VALUES
(4,"Book4",1992,2);
INSERT INTO books VALUES
(5,"Book5",1993,1);
INSERT INTO books VALUES
(6,"Book6",1994,1);
INSERT INTO characters VALUES
(1,"jim","motto","species",2,1);
INSERT INTO characters VALUES
(2,"tom","motto","species",2,1);
INSERT INTO characters VALUES
(3,"bob","motto","species",2,1);
INSERT INTO characters VALUES
(4,"george","motto","species",2,1);
INSERT INTO characters VALUES
(5,"jerry","motto","species",2,2);
INSERT INTO characters VALUES
(6,"Susy","motto","species",2,2);
INSERT INTO characters VALUES
(7,"sally","motto","species",2,2);
INSERT INTO characters VALUES
(8,"tina","motto","species",2,2);
INSERT INTO subgenres VALUES
(1,"spooky ghost");
INSERT INTO subgenres VALUES
(2,"short stories");
INSERT INTO authors VALUES
(1,"John");
INSERT INTO authors VALUES
(2,"Tom");
INSERT INTO character_books (id, book_id, character_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 2), (4, 3, 2), (5, 1, 3), (6, 2, 3), (7, 3, 3), (8, 1, 4);
INSERT INTO character_books (id, book_id, character_id) VALUES (9, 4, 5), (10, 4, 6), (11, 5, 6), (12, 6, 6), (13, 4, 7), (14, 5, 7), (15, 6, 7), (16, 4, 8); | true |
c75ae1c598a73035cb3af2a3bf8f3838bd900005 | SQL | paulfuller/PAUL_Cashlinx_Maint | /src/Build/etc/version_template.sql | UTF-8 | 1,018 | 3.546875 | 4 | [] | no_license | --
--
MERGE INTO PAWNSEC.STOREAPPVERSION A USING
(SELECT
[APPID] as "ID",
'[APPVERSION]' as "APPVERSION",
'[DESCRIPTION] [APPVERSION] Release' as "DESCRIPTION",
TO_TIMESTAMP_TZ('3/16/2010 10:57:53.000000 AM -05:00','fmMMfm/fmDDfm/YYYY fmHH12fm:MI:SS.FF AM TZH:TZM') as "CREATIONDATE",
'admin' as "CREATEDBY",
TO_TIMESTAMP_TZ('[TIMESTAMP]','fmMMfm/fmDDfm/YYYY fmHH12fm:MI:SS.FF AM TZH:TZM') as "LASTUPDATEDATE",
'admin' as "UPDATEDBY",
'[APPVERSIONHASH]' as "VERCHK"
FROM DUAL) B
ON (A.ID = B.ID)
WHEN NOT MATCHED THEN
INSERT (
ID, APPVERSION, DESCRIPTION, CREATIONDATE, CREATEDBY,
LASTUPDATEDATE, UPDATEDBY, VERCHK)
VALUES (
B.ID, B.APPVERSION, B.DESCRIPTION, B.CREATIONDATE, B.CREATEDBY,
B.LASTUPDATEDATE, B.UPDATEDBY, B.VERCHK)
WHEN MATCHED THEN
UPDATE SET
A.APPVERSION = B.APPVERSION,
A.DESCRIPTION = B.DESCRIPTION,
A.CREATIONDATE = B.CREATIONDATE,
A.CREATEDBY = B.CREATEDBY,
A.LASTUPDATEDATE = B.LASTUPDATEDATE,
A.UPDATEDBY = B.UPDATEDBY,
A.VERCHK = B.VERCHK;
COMMIT;
| true |
cf25424e3df28a5bc40447ae524ef3a47bf874c3 | SQL | jingyigao/PROJET_BDA | /projet_bd.sql | ISO-8859-1 | 7,488 | 4.09375 | 4 | [] | no_license | /*table Entreprise*/
CREATE TABLE Entreprise(
NumEntreprise INTEGER CONSTRAINT PK_Entreprise PRIMARY KEY,
NomEntreprise VARCHAR2(30),
VilleEntreprise VARCHAR2(30),
CPEntreprise VARCHAR2(6));
/*table Etudiant*/
CREATE TABLE Etudiant(
NumEtudiant INTEGER CONSTRAINT PK_Etudiant PRIMARY KEY,
NomEtudiant VARCHAR2(30),
PrenomEtudiant VARCHAR2(30),
MdpEtudiant VARCHAR2(30)NOT NULL,
EmailEtudiant VARCHAR2(30),
TP VARCHAR2(5),
EnStage INT CHECK(EnStage IN ('1','0'))
);
CREATE TABLE Stagiaire(
NumEtudiant INTEGER CONSTRAINT CIR_Etudiant REFERENCES ETUDIANT,
NumEntreprise INTEGER CONSTRAINT CIR_Entreprise REFERENCES ENTREPRISE,
AnneeStage INTEGER NOT NULL
);
/*table des Stages en fonction des entreprises*/
CREATE TABLE TriStages_Entreprises(
AnneeStage INTEGER,
NbrStage INTEGER,
NumEntreprise INTEGER CONSTRAINT CIR_ENTR REFERENCES ENTREPRISE
);
/*Table Statistiques qui comporte une seule ligne */
CREATE TABLE Statistiques(
Identifiant INTEGER CONSTRAINT pk_stats PRIMARY KEY,
NbEtudiantAvecStage INTEGER,
NbEtudiantSansStage INTEGER,
NbEtudiantSansStageADateVoulue INTEGER,
NbEtudiantPrisParEntreprise INTEGER,
NbEtudiantMoyenParEntreprise INTEGER,
NbStageParZoneGeographique INTEGER,
NbStageToutesZonesGeographique INTEGER
);
/* insert des donnes*/
/*Inserer Etudiant*/
CREATE PROCEDURE InsertEtudiant(nb INTEGER,nom VARCHAR, prenom VARCHAR, MDP VARCHAR,email VARCHAR, TP VARCHAR, enStage VARCHAR)
AS
BEGIN
INSERT INTO Etudiant
VALUES(nb,nom,prenom,MDP,email,TP,enStage);
END;
/*Inserer Stagiaire*/
CREATE PROCEDURE InsertStagiaire(numEtudiant INTEGER,NumEntreprise INTEGER, Anneestage INTEGER)
AS
BEGIN
INSERT INTO Stagiaire
VALUES (numEtudiant,NumEntreprise,Anneestage);
END;
/*Inserer Entreprise*/
CREATE PROCEDURE InsertEntreprise(num INTEGER,nom VARCHAR,CPE VARCHAR,ville VARCHAR)
AS
BEGIN
INSERT INTO Entreprise
VALUES(num,nom,CPE,ville);
END;
/*Inserer Stage_Entreprise*/
CREATE PROCEDURE InsertStageEntreprise(AnneeStage INTEGER,NbrStage INTEGER,NumEntreprise INTEGER)
AS
BEGIN
INSERT INTO TRISTAGES_ENTREPRISES
VALUES(AnneeStage,NbrStage,NumEntreprise);
END;
/*cration des procdures*/
/*calcule du nombre d'tudiants avec stage cette anne*/
CREATE PROCEDURE NbAvecStage(Annee INTEGER)
IS
Nombre INTEGER;
BEGIN
SELECT COUNT(*) INTO Nombre
FROM Etudiant e, Stagiaire s
WHERE e.numEtudiant = s.numEtudiant
AND s.Anneestage = Annee
AND e.EnStage = '1';
UPDATE Statistiques SET NbEtudiantAvecStage = Nombre;
END;
/*calcule du nombre d'tudiants sans stage cette anne*/
CREATE PROCEDURE NbSansStage(Annee INTEGER)
IS
Nombre INTEGER;
BEGIN
SELECT COUNT(*) INTO Nombre
FROM Etudiant e, Stagiaire s
WHERE e.numEtudiant = s.numEtudiant
AND s.Anneestage = Annee
AND e.EnStage = '0';
UPDATE Statistiques SET NbEtudiantSansStage = Nombre;
END;
/*calcule du nombre d'tudiants sans stage pour l'anne voulue*/
CREATE PROCEDURE NbSansStageAnnee(Annee INTEGER)
IS
Nombre INTEGER;
BEGIN
SELECT COUNT(*) INTO Nombre
FROM Etudiant e, Stagiaire s
WHERE e.numEtudiant = s.numEtudiant
AND s.Anneestage = Annee
AND e.EnStage = '0';
UPDATE Statistiques SET NbEtudiantSansStageADateVoulue = Nombre;
END;
/*NombreTotal de stage pour une ville passe en paramtres*/
CREATE PROCEDURE NombreStageVille(Ville VARCHAR)
IS
Nombre_Stage INTEGER;
BEGIN
SELECT COUNT(*) INTO Nombre_Stage
FROM TriStages_Entreprises se, Entreprise e
WHERE se.NumEntreprise = e.NumEntreprise
AND e.VilleEntreprise = Ville;
UPDATE STATISTIQUES SET NbStageParZoneGeographique = Nombre_Stage;
END;
/*NombreTotal de stage pour un dpartement(code postal) passe en paramtres*/
CREATE PROCEDURE NombreStageDepartement(Departement VARCHAR)
IS
Nombre_Stage INTEGER;
BEGIN
SELECT COUNT(*) INTO Nombre_Stage
FROM TriStages_Entreprises se, Entreprise e
WHERE se.NumEntreprise = e.NumEntreprise
AND e.CPEntreprise = Departement;
UPDATE STATISTIQUES SET NbStageParZoneGeographique = Nombre_Stage;
END;
/*NE FONCTIONNE PAS
NombreTotal de stagiaire sur N annes
CREATE PROCEDURE NombreStagiaireAnnee(duree INTEGER)
IS
Nb_stage INTEGER;
Nb_stage_Total INTEGER;
Annee_precedente INTEGER:=2015;
Annee_derniere INTEGER:=duree;
BEGIN
LOOP
SELECT COUNT(se.NombreStage) INTO Nb_stage
FROM Stage_Entreprise se
WHERE se.AnneeStage = Annee_precedente;
SET Annee_precedente = Annee_precedente - 1;
SET Annee_derniere = Annee_derniere - 1;
SET Nb_stage_Total = Nb_stage_Total + Nb_stage;
EXIT WHEN Annee_derniere = 0;
END LOOP;
UPDATE STATISTIQUES SET NbEtudiantPrisParEntreprise = Nb_stage_Total;
END;*/
/*Nombre dans toutes les rgions*/
CREATE PROCEDURE NombreStagiaireMonde(nb INTEGER)
IS
Total INTEGER;
BEGIN
SELECT COUNT(*) INTO Total
FROM TriStages_Entreprises;
UPDATE Statistiques SET NbStageToutesZonesGeographique = Total;
END;
/* NE FONCTIONNE PAS
Nombre par N annes en moyenne
CREATE PROCEDURE NombreStagiaireAnneeMoyenne(period INTEGER)
AS
DECLARE Nombre_Stage INTEGER;
DECLARE Period I;
BEGIN
SELECT * FROM NombreStagiaire_Annee(period) INTO Nombre_Stage;
SELECT CONVERT(DOUBLE,Nombre_Stage) INTO Nombre_Stage;
SELECT CONVERT(DOUBLE,period) INTO Period;
UPDATE Statistiques SET NbEtudiantMoyenParEntreprise = Nombre_Stage/Period;
END;*/
/*procdure d'affichage des statistiques*/
CREATE FUNCTION afficherNbEtudiantAvecStage RETURN INTEGER
IS
nb INTEGER;
BEGIN
SELECT NbEtudiantAvecStage INTO nb
FROM Statistiques;
RETURN nb;
END;
CREATE FUNCTION afficherNbEtudiantSansStage RETURN INTEGER
IS nb INTEGER;
BEGIN
SELECT NbEtudiantSansStage INTO nb
FROM Statistiques;
RETURN nb;
END;
CREATE FUNCTION afficherEtudiantSsStageADate RETURN INTEGER
IS
nb INTEGER;
BEGIN
SELECT NbEtudiantSansStageADateVoulue INTO nb
FROM Statistiques;
RETURN nb;
END;
CREATE FUNCTION afficherEtudiantPsPEntreprise RETURN INTEGER
IS nb INTEGER;
BEGIN
SELECT NbEtudiantPrisParEntreprise INTO nb
FROM Statistiques;
RETURN nb;
END;
CREATE FUNCTION afficherStageZoneGeographique RETURN INTEGER
IS nb INTEGER;
BEGIN
SELECT NbStageParZoneGeographique INTO nb
FROM Statistiques;
RETURN nb;
END;
CREATE FUNCTION afficherStageTtesZsGeog RETURN INTEGER
IS nb INTEGER;
BEGIN
SELECT NbStageToutesZonesGeographique INTO nb
FROM Statistiques;
RETURN nb;
END;
/*NE FONCTIONNE PAS
CREATE TRIGGER after_update_Etudiant AFTER UPDATE
ON ETUDIANT FOR EACH ROW
DECLARE NbSansStage INTEGER;
DECLARE NbAvecStage INTEGER;
BEGIN
SELECT COUNT(e.NumEtudiant) INTO NbAvecStage
FROM etudiant e
WHERE e.EnStage = '1';
UPDATE STATISTIQUES SET NbEtudiantAvecStage = NbAvecStage
WHERE identifiant = 1;
SELECT COUNT(e.NumEtudiant) INTO NbSansStage
FROM etudiant e
WHERE e.EnStage = '0';
UPDATE STATISTIQUES SET NbEtudiantSansStage = NbSansStage
WHERE identifiant = 1;
END;*/
/* Les DROPS */
DROP TABLE TRISTAGES_ENTREPRISES;
DROP TABLE STATISTIQUES;
DROP TABLE STAGIAIRE;
DROP TABLE ETUDIANT;
DROP TABLE ENTREPRISE; | true |
dc80a90fd0cba2297a54551b54d3f19cacb95669 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/low/day12/select1659.sql | UTF-8 | 266 | 2.921875 | 3 | [] | no_license |
SELECT sen.name
FROM SENSOR sen, SENSOR_TYPE st, COVERAGE_INFRASTRUCTURE ci
WHERE sen.SENSOR_TYPE_ID=st.id AND st.name='WiFiAP' AND sen.id=ci.SENSOR_ID AND ci.INFRASTRUCTURE_ID=ANY(array['4004','2054','5100_1','3202','5100_8','2069','2086','2011','4234','2019'])
| true |
16659fc61a83d19f0f1e2f256c4217677efe637b | SQL | danieldiamond/gitlab-analytics | /transform/snowflake-dbt/models/staging/zuora/xf/saas_charges_with_namespace_id.sql | UTF-8 | 1,769 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | WITH zuora_base_mrr AS (
SELECT *
FROM {{ ref('zuora_base_mrr') }}
WHERE delivery = 'SaaS'
)
, customers_db_charges AS (
SELECT *
FROM {{ ref('customers_db_charges_xf') }}
)
, namespaces AS (
SELECT *
FROM {{ ref('gitlab_dotcom_namespaces') }}
)
, dim_accounts AS (
SELECT *
FROM {{ ref('dim_accounts') }}
)
, dim_customers AS (
SELECT *
FROM {{ ref('dim_customers') }}
)
, dim_subscriptions AS (
SELECT *
FROM {{ ref('dim_subscriptions') }}
)
, joined AS (
SELECT
zuora_base_mrr.rate_plan_charge_id,
zuora_base_mrr.subscription_name_slugify,
dim_accounts.account_id AS zuora_account_id,
COALESCE(merged_accounts.crm_id, dim_customers.crm_id) AS sfdc_account_id,
COALESCE(merged_accounts.ultimate_parent_account_id,
dim_customers.ultimate_parent_account_id) AS ultimate_parent_account_id,
COALESCE(merged_accounts.ultimate_parent_account_name,
dim_customers.ultimate_parent_account_name) AS ultimate_parent_account_name,
customers_db_charges.current_customer_id,
namespaces.namespace_id
FROM zuora_base_mrr
LEFT JOIN customers_db_charges
ON zuora_base_mrr.rate_plan_charge_id = customers_db_charges.rate_plan_charge_id
LEFT JOIN namespaces
ON customers_db_charges.current_gitlab_namespace_id = namespaces.namespace_id
LEFT JOIN dim_accounts
ON zuora_base_mrr.account_number = dim_accounts.account_number
LEFT JOIN dim_customers
ON dim_accounts.crm_id = dim_customers.crm_id
LEFT JOIN dim_customers AS merged_accounts
ON dim_customers.merged_to_account_id = merged_accounts.crm_id
)
SELECT *
FROM joined
| true |
3661fe01e1391f11b94bd0ab5ea8eb6d8cb14ae9 | SQL | ARWA-ALraddadi/python-tutorial-for-beginners | /09-Workshop/QueryAndUpdateAirlineDatabase.sql | UTF-8 | 2,603 | 4.1875 | 4 | [] | no_license | /* This SQLite script contains suggested solutions to the "Airline Database"
questions. Having imported the Airline database, you should run these
queries and statements one at a time to see the results. */
/* 1. The first query, reproduced below, produces 11 rows */
SELECT * FROM cities;
/* 2. The second query, reproduced below, produces 5 rows */
SELECT * FROM cities WHERE CountryCode = 'AUS';
/* 3. A query to produce all Australian cities is as follows */
SELECT CityName FROM cities WHERE CountryCode = 'AUS';
/* 4a. A query that displays rows for all aircraft with a
capacity of at least 150 seats, but not more than 250 seats
is as follows */
SELECT SeatingCapacity FROM aircraft
WHERE SeatingCapacity >= 150 AND SeatingCapacity <= 250;
/* 4b. Here's an alternative answer to Question 4 */
SELECT SeatingCapacity FROM aircraft
WHERE SeatingCapacity BETWEEN 150 AND 250;
/* 5. A query that displays just the aircraft description and
aircraft type columns for all aircraft is as follows */
SELECT AircraftDescription, AircraftType FROM aircraft;
/* 6. A query that displays the flight number, destination city,
and the number of remaining seats of all the flights that
depart from Brisbane and have more than 20 seats left is
as follows */
SELECT FlightNum, ToCityCode, SeatsRemaining FROM flights
WHERE FromCityCode = 'BNE' AND SeatsRemaining > 20;
/* 7. The following statement will change the number of seats
remaining on Flight 10 */
UPDATE flights SET SeatsRemaining = 25 WHERE FlightNum = 10;
/* 8. The following statement will change the destination
for Flight 3 */
UPDATE flights SET ToCityCode = 'ADL' WHERE FlightNum = 3;
/* 9. The following statement will add two new rows to the
collection of country codes */
INSERT INTO countries VALUES ('CA', 'Canada'), ('ES', 'Spain');
/* 10. The following command will delete the obsolete
Boeing 747-338 entry */
DELETE FROM aircraft WHERE AircraftDescription = 'Boeing 747-338';
/* 11. The following statement will add the Airbus A380
to our fleet of aircraft */
INSERT INTO aircraft VALUES ('A380', 'Airbus A380', 853);
/* 12. The following statements will update the number of seats
remaining for Flights 1 and 2 to allow for the ten people
travelling from Brisbane to Sydney via Canberra */
UPDATE flights SET SeatsRemaining = 0 WHERE FlightNum = 1;
UPDATE flights SET SeatsRemaining = 10 WHERE FlightNum = 2;
/* 13. The following statement will delete all flights to
Los Angeles */
DELETE FROM flights WHERE ToCityCode = 'LAX';
| true |
67bda770faf5f90c4c79b7e5bda1661419ed0b04 | SQL | CesarChaMal/Tesis_Matriz_de_pagos | /Programa Matriz de Pagos/Nuevo script calculo de pesos.sql | ISO-8859-1 | 3,102 | 3.8125 | 4 | [] | no_license | select * from pareto order by factor desc
select * from dbo.Matriz070906 order by Modelo, Descripcion
select * from dbo.view_MatrizBruta
where tipo=0 and punto like'%Comodidad%'
order by Modelo, Punto
select * from dbo.view_MatrizBruta
where tipo=0
order by Modelo, Punto
-- Verifica que todos los puntos tengan el mismo nmero de Items calificados
select Punto, Modelo, count(*)
from dbo.view_MatrizBruta
group by Punto, Modelo
Order by Punto
/*
La idea est siendo que todo lo dejemos en valores entre 0 y 1 de forma que el
clculo sea para todos del tipo 0...
*/
-- Crea tabla puente para normailzar todos los tipos de caractersticas a 0
Select IdMarca, IdAutomovil, IdPunto, Valor, Factor
into ##tmpMatriz
from dbo.view_MatrizBruta
Where Tipo=0
-- drop table ##tmpMatriz
-- Calcula la proporcion y el peso de los modelos incrementales (Tipo 1)
/*
Select Modelo, Punto, c.Descripcion,
Proporcion = valor / (Select max(valor) from dbo.view_MatrizBruta x where x.idCaracteristica=m.idCaracteristica),
Peso = Factor
from dbo.view_MatrizBruta m, catCaracteristicas c
Where m.Tipo=1 and m.idCaracteristica=c.idCaracteristica
Order by Modelo, c.Descripcion
*/
Insert into ##tmpMatriz
Select IdMarca, IdAutomovil, IdPunto,
valor / (Select max(valor) from dbo.view_MatrizBruta x where x.idCaracteristica=m.idCaracteristica),
factor
from dbo.view_MatrizBruta m, catCaracteristicas c
Where m.Tipo=1 and m.idCaracteristica=c.idCaracteristica
Order by Modelo, c.Descripcion
-- Calcula la proporcion y el peso de los modelos decrementales (Tipo 2)
/*
Select Modelo, Punto, c.Descripcion,
Proporcion = 1 - (valor / (Select max(valor) from dbo.view_MatrizBruta x where x.idCaracteristica=m.idCaracteristica)),
Peso = Factor
from dbo.view_MatrizBruta m, catCaracteristicas c
Where m.Tipo=2 and m.idCaracteristica=c.idCaracteristica
Order by Modelo, c.Descripcion
*/
Insert into ##tmpMatriz
Select IdMarca, IdAutomovil, IdPunto,
1 - (valor / (Select max(valor) from dbo.view_MatrizBruta x where x.idCaracteristica=m.idCaracteristica)),
Factor
from dbo.view_MatrizBruta m, catCaracteristicas c
Where m.Tipo=2 and m.idCaracteristica=c.idCaracteristica
Order by Modelo, c.Descripcion
-- Select * from #tmpMatriz
-- Calcula la proporcion de los modelos de acuerdo al punto de Pareto agrupando
-- por Puntos de Adquisicion (Familias de caractersticas)
Select IdMarca, IdAutomovil, IdPunto,
Proporcion=sum(valor)/convert(float,count(*)), Factor=max(Factor)
into ##tmpBase
from ##tmpMatriz
group by IdMarca, IdAutomovil, IdPunto
Order by IdMarca, IdAutomovil, IdPunto
-- Select * from ##tmpBase
-- drop table ##tmpBase
-- Calcula el peso por Punto de Adquisicin
Select a.Modelo, pa.Descripcion, t.Proporcion, t.Factor, Peso=t.Proporcion*t.Factor
into ##tmpMatrizPago
from ##tmpBase t, catAutomovil a, catPuntosAdquisicion pa
where t.idAutomovil=a.idAutomovil and t.idPunto=pa.IdPunto
-- Select * from ##tmpMatrizPago
-- drop table ##tmpMatrizPago
-- Clculo por Modelo
Select Modelo, sum(Peso)
from ##tmpMatrizPago
group by Modelo
--having Modelo like '%clio%'
order by sum(Peso) desc | true |
7908b16f0fce600626e2392f1087300646712555 | SQL | emilcerezo15/aob | /aob.sql | UTF-8 | 1,890 | 2.984375 | 3 | [
"MIT"
] | permissive | -- --------------------------------------------------------
-- Host: 127.0.0.1
-- Server version: 5.5.5-10.1.19-MariaDB - mariadb.org binary distribution
-- Server OS: Win32
-- HeidiSQL Version: 8.3.0.4694
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!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 aob
CREATE DATABASE IF NOT EXISTS `aob` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `aob`;
-- Dumping structure for table aob.users
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Dumping data for table aob.users: ~0 rows (approximately)
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` (`id`, `name`, `email`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
(1, '', 'joseph.fidelino@republisys.com', '$2y$10$C9Tj5hya2jhdSirhIJjvm.Y547tlAxDbOClmd.gP9EJzVOEJXZzqG', 'fSa3AF6mB3udnB28OTKVLWQP6ryfIfSd7anKUzvAr1SSnJEjwOTrHowPjMnQ', '2017-05-02 10:47:44', '2017-05-02 10:47:47');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
| true |
34bc76e9b7d080cde2ba5fd5c400b088ef3933b0 | SQL | tegarferdyla/Inventory | /inventory.sql | UTF-8 | 4,047 | 3.171875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Aug 12, 2018 at 07:50 PM
-- Server version: 10.1.29-MariaDB
-- PHP Version: 7.2.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `inventory`
--
-- --------------------------------------------------------
--
-- Table structure for table `detail_barang`
--
CREATE TABLE `detail_barang` (
`id_detail_barang` int(11) NOT NULL,
`id_barang` varchar(7) NOT NULL,
`warna` varchar(25) NOT NULL,
`ukuran` varchar(5) NOT NULL,
`stok` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `detail_barang`
--
INSERT INTO `detail_barang` (`id_detail_barang`, `id_barang`, `warna`, `ukuran`, `stok`) VALUES
(1, 'BR00001', 'Merah', 'S', 100),
(2, 'BR00001', 'Hitam', 'M', 120),
(3, 'BR00001', 'Hijau', 'L', 30),
(4, 'BR00002', 'Biru', 'L', 100),
(5, 'BR00001', 'Merah', 'L', 25);
-- --------------------------------------------------------
--
-- Table structure for table `tbl_barang`
--
CREATE TABLE `tbl_barang` (
`id_barang` varchar(7) NOT NULL,
`id_kategori` varchar(7) NOT NULL,
`foto_barang` varchar(100) NOT NULL,
`nama_barang` varchar(100) NOT NULL,
`harga` int(11) NOT NULL,
`deskripsi` text NOT NULL,
`tanggal` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_barang`
--
INSERT INTO `tbl_barang` (`id_barang`, `id_kategori`, `foto_barang`, `nama_barang`, `harga`, `deskripsi`, `tanggal`) VALUES
('BR00001', 'KTG0001', '1.jpg', 'Baju Anak Baru', 10000, 'Baju Anak lucu dengan motif keren', '0000-00-00 00:00:00'),
('BR00002', 'KTG0001', '3.jpg', 'Baju Dewasa', 12000, 'Baju Dewasa', '2018-08-12 13:55:24');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_kategori`
--
CREATE TABLE `tbl_kategori` (
`id_kategori` varchar(7) NOT NULL,
`kategori` varchar(50) NOT NULL,
`deskripsi` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_kategori`
--
INSERT INTO `tbl_kategori` (`id_kategori`, `kategori`, `deskripsi`) VALUES
('KTG0001', 'Baju Gamis', 'Baju Gamis Syari');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_user`
--
CREATE TABLE `tbl_user` (
`id_user` varchar(7) NOT NULL,
`nama_user` varchar(50) NOT NULL,
`bagian` varchar(15) NOT NULL,
`foto_user` varchar(100) NOT NULL,
`username` varchar(25) NOT NULL,
`password` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_user`
--
INSERT INTO `tbl_user` (`id_user`, `nama_user`, `bagian`, `foto_user`, `username`, `password`) VALUES
('USR0001', 'Tegar Ferdyla', 'stok', '1.jpg', 'tegarferdyla', 'df70d98996977a7b6f8dcf37c3265a38');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `detail_barang`
--
ALTER TABLE `detail_barang`
ADD PRIMARY KEY (`id_detail_barang`),
ADD KEY `id_barang` (`id_barang`);
--
-- Indexes for table `tbl_barang`
--
ALTER TABLE `tbl_barang`
ADD PRIMARY KEY (`id_barang`),
ADD KEY `id_kategori` (`id_kategori`);
--
-- Indexes for table `tbl_kategori`
--
ALTER TABLE `tbl_kategori`
ADD PRIMARY KEY (`id_kategori`);
--
-- Indexes for table `tbl_user`
--
ALTER TABLE `tbl_user`
ADD PRIMARY KEY (`id_user`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `detail_barang`
--
ALTER TABLE `detail_barang`
MODIFY `id_detail_barang` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
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 |
55f89738d44527f632bf13606f6b19a189ec219f | SQL | CGMcBride/EmployeeTracker | /db/seeds.sql | UTF-8 | 642 | 3.09375 | 3 | [] | no_license | INSERT INTO departments (department)
VALUES
("Finance"),
("Programs"),
("Contracts");
INSERT INTO roles (title, salary, departmentId)
VALUES
("Sup 1", 4000, 1),
("EODDS", 5000, 2),
("DATA Broker", 3500, 2),
("Specialist", 5500, 3);
INSERT INTO employees (first_name, last_name, rolesId)
VALUES
("Pat", "Baker", 1),
("Amy", "Mitchell", 2),
("Bill", "Johnson", 3),
("Dev", "Patel", 4);
-- SELECT
-- roles.title, roles.salary,
-- departments.department
-- FROM roles left join departments on
-- roles.departmentId = departments.departmentId
-- ORDER BY roles.rolesId; | true |
b9cac7f96636f4e941ec95948b4a94a0824cfae1 | SQL | e-webking/nws_tripmanage | /ext_tables.sql | UTF-8 | 14,705 | 2.984375 | 3 | [] | no_license | #
# Table structure for table 'tx_nwstripmanage_domain_model_trip'
#
CREATE TABLE tx_nwstripmanage_domain_model_trip (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
title varchar(255) DEFAULT '' NOT NULL,
image int(11) unsigned NOT NULL default '0',
description text NOT NULL,
itinerary text NOT NULL,
hotelimages int(11) unsigned NOT NULL default '0',
travelperiodstart int(11) DEFAULT '0' NOT NULL,
travelperiodend int(11) DEFAULT '0' NOT NULL,
priceperperson double(11,2) DEFAULT '0.00' NOT NULL,
timeprice int(11) unsigned DEFAULT '0' NOT NULL,
abflugort int(11) unsigned DEFAULT '0' NOT NULL,
tourguide int(11) unsigned DEFAULT '0' NOT NULL,
currenttrip tinyint(4) unsigned DEFAULT '0' NOT NULL,
triptype varchar(255) DEFAULT '' NOT NULL,
ziel int(11) unsigned DEFAULT '0' NOT NULL,
gesonderte_reisen varchar(255) DEFAULT '' NOT NULL,
hotelpricedetails text NOT NULL,
studentdiscount varchar(255) DEFAULT '' NOT NULL,
travel_period int(11) unsigned DEFAULT '0' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) DEFAULT '0' NOT NULL,
t3ver_id int(11) DEFAULT '0' NOT NULL,
t3ver_wsid int(11) DEFAULT '0' NOT NULL,
t3ver_label varchar(255) DEFAULT '' NOT NULL,
t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
t3ver_stage int(11) DEFAULT '0' NOT NULL,
t3ver_count int(11) DEFAULT '0' NOT NULL,
t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
t3ver_move_id int(11) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob,
PRIMARY KEY (uid),
KEY parent (pid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY language (l10n_parent,sys_language_uid)
);
#
# Table structure for table 'tx_nwstripmanage_domain_model_price'
#
CREATE TABLE tx_nwstripmanage_domain_model_abflugort (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
trip int(11) unsigned DEFAULT '0' NOT NULL,
title varchar(255) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) DEFAULT '0' NOT NULL,
t3ver_id int(11) DEFAULT '0' NOT NULL,
t3ver_wsid int(11) DEFAULT '0' NOT NULL,
t3ver_label varchar(255) DEFAULT '' NOT NULL,
t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
t3ver_stage int(11) DEFAULT '0' NOT NULL,
t3ver_count int(11) DEFAULT '0' NOT NULL,
t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
t3ver_move_id int(11) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob,
PRIMARY KEY (uid),
KEY parent (pid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY language (l10n_parent,sys_language_uid)
);
#
# Table structure for table 'tx_nwstripmanage_domain_model_price'
#
CREATE TABLE tx_nwstripmanage_domain_model_price (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
trip int(11) unsigned DEFAULT '0' NOT NULL,
numberofbeds varchar(255) DEFAULT '' NOT NULL,
age varchar(255) DEFAULT '' NOT NULL,
price double(11,2) DEFAULT '0.00' NOT NULL,
studentprice tinyint(4) unsigned DEFAULT '0' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) DEFAULT '0' NOT NULL,
t3ver_id int(11) DEFAULT '0' NOT NULL,
t3ver_wsid int(11) DEFAULT '0' NOT NULL,
t3ver_label varchar(255) DEFAULT '' NOT NULL,
t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
t3ver_stage int(11) DEFAULT '0' NOT NULL,
t3ver_count int(11) DEFAULT '0' NOT NULL,
t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
t3ver_move_id int(11) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob,
PRIMARY KEY (uid),
KEY parent (pid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY language (l10n_parent,sys_language_uid)
);
#
# Table structure for table 'tx_nwstripmanage_domain_model_tourguide'
#
CREATE TABLE tx_nwstripmanage_domain_model_tourguide (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
trip int(11) unsigned DEFAULT '0' NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
email varchar(255) DEFAULT '' NOT NULL,
telephone varchar(255) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) DEFAULT '0' NOT NULL,
t3ver_id int(11) DEFAULT '0' NOT NULL,
t3ver_wsid int(11) DEFAULT '0' NOT NULL,
t3ver_label varchar(255) DEFAULT '' NOT NULL,
t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
t3ver_stage int(11) DEFAULT '0' NOT NULL,
t3ver_count int(11) DEFAULT '0' NOT NULL,
t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
t3ver_move_id int(11) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob,
PRIMARY KEY (uid),
KEY parent (pid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY language (l10n_parent,sys_language_uid)
);
#
# Table structure for table 'tx_nwstripmanage_domain_model_price'
#
CREATE TABLE tx_nwstripmanage_domain_model_price (
trip int(11) unsigned DEFAULT '0' NOT NULL,
);
#
# Table structure for table 'tx_nwstripmanage_domain_model_tourguide'
#
CREATE TABLE tx_nwstripmanage_domain_model_tourguide (
trip int(11) unsigned DEFAULT '0' NOT NULL,
);
#
# Table structure for table 'tx_nwstripmanage_domain_model_booking'
#
CREATE TABLE tx_nwstripmanage_domain_model_booking (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
trip int(11) unsigned DEFAULT '0' NOT NULL,
contactperson int(11) unsigned DEFAULT '0' NOT NULL,
telephone varchar(255) DEFAULT '' NOT NULL,
email varchar(255) DEFAULT '' NOT NULL,
street varchar(255) DEFAULT '' NOT NULL,
housenumber varchar(255) DEFAULT '' NOT NULL,
plz varchar(255) DEFAULT '' NOT NULL,
city varchar(255) DEFAULT '' NOT NULL,
country varchar(255) DEFAULT '' NOT NULL,
travelguidance varchar(255) DEFAULT '' NOT NULL,
travelguidanceother varchar(255) DEFAULT '' NOT NULL,
seminarparticipation varchar(255) DEFAULT '' NOT NULL,
additionalinformation varchar(255) DEFAULT '' NOT NULL,
contactpersondetail int(11) unsigned DEFAULT '0' NOT NULL,
timeandprice int(11) unsigned DEFAULT '0' NOT NULL,
totalprice varchar(255) DEFAULT '' NOT NULL,
abflugort varchar(255) DEFAULT '' NOT NULL,
referenz varchar(255) DEFAULT '' NOT NULL,
travel_period int(11) unsigned DEFAULT '0' NOT NULL,
paymentmethod varchar(255) DEFAULT '' NOT NULL,
paymentstatus varchar(255) DEFAULT '' NOT NULL,
paymentdate varchar(255) DEFAULT '' NOT NULL,
verifysign varchar(255) DEFAULT '' NOT NULL,
txnid varchar(255) DEFAULT '' NOT NULL,
payeremail varchar(255) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) DEFAULT '0' NOT NULL,
t3ver_id int(11) DEFAULT '0' NOT NULL,
t3ver_wsid int(11) DEFAULT '0' NOT NULL,
t3ver_label varchar(255) DEFAULT '' NOT NULL,
t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
t3ver_stage int(11) DEFAULT '0' NOT NULL,
t3ver_count int(11) DEFAULT '0' NOT NULL,
t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
t3ver_move_id int(11) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob,
PRIMARY KEY (uid),
KEY parent (pid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY language (l10n_parent,sys_language_uid)
);
#
# Table structure for table 'tx_nwstripmanage_domain_model_ziel'
#
CREATE TABLE tx_nwstripmanage_domain_model_ziel (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
trip int(11) unsigned DEFAULT '0' NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) DEFAULT '0' NOT NULL,
t3ver_id int(11) DEFAULT '0' NOT NULL,
t3ver_wsid int(11) DEFAULT '0' NOT NULL,
t3ver_label varchar(255) DEFAULT '' NOT NULL,
t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
t3ver_stage int(11) DEFAULT '0' NOT NULL,
t3ver_count int(11) DEFAULT '0' NOT NULL,
t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
t3ver_move_id int(11) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob,
PRIMARY KEY (uid),
KEY parent (pid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY language (l10n_parent,sys_language_uid)
);
#
# Table structure for table 'tx_nwstripmanage_domain_model_contactperson'
#
CREATE TABLE tx_nwstripmanage_domain_model_contactperson (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
booking int(11) unsigned DEFAULT '0' NOT NULL,
gender varchar(255) DEFAULT '' NOT NULL,
birthdate varchar(255) DEFAULT '' NOT NULL,
firstname varchar(255) DEFAULT '' NOT NULL,
lastname varchar(255) DEFAULT '' NOT NULL,
passportnumber varchar(255) DEFAULT '' NOT NULL,
nationality varchar(255) DEFAULT '' NOT NULL,
age varchar(255) DEFAULT '' NOT NULL,
roomprice varchar(255) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) DEFAULT '0' NOT NULL,
t3ver_id int(11) DEFAULT '0' NOT NULL,
t3ver_wsid int(11) DEFAULT '0' NOT NULL,
t3ver_label varchar(255) DEFAULT '' NOT NULL,
t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
t3ver_stage int(11) DEFAULT '0' NOT NULL,
t3ver_count int(11) DEFAULT '0' NOT NULL,
t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
t3ver_move_id int(11) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob,
PRIMARY KEY (uid),
KEY parent (pid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY language (l10n_parent,sys_language_uid)
);
#
# Table structure for table 'tx_nwstripmanage_domain_model_daterequest'
#
CREATE TABLE tx_nwstripmanage_domain_model_daterequest (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
trip int(11) unsigned DEFAULT '0' NOT NULL,
startdate varchar(255) DEFAULT '' NOT NULL,
enddate varchar(255) DEFAULT '' NOT NULL,
gender varchar(255) DEFAULT '' NOT NULL,
firstname varchar(255) DEFAULT '' NOT NULL,
lastname varchar(255) DEFAULT '' NOT NULL,
email varchar(255) DEFAULT '' NOT NULL,
street varchar(255) DEFAULT '' NOT NULL,
zip varchar(255) DEFAULT '' NOT NULL,
city varchar(255) DEFAULT '' NOT NULL,
telephone varchar(255) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) DEFAULT '0' NOT NULL,
t3ver_id int(11) DEFAULT '0' NOT NULL,
t3ver_wsid int(11) DEFAULT '0' NOT NULL,
t3ver_label varchar(255) DEFAULT '' NOT NULL,
t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
t3ver_stage int(11) DEFAULT '0' NOT NULL,
t3ver_count int(11) DEFAULT '0' NOT NULL,
t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
t3ver_move_id int(11) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob,
PRIMARY KEY (uid),
KEY parent (pid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY language (l10n_parent,sys_language_uid)
);
#
# Table structure for table 'tx_nwstripmanage_domain_model_travelperiod'
#
CREATE TABLE tx_nwstripmanage_domain_model_travelperiod (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
trip int(11) unsigned DEFAULT '0' NOT NULL,
startdate int(11) DEFAULT '0' NOT NULL,
enddate int(11) DEFAULT '0' NOT NULL,
price double(11,2) DEFAULT '0.00' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime int(11) unsigned DEFAULT '0' NOT NULL,
t3ver_oid int(11) DEFAULT '0' NOT NULL,
t3ver_id int(11) DEFAULT '0' NOT NULL,
t3ver_wsid int(11) DEFAULT '0' NOT NULL,
t3ver_label varchar(255) DEFAULT '' NOT NULL,
t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
t3ver_stage int(11) DEFAULT '0' NOT NULL,
t3ver_count int(11) DEFAULT '0' NOT NULL,
t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
t3ver_move_id int(11) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob,
PRIMARY KEY (uid),
KEY parent (pid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY language (l10n_parent,sys_language_uid)
); | true |
599ee3e4f0e4dbf71f0c1b0bd9f63f860267bca5 | SQL | AbrahamFergie/abraHarmanHammer | /SOLUTIONS.sql | UTF-8 | 5,861 | 4.09375 | 4 | [
"MIT"
] | permissive | LEETCODE.COM:
Duplicate Emails(table called Person):
SELECT Person.Email
FROM Person
GROUP By Person.Email
Having Count(*) > 1;
Employees Earning More Than Their Managers:
SELECT Name AS Employee
From Employee emp
Where emp.ManagerId IS NOT NULL
AND emp.Salary > (SELECT Salary From Employee Where emp.ManagerId = Id);
SQLTEACHING.COM:
Multiple joins sql teacher
SELECT character.name, tv_show.name
FROM character
INNER JOIN character_tv_show
ON character.id = character_tv_show.character_id
INNER JOIN tv_show
ON character_tv_show.tv_show_id = tv_show.id WHERE character.name != 'Willow Rosenberg' AND tv_show.name != 'How I Met Your Mother';
Table Aliases
SELECT c.name, a.name
FROM character AS c
LEFT JOIN character_actor AS ca
ON c.id = ca.character_id
LEFT JOIN actor AS a
ON ca.actor_id = a.id;
Column Aliases
SELECT character.name AS character, actor.name AS actor
FROM character
LEFT JOIN character_actor
ON character.id = character_actor.character_id
LEFT JOIN actor
ON character_actor.actor_id = actor.id;
SELF JOINS
SELECT r1.name AS employee_name, r2.name AS boss_name
FROM employees as r1
INNER JOIN employees AS r2
ON r1.boss_id = r2.id;
SUBSTR
SELECT *
FROM robots
WHERE SUBSTR(location, -2)
LIKE 'NY';
COALESCE
SELECT name,
COALESCE(tank, gun, sword)
as weapon FROM fighters;
SQLZOO.NET:
SELECT from WORLD:
Number 12:
Show the name and the continent - but substitute Eurasia for Europe and Asia; substitute America - for each country in North America or South America or Caribbean. Show countries beginning with A or B
SELECT name,
CASE
WHEN continent='Europe' OR continent='Asia' THEN 'Eurasia'
WHEN continent = 'North America' OR continent = 'South America' OR continent = 'Caribbean' THEN 'America'
ELSE continent END
FROM world
WHERE name LIKE 'A%' OR name LIKE 'B%';
Question 13:
SELECT name, continent,
CASE
WHEN continent = 'Oceania' THEN 'Australasia'
WHEN continent = 'Eurasia' OR name = 'Turkey' THEN 'Europe/Asia'
WHEN continent = 'America' THEN continent = 'North America'
WHEN continent = 'Caribbean' AND name LIKE 'B%' THEN 'North America'
WHEN continent = 'Caribbean' THEN 'South America'
ELSE continent END
FROM world
WHERE tld IN ('.ag','.ba','.bb','.ca','.cn','.nz','.ru','.tr','.uk') ORDER BY name;
SELECT from nobel:
Question 1:
Change the query shown so that it displays Nobel prizes for 1950.
SELECT yr, subject, winner
FROM nobel
WHERE yr = 1950
Question 2:
Show who won the 1962 prize for Literature.
SELECT winner
FROM nobel
WHERE yr = 1962
AND subject = 'Literature'
Question 3:
Show the year and subject that won 'Albert Einstein' his prize.
SELECT yr, subject
FROM nobel
WHERE winner = 'Albert Einstein';
Question 4:
Give the name of the 'Peace' winners since the year 2000, including 2000.
SELECT winner
FROM nobel
WHERE subject = 'Peace' AND yr >= 2000;
Question 5:
Show all details (yr, subject, winner) of the Literature prize winners for 1980 to 1989 inclusive.
SELECT yr, subject, winner
FROM nobel
WHERE subject = 'Literature' AND yr>=1980 AND yr<=1989;
Question 6:
Show all details of the presidential winners:
Theodore Roosevelt
Woodrow Wilson
Jimmy Carter
SELECT *
FROM nobel
WHERE winner = 'Theodore Roosevelt' OR winner = 'Woodrow Wilson' OR winner ='Jimmy Carter'
AND subject = 'peace'
Question 7:
Show the winners with first name John
SELECT winner
FROM nobel
WHERE winner LIKE 'John%'
Question 8:
Show the Physics winners for 1980 together with the Chemistry winners for 1984.
SELECT *
FROM nobel
WHERE yr =1980 AND subject = 'Physics 'OR yr = 1984 AND subject = 'Chemistry'
Question 9:
Show the winners for 1980 excluding the Chemistry and Medicine
SELECT *
FROM nobel
WHERE yr = 1980 AND NOT subject = 'Chemistry' AND NOT subject = 'Medicine'
Question 10:
Show who won a 'Medicine' prize in an early year (before 1910, not including 1910) together with winners of a 'Literature' prize in a later year (after 2004, including 2004)
SELECT *
FROM nobel
WHERE subject = 'Medicine' AND yr < 1910 OR subject = 'Literature' AND yr >= 2004;
Question 11:
Find all details of the prize won by PETER GRÜNBERG
SELECT *
FROM nobel
WHERE winner = 'Peter'
Question 12:
Find all details of the prize won by EUGENE O'NEILL'
SELECT *
FROM nobel
WHERE winner = 'Eugene O''neill'
Question 13:
Knights in order
List the winners, year and subject where the winner starts with Sir. Show the the most recent first, then by name order.
SELECT winner, yr, subject
FROM nobel
WHERE winner LIKE 'Sir%'
ORDER BY yr DESC
;
Question 14 on Select from nobel:
SELECT winner, subject
FROM nobel
WHERE yr=1984
ORDER BY subject IN ('Physics', 'Chemistry'), subject, winner;
JOIN:
Question 1:
The first example shows the goal scored by a player with the last name 'Bender'. The * says to list all the columns in the table - a shorter way of saying matchid, teamid, player, gtime
Modify it to show the matchid and player name for all goals scored by Germany. To identify German players, check for: teamid = 'GER'
SELECT matchid, player FROM goal
WHERE teamid = 'GER'
Question 2:
From the previous query you can see that Lars Benders scored a goal in game 1012. Now we want to know what teams were playing in that match.
Notice in the that the column matchid in the goal table corresponds to the id column in the game table. We can look up information about game 1012 by finding that row in the game table.
Show id, stadium, team1, team2 for just game 1012
SELECT id,stadium,team1,team2
FROM game
WHERE id = 1012
Question 3:
| true |
3a58fb8df970b495ffe62f9065c4f96800169383 | SQL | tangyu1992/springboot-bootstrap | /src/main/resources/schema/tangyu.sql | UTF-8 | 913 | 2.78125 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : VOS
Source Server Version : 50096
Source Host : localhost:3306
Source Database : tangyu
Target Server Type : MYSQL
Target Server Version : 50096
File Encoding : 65001
Date: 2016-11-08 13:03:39
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` bigint(20) NOT NULL auto_increment,
`name` varchar(50) NOT NULL,
`age` int(11) default NULL,
`mobile` varchar(32) default NULL,
`email` varchar(100) NOT NULL,
`password` varchar(255) NOT NULL,
`birthday` date default NULL,
`local` varchar(255) default NULL,
`remark` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user
-- ----------------------------
| true |
769ec504d360de0cd81519b06bf0426dbdd61ff1 | SQL | murphyc12/php-final-project | /sql/joinReview.sql | UTF-8 | 144 | 3.015625 | 3 | [] | no_license | SELECT players.playerid, players.name, playerreviews.review
FROM players Inner JOIN playerreviews
ON players.playerid = playerreviews.playerid
| true |
9787588f3edd1f5dc7de2320cea551bede55c898 | SQL | buikevin96/Bamazon | /products.sql | UTF-8 | 805 | 3.359375 | 3 | [] | no_license | CREATE DATABASE bamazon
USE bamazon
CREATE TABLE products (
item_id INT NOT NULL AUTO_INCREMENT,
product_name VARCHAR(40) NULL,
department_name VARCHAR(40) NULL,
price DECIMAL(10,2) NULL,
stock_quantity INT NULL,
primary key (item_id)
);
INSERT INTO products (product_name, department_name, price, stock_quantity)
VALUES ("Gold iPhone 6", "Phones", 350, 40),
("Grand Theft Auto San Andreas PC", "Games", 40, 40),
("American Eskie", "Pets", 500, 2),
("Rolex", "Watches", 15000, 4),
("Blue Nike SBs", "Shoes", 45, 10),
("Samsung Galaxy S6", "Phone", 300, 30),
("Call Of Duty: World At War", "Games", 45, 35),
("Brown Poodle", "Pets", 450, 2),
("Movado", "Watches", 1000, 8),
("Nike Air Forces", "Shoes", 100, 15);
SELECT * FROM products | true |
4aee3d21e9151565b35fa09a4e478b408d4f931d | SQL | sergioivan154/androidVernam | /usb/DreamHome/Directores.sql | UTF-8 | 345 | 2.515625 | 3 | [] | no_license | drop table if exists directores;
create table directores(
num_empl int primary key,
fecha_nombramiento datetime not null,
num_sucursal varchar(6)not null UNIQUE
);
insert into directores values (00005, '2013-01-12','B003');
insert into directores values (00006, '2013-01-12','B004');
insert into directores values (00008, '2013-01-12','B005'); | true |
331e7cdfecb7b4a02cc7ba4ae2b08c445907ef1a | SQL | YannickOsen/WebEngineeringProject | /QASystem/src/main/resources/data.sql | UTF-8 | 498 | 2.53125 | 3 | [] | no_license | INSERT INTO Users(
VALUES (10000,'password','jonathan')
);
INSERT INTO Users(
VALUES(9999,'password','joseph')
);
INSERT INTO Users(
VALUES(10001,'password','yareyare')
);
/*INSERT INTO Questions(
VALUES(5000, 2004-02-09 13:12:11.000, false, false, 'Questiontext that iss highly interesting', 'exampleTitle', 10001)
);
INSERT INTO Questions(
VALUES(1935, 1989-02-09 13:12:11.000, false, false, 'VERY URGENT. THE AIR IS GETTING THIN', 'How do you breath inside a coffin?', 10001)
);*/ | true |
78293afe7fc6eeb6c2bf95e7a07d9536aac56563 | SQL | ccappetta/scratch | /taskr_proc_upsert_taskr_activity_stream_view.sql | UTF-8 | 1,602 | 3.90625 | 4 | [] | no_license | DROP procedure if exists proc_upsert_taskr_activity_stream_view;
create procedure proc_upsert_taskr_activity_stream_view(IN dbname varchar(128))
BEGIN
SET @theSQL=CONCAT('
CREATE OR REPLACE VIEW ', dbname,'.taskr_activity_stream AS
SELECT ''task'' COLLATE utf8mb4_unicode_ci AS action_type,
a.last_action_by AS actor,
a.last_modified_timestamp AS action_time,
a.task_uuid AS task_identifier,
CONCAT(a.last_action_by,
(
CASE
WHEN (((SELECT TIMESTAMPDIFF(SECOND,a.created_timestamp,a.last_modified_timestamp) result) <= ''120'') AND (a.is_complete = true) )
THEN '' CREATED and then pretty-much immediately COMPLETED ''
WHEN (a.is_complete = true)
THEN '' COMPLETED ''
WHEN ((SELECT TIMESTAMPDIFF(SECOND,a.created_timestamp,a.last_modified_timestamp) result) <= ''5'')
THEN '' CREATED ''
ELSE '' UPDATED ''
END
)
,''the task: '', UPPER(a.task_subject)) AS action_description
FROM ', dbname,'.task a
UNION ALL
SELECT ''comment'' COLLATE utf8mb4_unicode_ci AS action_type,
b.commenter AS actor,
b.comment_time AS action_time,
b.task_id AS task_identifier,
CONCAT(b.commenter, '' COMMENTED on the task: '',UPPER((SELECT a.task_subject WHERE a.task_uuid = b.task_id)),'' with the message: "'', b.comment_body,''"'') as action_description
FROM ', dbname,'.task_comments b, ', dbname,'.task a
GROUP BY action_description
ORDER BY action_time DESC;
');
PREPARE stmt1 from @theSQL;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
END;
| true |
c914324b84cc8707028b4bd03607bc58887e475b | SQL | samitamaharjan/Hadoop-Cloudera-Certification | /HadoopExam/HIVE_summary.sql | UTF-8 | 6,728 | 3.78125 | 4 | [] | no_license | HIVE:
to create table:
create table table1
(name string, salary int, sex string, age int)
row format delimited
fields terminated by ',';
to load data from hdfs file:
load data inpath '/HadoopExam/logs/ads.log' into table temp_ad_part;
to load data from local file:
LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;
to change table type external to managed or vice versa:
alter table purchase set tblproperties ('EXTERNAL'='TRUE'); ==> all in capital letters
alter table table1 set tblproperties ('skipAutoProvisioning'='FALSE');
#commandline:
hive -e "alter table table1 set tblproperties ('skipAutoProvisioning'='FALSE');"
to create hive table from avro data file in hdfs:
create external table departments_avro stored as avro location '/spark/departments_avro/departments' tblproperties ('avro.schema.url'='/spark/departments_avro/departments.avsc');
to compress the output file OR to change the file format to compressed one:
hive>set hive.exec.compress.output=true;
hive>set mapred.compress.map.output=true;
hive>set mapred.output.compression.codec=org.apache.hadoop.io.compress.BZip2Codec;
to remove header: tblproperties("skip.header.line.count"="1");
to create structure format table:
create table table_struct
(
Name struct<fname:string, lname:string>,
Address struct<housenumber:string, city:string, state:string, zip:string>,
Phone struct<home:string, mobile:string>
)
comment "Created by: Samita Maharjan"
row format delimited fields terminated by '|'
collection items terminated by ','
stored as sequencefile
;
Amit|Jain|A-646, Cheru Nagar, Chennai|999999999|98989898|600020
Sumit|Saxena|D-100, Connaught Place, Delhi|1111111111|82828282|110001
create table table1(data1 string);
insert into table_struct select named_struct("fname", split(data1, '\\|')[0], "lname", split(data1, '\\|')[1]),
named_struct("city", split(split(data1, '\\|')[2], ',')[1], "state", split(split(data1, '\\|')[2], ',')[2])
named_struct("mobile", split(data1,'\\|')[4])
from table1;
Jun 3 07:10:54 hadoopexam.com_node01 init: tty (/dev/tty6) main process (1208) killed by TERM signal
Jun 3 07:11:31 hadoopexam.com_node01 kernel: registered taskstats version 1
to load above log into the table:
create table table1(
month_name string, day string, time string, node string, process string, log_msg string
)
partitioned by (year int, month int)
row format serde 'org.apache.hadoop.hive.serde2.RegexSerde'
with serdeproperties (
"input.regex"="^(\\w+)[ ]+(\\d+)[ ]+(\\d+:\\d+:\\d+)[ ]+([^ ]*)[ ]+(.*)$"
)
stored as textfile;
Alter table table1 add partition(year = 2016, month = 06) location '/HadoopExam/logs' ;
to change date format of BirthDate:
Id,FirstName,LastName,Age,BirthDate
1,Ajit,Jogi,45,19-Aug-1970
2,Anubhav,shyam,56,30-Sep-1965
3,Raghu,Prasad,43,30/Jul/1963
insert into table1 as select id, FirstName, LastName, Age,
(case
When BirthDate REGEXP ='(\\d{1,2})-(\\w{3})-(\\d{4})' then from_unixtime(UNIX_TIMESTAMP(BirthDate,'dd-MMM-yyyy'),'MM-dd-yyyy')
When BirthDate REGEXP ='(\\d{1,2})/(\\w{3})/{\\d{4}}' then from_unixtime(UNIX_TIMESTAMP(BirthDate,'dd/MMM/yyyy'),'MM-dd-yyyy')
else BirthDate
End) as BirthDate
from patientdetails;
to filter the BirthDate who are born in jun:
select * from table1 where from_unixtime(UNIX_TIMESTAMP(BirthDate,'MM-dd-yyyy'), 'MMM') = "jun";
to rank the price:
select *, rank() over (order by price) rank from products;
1004 PEC Pencil 2B 10000 0.48 1
1005 PEC Pencil 2H 8000 0.49 2
1001 PEN Pen Red 5000 1.23 3
1003 PEN Pen Black 2000 1.25 4
1002 PEN Pen Blue 8000 1.25 4
1006 PEC Pencil HB 0 9999.99 6 <== rank() function skips 5
select *, dense_rank() over (order by price) rank from products;
1004 PEC Pencil 2B 10000 0.48 1
1005 PEC Pencil 2H 8000 0.49 2
1001 PEN Pen Red 5000 1.23 3
1003 PEN Pen Black 2000 1.25 4
1002 PEN Pen Blue 8000 1.25 4
1006 PEC Pencil HB 0 9999.99 5 <== dense_rank() function includes 5
select name, product, price, dense_rank() over (partition by name, product order by price desc) from table_name1;
1001 PEN Pen Red 5000 1.23 1
1002 PEN Pen Blue 8000 1.25 1
1003 PEN Pen Black 2000 1.25 1
1004 PEC Pencil 2B 10000 1.5 1 <= if prder by price asc, 0.48 will be in rank 1
1004 PEC Pencil 2B 10000 0.48 2 <=
1004 PEC Pencil 2B 10000 0.48 2 <=
1005 PEC Pencil 2H 8000 0.49 1
1006 PEC Pencil HB 0 9999.99 1
#to display 3rd highest department_id:
mysql/hive>select * from (select department_id, department_name from depart order by department_id desc limit 3) as table1 order by department_id limit 1 ;
to remove duplicate using rank function:
create table table_name2 as
(select name, product, price from (
select name, product, price, rank() over (partition by name, product order by price desc) rank
from table_name1) rank_table) where rank_table.rank=1 ;
create table table_name2 as
(select name, product, price from (
select name, product, price, rank() over (partition name, product order by price desc) rank from table_name1) rank_table) where rank.rank_table=1;
)
samita samita eats apple apple apple
What are difference on the three channels?
Memory channels store events an in-memory queue. It is very useful for high-throughput data flow but day have no durability which means if agent goes down, data will be lost.
File channels persist events to disk and have a strong durability.
JDBC channels store events in database and have the strongest durability. But JDBC channels are the slowest compared to other 2 types of channels.
# Q: student name, grade
You are required to use Spark RDD to calculate the average grades for each student
A, 100
A, 99
B, 80
var managerPairRDD = manager.map(x => (x.split(",")(0), x.split(",")(1).toInt))
val xpair = xmap.aggregateByKey((0, 0))((x, y) =>(x._1 + y, x._2 + 1), (x1, y1) => (x1._1 + y1._1, x1._2 + y1._2))
val avg = xpair.mapValues(x => (x._1 / x._2))
avg.collect();
//method 1
val rdd = textFile.flatMap(line=> { val p = line.split(","); (p(0), p(1))})
val agg_rdd = rdd.aggregateByKey((0,0))((acc, value) => (acc._1 + value, acc._2 + 1),(acc1, acc2) => (acc1._1 + acc2._1, acc1._2 + acc2._2))
val avg = agg_rdd.mapValues(x => (x._1/x._2))
avg.collect();
//method 2
val rdd = textFile.flatMap(line=> { val p = line.split(","); (p(0), p(1))})
val com_rdd = rdd.combineByKey((x) => (x,1),
(pair1, x) => (pair1._1 + x, pair1._2 + 1),
(pair1, pair2) => (pair1._1 + pair2._1, pair1._2 + pair2._2))
val avg = com_rdd.mapValues(x => (x._1/x._2))
avg.collect()
Q: list all the major components of HBase
zookeeper, HMaster, HRegionServer, HRegion, Catalog Tables. | true |
dc0b5e995018db99fa742a9452451030e8d21671 | SQL | sebagott/project1 | /create.sql | UTF-8 | 742 | 3.625 | 4 | [] | no_license | CREATE TABLE avatars (
id SERIAL PRIMARY KEY,
filename TEXT NOT NULL
);
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
password TEXT NOT NULL,
avatar_id INTEGER NOT NULL REFERENCES avatars
);
CREATE TABLE authors (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL UNIQUE
);
CREATE TABLE books (
id SERIAL PRIMARY KEY,
isbn TEXT NOT NULL UNIQUE,
title TEXT NOT NULL,
author_id INTEGER NOT NULL REFERENCES authors,
year INTEGER,
current_rating REAL
);
CREATE TABLE reviews (
id SERIAL PRIMARY KEY,
book_id INTEGER NOT NULL REFERENCES books,
user_id INTEGER NOT NULL REFERENCES users,
comment TEXT,
rating INTEGER NOT NULL CHECK (rating > 0 AND rating <=5)
);
CREATE EXTENSION pgcrypto;
| true |
638f1e2794f708c2b812e7ae0c83d44d5b9f4f56 | SQL | oradrs/Oracle | /Scripts/Other/topsql_v3.sql | UTF-8 | 712 | 3.46875 | 3 | [] | no_license | -- Source : http://www.nocoug.org/download/2008-08/a-tour-of-the-awr-tables.nocoug-Aug-21-2008.abercrombie.html#script-find-expensive
select
sub.sql_id,
sub.seconds_since_date,
sub.execs_since_date,
sub.gets_since_date
from
( -- sub to sort before rownum
select
sql_id,
round(sum(elapsed_time_delta)/1000000) as seconds_since_date,
sum(executions_delta) as execs_since_date,
sum(buffer_gets_delta) as gets_since_date
from
dba_hist_snapshot natural join dba_hist_sqlstat
where
begin_interval_time > to_date('&&start_YYYYMMDD','YYYY-MM-DD')
group by
sql_id
order by
2 desc
) sub
where
rownum < 100
;
| true |
e7616d5612a099bf9bb5baa060cf2bcfd9d956a2 | SQL | htmlacademy-php/1418301-doingsdone-12 | /shema.sql | UTF-8 | 1,206 | 3.71875 | 4 | [] | no_license | /* Создание БД */
CREATE DATABASE `doingsdone`
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;
USE `doingsdone`;
/* Создание таблиц */
CREATE TABLE `users` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`email` VARCHAR(128) NOT NULL UNIQUE,
`password` CHAR(64) NOT NULL,
`name` VARCHAR(50) NOT NULL
);
CREATE TABLE `projects` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` VARCHAR(150) NOT NULL,
`id_user` INT NOT NULL
);
CREATE TABLE `tasks` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` VARCHAR(150) NOT NULL,
`id_project` INT NOT NULL,
`id_user` INT NOT NULL,
`date_create` DATETIME NOT NULL,
`status` TINYINT(1) NOT NULL DEFAULT 0,
`file` VARCHAR(500) NULL,
`date_execute` DATETIME NULL
);
/* Создание индексов */
CREATE INDEX `user_email` ON `users`(`email`);
CREATE INDEX `project_user` ON `projects`(`id_user`);
CREATE INDEX `task_user` ON `tasks`(`id_user`);
CREATE INDEX `task_project` ON `tasks`(`id_project`);
/* Создание полнотекстового индекса */
CREATE FULLTEXT INDEX `task_ft_search` ON `tasks`(`title`); | true |
4fd8104b5d6cb7926560654171a0e38dfb6335be | SQL | GautamGadipudi/imdb-insertion-tool | /db_init.sql | UTF-8 | 3,249 | 3.84375 | 4 | [] | no_license | --CREATE USER imdb_super_admin IF NOT EXISTS
DO $create_super_user$
BEGIN
IF NOT EXISTS (
SELECT
FROM pg_catalog.pg_user
WHERE usename = 'imdb_super_admin'
)
THEN
CREATE USER imdb_super_admin WITH
ENCRYPTED PASSWORD 'imdb_super_admin'
SUPERUSER
CREATEDB
CREATEROLE
REPLICATION
BYPASSRLS;
END IF;
END
$create_super_user$;
--CREATE USER imdb_production IF NOT EXISTS
DO $create_query_user$
BEGIN
IF NOT EXISTS (
SELECT
FROM pg_catalog.pg_user
WHERE usename = 'imdb_production'
)
THEN
CREATE USER imdb_production WITH
ENCRYPTED PASSWORD 'imdb_production';
END IF;
END
$create_query_user$;
SET ROLE imdb_super_admin;
--CREATE DATABASE CSCI_620 IF NOT EXISTS loop around
SELECT 'CREATE DATABASE csci_620 WITH OWNER = imdb_super_admin ENCODING = ''UTF8'''
WHERE NOT EXISTS (SELECT * FROM pg_database WHERE datname = 'csci_620'); \gexec
\connect csci_620;
--CREATE SCHEMA imdb IF NOT EXISTS
DO $create_imdb_schema$
BEGIN
CREATE SCHEMA IF NOT EXISTS imdb AUTHORIZATION CURRENT_USER;
END
$create_imdb_schema$;
--CREATE TABLE names
CREATE TABLE IF NOT EXISTS imdb.names (
id INTEGER NOT NULL PRIMARY KEY,
primaryName VARCHAR(200) NOT NULL,
birthYear NUMERIC(4, 0),
deathYear NUMERIC(4, 0)
);
--CREATE TABLE titles
CREATE TABLE IF NOT EXISTS imdb.titles (
id INTEGER NOT NULL PRIMARY KEY,
type VARCHAR(100),
primaryTitleName VARCHAR(1000) NOT NULL,
originalTitleName VARCHAR(1000) NOT NULL,
isAdult BOOLEAN NOT NULL DEFAULT FALSE,
startYear NUMERIC(4, 0),
endYear NUMERIC(4, 0),
runtimeMinutes INTEGER,
genres VARCHAR(200)
);
--CREATE TABLE ratings
CREATE TABLE IF NOT EXISTS imdb.ratings (
titleId INTEGER NOT NULL PRIMARY KEY,
averageRating NUMERIC(4, 2),
voteCount INTEGER,
FOREIGN KEY (titleId) REFERENCES imdb.titles(id)
);
--CREATE TABLE episode
CREATE TABLE IF NOT EXISTS imdb.episodes (
id INTEGER NOT NULL PRIMARY KEY,
titleId INTEGER NOT NULL,
seasonNumber INTEGER,
episodeNumber INTEGER,
FOREIGN KEY (titleId) REFERENCES imdb.titles(id)
);
--CREATE TABLE akas
CREATE TABLE IF NOT EXISTS imdb.akas (
titleId INTEGER NOT NULL PRIMARY KEY,
orderNumber INTEGER,
titleName VARCHAR(200),
region VARCHAR(200),
language VARCHAR(200),
types VARCHAR(500),
attributes VARCHAR(500),
isOriginalTitle BOOLEAN,
FOREIGN KEY (titleId) REFERENCES imdb.titles(id)
);
--CREATE TABLE directors
CREATE TABLE IF NOT EXISTS imdb.directors (
titleId INTEGER NOT NULL,
nameId INTEGER NOT NULL,
PRIMARY KEY (titleId, nameId),
FOREIGN KEY (titleId) REFERENCES imdb.titles(id),
FOREIGN KEY (nameId) REFERENCES imdb.names(id)
);
--CREATE TABLE writers
CREATE TABLE IF NOT EXISTS imdb.writers (
titleId INTEGER NOT NULL,
nameId INTEGER NOT NULL,
PRIMARY KEY (titleId, nameId),
FOREIGN KEY (titleId) REFERENCES imdb.titles(id),
FOREIGN KEY (nameId) REFERENCES imdb.names(id)
);
--CREATE TABLE principals
CREATE TABLE IF NOT EXISTS imdb.principals (
titleId INTEGER NOT NULL,
nameId INTEGER NOT NULL,
orderNumber INTEGER,
category VARCHAR(100),
job VARCHAR(1000),
characters VARCHAR(1000),
PRIMARY KEY (titleId, nameId),
FOREIGN KEY (titleId) REFERENCES imdb.titles(id),
FOREIGN KEY (nameId) REFERENCES imdb.names(id)
);
\echo 'DB INITIALIZED' | true |
fa7d43c6694ee1b8326a21e6300382b21859075f | SQL | birce-ceren/Web-Programlama-Blog-Sitesi | /basic_blog/blog.sql | UTF-8 | 513 | 3.359375 | 3 | [] | no_license | CREATE TABLE users
(
id int PRIMARY KEY AUTO_INCREMENT,
name varchar(255),
surname varchar(255),
password varchar(255),
username varchar(255)
);
CREATE TABLE blogs
(
id int PRIMARY KEY AUTO_INCREMENT,
owner int,
title varchar(255),
article longtext,
creation_time DATETIME DEFAULT CURRENT_TIMESTAMP,
modification_time DATETIME ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (owner) REFERENCES users(id)
);
| true |
81e3267231c1343688865b803b307b4b1c8bb9b9 | SQL | noel-castillo/JPACRUDProject | /mlbb.sql | UTF-8 | 1,534 | 3.375 | 3 | [] | no_license | -- 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 mlbb
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `mlbb` ;
-- -----------------------------------------------------
-- Schema mlbb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mlbb` DEFAULT CHARACTER SET utf8 ;
USE `mlbb` ;
-- -----------------------------------------------------
-- Table `Hero`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `Hero` ;
CREATE TABLE IF NOT EXISTS `Hero` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) NULL,
`health` INT NULL,
`mana` INT NULL,
`backstory` VARCHAR(45) NULL,
`image` LONGBLOB NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SET SQL_MODE = '';
DROP USER IF EXISTS blue@localhost;
SET SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
CREATE USER 'blue'@'localhost' IDENTIFIED BY 'blue';
GRANT SELECT, INSERT, TRIGGER, UPDATE, DELETE ON TABLE * TO 'blue'@'localhost';
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
| true |
39f7d718207ed947032cb7c2f754523d44a0a34d | SQL | pablogomezponce/executive-interaction-system-for-moodle | /views.sql | UTF-8 | 905 | 2.578125 | 3 | [] | no_license | create view logstore as select id, action, courseid, component, userid, objectid, eventname from mdl_logstore_standard_log;
create view user as select firstname, id, username from mdl_user;
create view assign as select duedate, id, course from mdl_assign;
create view assign_submission as select assignment, userid, timemodified, status, id from mdl_assign_submission;
create view resource as select name, id from mdl_resource;
create view course as select id, fullname from mdl_course;
create view url as select name, id, course from mdl_url;
create view role_assignments as select userid, roleid, contextid from mdl_role_assignments;
create view user_enrolments as select userid, enrolid from mdl_user_enrolments;
create view role as select id, shortname from mdl_role;
create view context as select id, instanceid from mdl_context;
create view enrol as select courseid, id from mdl_enrol;
| true |
c69df30a001400ca8757c6c941a763afbb46a0ae | SQL | XingXing2019/LeetCode | /Database/LeetCode 2066 - AccountBalance/AccountBalance_SQLServer.sql | UTF-8 | 185 | 3.8125 | 4 | [] | no_license | SELECT account_id, day,
SUM(
CASE [type]
WHEN 'Deposit' THEN amount
ELSE -amount END)
OVER (PARTITION BY account_id ORDER BY day) AS balance
FROM Transactions
ORDER BY account_id | true |
3efb1b90ddceac603f9db0d05f7ae1bcb1ea8df9 | SQL | GuruYoda/Learning_SQL | /SQLCommands.sql | UTF-8 | 4,082 | 4.1875 | 4 | [] | no_license | --'Creating new TABLE'
--\* BASICS COURSE */
CREATE TABLE EmployeeDemographics
(
EmployeeID int,
FirstName varchar(50),
LastName varchar(50),
Age int,
Gender varchar(50)
)
CREATE TABLE EmployeeSalary
(
EmployeeID int,
JobTitle varchar(50),
Salary int,
)
--HardRefresh Ctrl+Shift+R
'Inserting data into TABLE'
INSERT INTO EmployeeDemographics VALUES
(
1001, 'Jim', 'Halpert', 30, 'Male'
)
--'SELECT AND FROM Statement'
SELECT TOP 5 *
SELECT DISTINCT(Gender) //'The number of distincr resulta are returned'
SELECT COUNT(LastName) AS LastNameCount
SELECT MAX/MIN/AVG(Salary)
--'WHERE and LIKE are also super easy to use
--we can query just a small portion of our complete
--data using these
--Eg. WHERE LastName LIKE '%d%' ( this query will return all the lastnames which hade d somewhere)
--WHERE Age <= 23 AND/OR LastName LIKE '%d''
WHERE FirstName in NULL 'returns all the fielsd in the data which have firstname Null'
WHERE FirstName is NOT NULL 'returns all the fields in the last name column which are not NULL'
WHERE FirstName IN ('Jim', 'Michael')
--\* GROUP BY Statement */
--' This statement is useful if zou want to have an overview
--of the data in the columnsThe query rolls all the data
--i.e groups all the data of the query'
--###Limits
/*LIMIT is a keyword available in SQL to limit the rows of a query*/
SELECT accout_id, [money], "funds"
FROM cleints
LIMIT 10;
--###OrderBy
/*ORDER BY Keyword is used to reorder the query in ascending order by DEFAULT i.e. a-z or 1-9
but if the query is to be ordered in descending order, a DESC can be added to the
end of the query*/
SELECT account_it, occured_at
FROM orders
ORDER BY occured_at DESC
LIMIT 20;
SELECT id, account_id, total_amt_usd
FROM orders
ORDER BY account_id, total_amt_usd DESC;
--###WHERE
/* This keyword sherched and queries on the data that satisfies the applied condition in
the selected column
Common operations are (<> is the not equal to operator), BETWEEN ,
=,>,< when using non character data but when using character data use '__d%__'*/
SELECT account_it, occured_at
FROM orders
WHERE account_id = 1222
ORDER BY occured_at DESC
LIMIT 20;
SELECT *
FROM orders
WHERE gloss_amt_usd >= 1000
ORDER BY gloss_amt_usd
LIMIT 5;
--### AS is used simply to create a derived data from the already available columns in the table when making a query
SELECT a,b,a+b AS c
FROM orders
WHERE gloss_amt_usd <= 500
ORDER BY gloss_amt_usd
LIMIT 10;
--### LIKE is used also as a comparision operator but is more powerful
SELECT *
FROM orders
WHERE gloss_amt_usd LIKE '%t%'
--###IN also used with WHERE
SELECT *
FROM orders
WHERE gloss_amt_usd IN (122,1222)
SELECT name, primary_poc, sales_rep_id
FROM accounts
WHERE name IN ('Walmart','Target','Nordstorm');
SELECT *
FROM web_events
WHERE channel IN ('organic','adword')
--###NOT can be used in conjunction with IN and LIKE to get inverse of the query
--### AND, OR is just like a logical operator
select *
from orders
where standard_qty BETWEEN 1000 AND 1001 and poster_qty = 0 and gloss_qty = 0
order by standard_qty;
--### JOINS
SELECT orders.*
FROM orders
JOIN accounts
ON orders.account_id = accounts.id;
/*FROM clause indicates the first table from which we're pulling data, and the JOIN indicates the second table.
### The ON clause specifies the column on which you'd like to merge the two tables together */
INNER JOIN,
FULL OUTER JOIN,
LEFT OUTER JOIN,
RIGHT OUTER JOIN
UNION
--this is used to join the data from 2 TABLES
CASE
WHEN ...... THEN .....
ELSE
END
--*HAVING*
--This is used after we have done some mathematical operation on our DATABASE
--WHERE caluse cannot work on queries like AVG(salaries)
--Hence in such situations HAVING is really helpful
--But having must be used after the ORDER BY clause
UPDATE name of the tables
SET some field fromt he table = some DATA
WHERE some keys to identify the data
DELETE FROM name of the TABLE
WHERE field in the table = data
--'Deletion is permanent operation and the deleted data cannot be retrived'
COUNT(Gender) OVER (PARTITION BY Gender) AS TotalGender | true |
05c716980bb9725f3f22cf6646ecf7c9bb321f55 | SQL | EladC921/Ricos | /create tables query.sql | UTF-8 | 1,582 | 3.859375 | 4 | [] | no_license | CREATE TABLE Users (
uid INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(55) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
mail VARCHAR(255) UNIQUE NOT NULL,
firstName VARCHAR(55) NOT NULL,
lastName VARCHAR(55),
profilePic TEXT(1000),
bio TEXT,
numOfRecipes INT DEFAULT 0,
numOfFollowers INT DEFAULT 0,
numOfFollowing INT DEFAULT 0,
);
CREATE TABLE Recipe (
rid INT PRIMARY KEY AUTO_INCREMENT,
uid INT NOT NULL,
date DATETIME NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT(1000),
img TEXT(1000),
ingredients TEXT,
steps MEDIUMTEXT,
numOfLikes INT DEFAULT 0,
FOREIGN KEY (uid) REFERENCES Users(uid)
);
CREATE TABLE Comment (
cid INT PRIMARY KEY AUTO_INCREMENT,
content TEXT(1000) NOT NULL,
numOfLikes INT DEFAULT 0
);
CREATE TABLE RecipeLikes(
uid INT NOT NULL,
rid INT NOT NULL,
FOREIGN KEY (uid) REFERENCES Users(uid),
FOREIGN KEY (rid) REFERENCES Recipe(rid),
PRIMARY KEY(uid, rid)
);
CREATE TABLE CommentLikes (
uid INT NOT NULL,
cid INT NOT NULL,
FOREIGN KEY (uid) REFERENCES Users(uid),
FOREIGN KEY (cid) REFERENCES Comment(cid),
PRIMARY KEY (uid, cid)
);
CREATE TABLE CommentsOnRecipes (
uid INT NOT NULL,
cid INT NOT NULL,
rid INT NOT NULL,
FOREIGN KEY (uid) REFERENCES Users(uid),
FOREIGN KEY (cid) REFERENCES Comment(cid),
FOREIGN KEY (rid) REFERENCES Recipe(rid),
PRIMARY KEY (uid, cid, rid)
);
CREATE TABLE Follows (
uid INT NOT NULL,
followerId INT NOT NULL,
FOREIGN KEY (uid) REFERENCES Users(uid),
FOREIGN KEY (followerId) REFERENCES Users(uid),
PRIMARY KEY (uid, followerId),
date DATETIME NOT NULL
); | true |
c8559852329b5100838bf723d419b89d5b05a819 | SQL | GillesRitchmond/Delivery | /difference_date_time-main/Table_Ajax_PHP/user.sql | UTF-8 | 2,253 | 3.171875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 11, 2021 at 09:33 PM
-- Server version: 10.4.17-MariaDB
-- PHP Version: 7.2.34
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `testing`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_user`
--
CREATE TABLE `tbl_user` (
`id` int(11) NOT NULL,
`numero_fiche` int(11) NOT NULL,
`envoyeur` varchar(250) NOT NULL,
`heure_envoie` datetime NOT NULL,
`receveur` varchar(250) NOT NULL,
`heure_reception` datetime NOT NULL,
`temps_attente` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_user`
--
INSERT INTO `tbl_user` (`id`, `numero_fiche`, `envoyeur`, `heure_envoie`, `receveur`, `heure_reception`, `temps_attente`) VALUES
(3, 2, 'Carol', '2021-04-08 03:52:37', 'Ferrari', '2021-04-08 06:52:37', '00:00:00'),
(10, 3, 'Kenneth', '2021-04-08 10:36:06', 'Simons', '2021-04-08 21:52:06', '00:00:00'),
(11, 4, 'Dona', '2021-04-08 04:21:38', 'Huber', '2021-04-08 08:03:38', '00:00:00'),
(12, 5, 'Williamr', '2021-04-08 07:41:02', 'Soliz', '2021-04-08 09:33:02', '00:00:00'),
(14, 6, 'Sarah bercy', '2021-04-08 08:50:30', 'Anne', '2021-04-08 09:40:00', '00:00:00'),
(17, 7, 'Stéphanie', '2021-03-31 00:00:00', 'Ritchmond', '2021-04-04 00:00:00', '00:00:00'),
(19, 8, 'Marcus', '2021-04-12 00:00:00', 'Elisabeth', '2021-04-12 00:00:00', '00:00:00');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tbl_user`
--
ALTER TABLE `tbl_user`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `tbl_user`
--
ALTER TABLE `tbl_user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
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 |
d34dd927e2e5542bb4752f22d62eca85d1698511 | SQL | s18001-ikeshiro/oracle | /0117/0117.3.sql | UTF-8 | 139 | 3.078125 | 3 | [] | no_license | select employee_id, last_name
from employees
where department_id = any (select department_id from employees where last_name like '%u%')
/
| true |
87966bbe7b1f1256a5354e30d170fcc90eb4285c | SQL | SQLauto/PyroSQL | /bestpractice/tsqlsmells/TSQLSmells/ConvertInt.sql | UTF-8 | 166 | 3.015625 | 3 | [] | no_license |
CREATE PROCEDURE dbo.ConvertDateMultipeCond
AS
SELECT create_date,CONVERT(varchar(255),create_date,120)
FROM sys.objects
WHERE CAST(object_id AS VARCHAR(10)) ='22'
| true |
d21d9ace742ca1de85e4c0a4cf3dbea1c934352f | SQL | THRAGOO/Morningbees-server | /src/main/resources/db/migration/V1__create_user.sql | UTF-8 | 296 | 3.203125 | 3 | [] | no_license | create table users (
id bigint unsigned not null auto_increment primary key,
nickname varchar(255),
status int(1),
created_at datetime not null,
updated_at datetime not null,
index idx_status(status),
UNIQUE idx_nickname(nickname)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | true |
ba2302bbc821be710de0d9295d946c26d18cd66c | SQL | lt911/PL-SQL-Fundamentals-2018- | /week3_code_examples/les03_part04_codex01.sql | UTF-8 | 1,066 | 3.609375 | 4 | [] | no_license | -- This program is intended to explain cursors, and it does not handle any exceptions that might arise from the SQL query.
DECLARE
v_emp_id copy_emp2.employee_id%TYPE := 0;
v_bonus NUMBER(8,2) := 0;
v_salary copy_emp2.salary%TYPE;
v_hire_date copy_emp2.hire_date%TYPE;
CURSOR c_emp_cursor IS
SELECT employee_id, salary, hire_date FROM copy_emp2;
BEGIN
OPEN c_emp_cursor;
LOOP
FETCH c_emp_cursor INTO v_emp_id, v_salary, v_hire_date;
EXIT WHEN c_emp_cursor%NOTFOUND;
v_bonus :=
CASE
WHEN ROUND((MONTHS_BETWEEN (SYSDATE,v_hire_date) / 12),0) = 10 THEN
v_salary * 0.5
WHEN ROUND((MONTHS_BETWEEN (SYSDATE,v_hire_date) / 12),0) > 5 AND ROUND((MONTHS_BETWEEN (SYSDATE,v_hire_date) / 12),0) < 10 THEN
v_salary * 0.25
ELSE
v_salary * 0.1
END;
DBMS_OUTPUT.PUT_LINE( 'Employee ID: '||v_emp_id|| ' gets a bonus amount: '||v_bonus);
END LOOP;
CLOSE c_emp_cursor;
END;
/ | true |
23f1283c1952d75b4f816cf1f26ea8e22e411b4c | SQL | MrLambert13/PHP2 | /lesson3/Exersice2.sql | UTF-8 | 598 | 2.984375 | 3 | [] | no_license | CREATE SCHEMA `world` ;
CREATE TABLE `world`.`country` (
`id` INT NOT NULL AUTO_INCREMENT,
`Code` VARCHAR(45) NULL,
`Name` VARCHAR(45) NULL,
`Region` VARCHAR(45) NULL,
`Population` VARCHAR(45) NULL,
`Capital` VARCHAR(45) NULL,
PRIMARY KEY (`id`));
CREATE TABLE `world`.`city` (
`id` INT NOT NULL,
`Name` VARCHAR(45) NULL,
`CountryCode` VARCHAR(45) NULL,
PRIMARY KEY (`id`));
CREATE TABLE `world`.`countrylanguage` (
`id` INT NOT NULL AUTO_INCREMENT,
`Language` VARCHAR(45) NULL,
`CountryCode` VARCHAR(45) NULL,
`IsOfficial` VARCHAR(45) NULL,
PRIMARY KEY (`id`));
| true |
30b8a55c28a6a0d5aee90d28d349319d095fa18c | SQL | fleetside72/tps_etl | /database/reports/colateral_balalance.sql | UTF-8 | 744 | 3.3125 | 3 | [] | no_license | SELECT
r.*
,CASE "Schedule#"
WHEN '02IN Raw Material' THEN 13097563.42
WHEN '03IN Finished Goods' THEN 35790696.52
ELSE 0
END + SUM("Sales"+"Credits & Adjustments"-"Gross Collections") OVER (PARTITION BY "Schedule#" ORDER BY "Schedule#" ASC, "PostDate" ASC) running_bal
,(LEAST("CollateralBalance" - "Ineligible Amount","MaxEligible")*("AdvanceRate"/100))::NUMERIC(20,2) qualified_collateral
,(("CollateralBalance" - "Ineligible Amount")*("AdvanceRate"/100))::NUMERIC(20,2) qualified_collateral_nl
FROM
tpsv.pncl_default r
WHERE
"Schedule#" = '01AR'
--"Schedule#" = '02IN Raw Material'
--"Schedule#" = '03IN Finished Goods'
ORDER BY
"Schedule#" asc
,r."PostDate" asc
,id | true |
5bb009ee79bd090adce0825bab28d1c481fd3916 | SQL | gitdaddy/gitdaddy.github.io | /web2_db.sql | UTF-8 | 2,133 | 3.328125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.0.10.10
-- http://www.phpmyadmin.net
--
-- Host: 127.10.41.2:3306
-- Generation Time: Jan 05, 2016 at 08:54 PM
-- Server version: 5.5.45
-- PHP Version: 5.3.3
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: `web2_db`
--
-- --------------------------------------------------------
--
-- Table structure for table `card`
--
CREATE TABLE IF NOT EXISTS `card` (
`card_id` int(11) NOT NULL AUTO_INCREMENT,
`subject_id` int(11) NOT NULL,
`question` varchar(50) NOT NULL,
`answer` varchar(50) NOT NULL,
PRIMARY KEY (`card_id`),
KEY `subject_id` (`subject_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `card`
--
INSERT INTO `card` (`card_id`, `subject_id`, `question`, `answer`) VALUES
(1, 1, 'Integral of xlnx', 'x^2/2lnx-x^2/4 + C'),
(2, 3, 'What does S.E.O stand for', 'Search Engine Optimization'),
(3, 2, 'What does Pb3(PO4)4 stand for', 'Lead Phosphate'),
(4, 3, 'What was the Morris Worm Famous for', 'First internet worm distributed in 1988');
-- --------------------------------------------------------
--
-- Table structure for table `subject`
--
CREATE TABLE IF NOT EXISTS `subject` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Dumping data for table `subject`
--
INSERT INTO `subject` (`id`, `name`) VALUES
(1, 'Math'),
(2, 'Chemistry'),
(3, 'Computer Security');
--
-- Constraints for dumped tables
--
--
-- Constraints for table `card`
--
ALTER TABLE `card`
ADD CONSTRAINT `card_ibfk_1` FOREIGN KEY (`subject_id`) REFERENCES `subject` (`id`);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
dda342d0c7497a6cbbd89fc10cdcc83cd1a35d92 | SQL | ricco1337/projects | /db/get_products.sql | UTF-8 | 78 | 2.734375 | 3 | [] | no_license | select * from images
join products
on images.product_id = products.product_id
| true |
0f72724151fedc7dcb03971fef469282fad69f89 | SQL | pablorzmz/AdminEscuelasDeFut | /src/Tables.sql | ISO-8859-1 | 5,858 | 3.75 | 4 | [] | no_license | USE DB_ERROR404;
/* Tabla de la entidad de Persona*/
CREATE TABLE Persona
(
Cedula CHAR(9) NOT NULL,
NombreP VARCHAR(30) NULL,
Apellido1 VARCHAR(15) NULL,
Apellido2 VARCHAR(15) NULL,
CONSTRAINT Ced_Persona PRIMARY KEY ( Cedula )
);
/*Atributo multivalor de los telfonos de las personas*/
CREATE TABLE TelefonoP
(
Cedula CHAR(9) NOT NULL,
Telefono VARCHAR(8) NOT NULL,
CONSTRAINT Tels_Persona PRIMARY KEY ( Cedula, Telefono ),
CONSTRAINT Ref_Per FOREIGN KEY ( Cedula ) REFERENCES Persona( Cedula )
ON DELETE CASCADE ON DELETE CASCADE
);
/* Tabla de la entidad especializada Encargado */
CREATE TABLE Encargado
(
CedEncargado CHAR (9) NOT NULL,
CONSTRAINT Ced_Encar PRIMARY KEY( CedEncargado ),
CONSTRAINT Ref_Per_Encar FOREIGN KEY ( CedEncargado ) REFERENCES Persona( Cedula )
ON UPDATE CASCADE
);
/* Tabla de la entidad especializada Jugador */
CREATE TABLE Jugador
(
CedJugador CHAR (9) NOT NULL,
Edad TINYINT NOT NULL,
Sexo CHAR(1) NOT NULL CHECK( Sexo = 'm' OR Sexo = 'f'),
FechNac DATE NOT NULL,
CedEncargado CHAR(9) NOT NULL,
CONSTRAINT Ced_Jug PRIMARY KEY ( CedJugador ),
CONSTRAINT Ref_Ced_Encar FOREIGN KEY ( CedEncargado ) REFERENCES Encargado( CedEncargado )
ON UPDATE CASCADE
CONSTRAINT Ref_Jug_Pers FOREIGN KEY ( CedJugador ) REFERENCES Persona( Cedula )
ON UPDATE CASCADE
);
/* Tabla entidad instalacin */
CREATE TABLE Instalacion
(
Direccion VARCHAR(30) NOT NULL,
Telefono VARCHAR(8) NULL DEFAULT '88888888',
CONSTRAINT Dir_Inst PRIMARY KEY( Direccion )
);
/* Tabla de la entidad Esculea */
CREATE TABLE Escuela
(
Nombre VARCHAR(30) NOT NULL,
Lugar VARCHAR(30) NOT NULL,
DireccionInst VARCHAR(30) NULL,
CONSTRAINT Nomb_Esc PRIMARY KEY( Nombre ),
CONSTRAINT Ref_Insta FOREIGN KEY ( DireccionInst ) REFERENCES Instalacion( Direccion )
ON DELETE SET NULL ON UPDATE CASCADE
);
/* Atributo multivalor de las escuelas */
CREATE TABLE TelefonoE
(
NombreEsc VARCHAR(30) NOT NULL,
Telefono VARCHAR(8) NOT NULL,
CONSTRAINT Telf_Esc PRIMARY KEY ( NombreEsc, Telefono ),
CONSTRAINT Ref_Esc FOREIGN KEY ( NombreEsc ) REFERENCES Escuela ( Nombre )
ON DELETE CASCADE ON UPDATE CASCADE
);
/* Tabla de la entidad pagos del jugador */
CREATE TABLE PagosDeJugador
(
NombreEscuela VARCHAR(30) NOT NULL,
NumeroRecibo VARCHAR(5) NOT NULL,
Fecha DATE NOT NULL,
Monto NUMERIC(6,0) NOT NULL,
Detalle VARCHAR(500) NULL,
CedJugador CHAR(9) NOT NULL,
CONSTRAINT Nomb_NumR PRIMARY KEY( NombreEscuela, NumeroRecibo ),
CONSTRAINT Ref_Jug1 FOREIGN KEY ( CedJugador ) REFERENCES Jugador ( CedJugador )
ON UPDATE CASCADE ON DELETE NO SET NULL,
CONSTRAINT Ref_Escc FOREIGN KEY ( NombreEscuela ) REFERENCES Escuela ( Nombre )
ON UPDATE CASCADE ON DELETE NO ACTION
);
/* Tabla de la entidad especializada pagos del jugador mensualidad */
CREATE TABLE PagoMensualidad
(
NombreEscuela VARCHAR(30) NOT NULL,
NumeroRecibo VARCHAR(5) NOT NULL,
CONSTRAINT Pago_Men PRIMARY KEY ( NombreEscuela, NumeroRecibo ),
CONSTRAINT Ref_Pago FOREIGN KEY ( NombreEscuela, NumeroRecibo ) REFERENCES PagosDeJugador( NombreEscuela, NumeroRecibo )
ON UPDATE CASCADE
);
/* Atributo multivalor de los meses pagados del pago mensualidad */
CREATE TABLE Mes
(
NombreEscuela VARCHAR(30) NOT NULL,
NumeroRecibo VARCHAR(5) NOT NULL,
Mes CHAR(3) NOT NULL,
Ao CHAR(4) NOT NULL,
CONSTRAINT Pago_Meses PRIMARY KEY ( NombreEscuela, NumeroRecibo, Mes, Ao ),
CONSTRAINT Ref_PagoM FOREIGN KEY ( NombreEscuela, NumeroRecibo ) REFERENCES PagoMensualidad ( NombreEscuela, NumeroRecibo )
ON DELETE CASCADE ON UPDATE CASCADE
);
/* Tabla de la entidad especializada pagos del jugador matrculas */
CREATE TABLE PagoMatricula
(
NombreEscuela VARCHAR(30) NOT NULL,
NumeroRecibo VARCHAR(5) NOT NULL,
CONSTRAINT Pago_Matri PRIMARY KEY ( NombreEscuela, NumeroRecibo ),
CONSTRAINT Ref2_Pago FOREIGN KEY ( NombreEscuela, NumeroRecibo ) REFERENCES PagosDeJugador( NombreEscuela, NumeroRecibo )
ON UPDATE CASCADE
);
/* Tabla de la entidad de entrenamientos */
CREATE TABLE Entrenamiento
(
Fecha DATE NOT NULL,
Hora TIME NOT NULL,
CONSTRAINT Fecha_entreno PRIMARY KEY( Fecha )
);
/* Tabla de la entidad de nivel */
CREATE TABLE Nivel
(
Numero TINYINT NOT NULL,
EdadInicio TINYINT NOT NULL,
EdadFin TINYINT NOT NULL,
CONSTRAINT Num_nivel PRIMARY KEY ( Numero)
);
/* Relacin de los jugadores en un nivel y en una escuela especfica */
CREATE TABLE Esta_En
(
CedJugador CHAR (9) NOT NULL,
NomEscuela VARCHAR (30) NOT NULL,
Nivel TINYINT NOT NULL
CONSTRAINT Esc_Jug_Niv PRIMARY KEY ( CedJugador, NomEscuela ),
CONSTRAINT Ced_For FOREIGN KEY ( CedJugador ) REFERENCES Jugador( CedJugador )
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT Esc_For FOREIGN KEY ( NomEscuela ) REFERENCES Escuela ( Nombre )
ON UPDATE CASCADE,
CONSTRAINT Niv_For FOREIGN KEY ( Nivel ) REFERENCES Nivel ( Numero )
ON UPDATE CASCADE
);
/* Relacin de los entrenamientos a los que asiste el jugador */
CREATE TABLE Asiste
(
CedJugador CHAR (9) NOT NULL,
FecEntrenamiento DATE NOT NULL,
CONSTRAINT Jug_Entre PRIMARY KEY ( CedJugador, FecEntrenamiento ),
CONSTRAINT Ref_Jug FOREIGN KEY ( CedJugador ) REFERENCES Jugador( CedJugador)
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT Ref_Entre FOREIGN KEY ( FecEntrenamiento ) REFERENCES Entrenamiento ( Fecha )
ON UPDATE CASCADE,
);
/* Relacin de los niveles que tiene una escuela */
CREATE TABLE Tiene
(
NomEsc VARCHAR(30) NOT NULL,
NumNivel TINYINT NOT NULL,
CONSTRAINT Esc_Nivel PRIMARY KEY ( NomEsc, NumNivel ) ,
CONSTRAINT Ref_Esc1 FOREIGN KEY ( NomEsc ) REFERENCES Escuela ( Nombre )
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT Ref_Esc2 FOREIGN KEY ( NumNivel ) REFERENCES Nivel ( Numero )
ON DELETE CASCADE ON UPDATE CASCADE
);
| true |
f89f68c1b280fa94e9506b441e410ad2ba90c4af | SQL | myun2ext/shibuya | /db/seed.sql | UTF-8 | 772 | 2.765625 | 3 | [] | no_license | use shibuya_development;
INSERT INTO nodes (name, screen_name, color, created_at, parent_node_id) VALUES
("Tokyo(root)", "東京", "fff", NOW(), NULL),
("Shibuya", "渋谷", "278C3E", NOW(), 1),
("Tokyo", "東京", "37B7DD", NOW(), 1),
("Shinagawa", "品川", "3689DB", NOW(), 1),
("Meguro", "目黒", "212B23", NOW(), 1),
-- EA628F
("Sakuragaoka", "桜ヶ丘", "E35AED", NOW(), 2),
("Dogenzaka", "道玄坂", "7F1033", NOW(), 2),
("Nanpeidai", "南平台", "2A32C1", NOW(), 2),
("Shibuya109", "渋谷109", "EA59BA", NOW(), 7),
("Kawasaki(root)","川崎", "37B7DD", NOW(), NULL)
;
INSERT INTO users (name, screen_name, encrypted_password, password_salt, created_at) VALUES
("myun2", "myun2 (root)", "0000", "000000", NOW())
;
| true |
028225797a09f2b907bc48d2bd18b732da73d1f3 | SQL | xsanm/DB-COURSE | /oracle/V_TRIPS.sql | UTF-8 | 258 | 3.015625 | 3 | [] | no_license | create view V_TRIPS as
select COUNTRY,
TRIP_DATE,
NAME,
NO_PLACES,
NO_PLACES - (
select count(*)
from RESERVATION
where RESERVATION.TRIP_ID = TRIP.TRIP_ID
) NO_AVAILABLE_PLACES
from TRIP
/
| true |
758b00a5bb867692a62863d526e65a8be569c904 | SQL | vineetshukla15/dusharimango | /src/data/sql/X/Temp/Temp1/05.sql | UTF-8 | 9,821 | 4.09375 | 4 | [] | no_license | DROP TABLE IF EXISTS insights.brands;
CREATE TABLE insights.brands
(
brand_id int(11) unsigned, PRIMARY KEY(brand_id),
brand_name varchar(120), INDEX(brand_name),
brand_display_name varchar(120), INDEX(brand_display_name),
brand_group_id int(11) unsigned, INDEX(brand_group_id)# FOREIGN KEY(brand_group_id) references insights.brands(brand_id)
);
DROP TRIGGER IF EXISTS insights.brands_init;
DELIMITER //
CREATE TRIGGER insights.brand_init BEFORE INSERT ON insights.brands FOR EACH ROW
BEGIN
IF NEW.brand_group_id IS NULL THEN
SET NEW.brand_group_id := NEW.brand_id;
END IF;
-- IF NEW.brand_display_name IS NULL THEN
-- SET NEW.brand_display_name := NEW.brand_name;
-- END IF;
END//
DELIMITER ;
DROP TABLE IF EXISTS insights.categories;
CREATE TABLE insights.categories
(
category_id int(10) unsigned, PRIMARY KEY(category_id),
category_name varchar(120), INDEX(category_name),
category_display_name varchar(120), INDEX(category_display_name),
parent_category_id int(10) unsigned, INDEX(parent_category_id)# FOREIGN KEY(parent_category_id) references insights.categories(category_id)
);
-- DROP TRIGGER IF EXISTS insights.category_init;
-- DELIMITER //
-- CREATE TRIGGER insights.category_init BEFORE INSERT ON insights.categories FOR EACH ROW
-- BEGIN
-- IF NEW.category_display_name IS NULL THEN
-- SET NEW.category_display_name := NEW.category_name;
-- END IF;
-- END//
-- DELIMITER ;
-- DROP TABLE IF EXISTS insights.productlines;
-- CREATE TABLE insights.productlines
-- (
-- productline_id int(11) unsigned, PRIMARY KEY(productline_id),
-- productline_name varchar(120), INDEX(productline_name),
-- brand_id int(11) unsigned, FOREIGN KEY(brand_id) references insights.brands(brand_id),
-- category_id int(10) unsigned, FOREIGN KEY(category_id) references insights.categories(category_id)
-- );
DROP TABLE IF EXISTS insights.products;
CREATE TABLE insights.products
(
product_id int(11) unsigned, PRIMARY KEY(product_id),
product_name varchar(120), INDEX(product_name),
brand_id int(11) unsigned, INDEX(brand_id),# FOREIGN KEY(brand_id) references insights.brands(brand_id),
category_id int(10) unsigned DEFAULT NULL, INDEX(category_id),# FOREIGN KEY(category_id) references insights.categories(category_id),
product_display_name varchar(120), INDEX(product_display_name),
productline_id int(11) unsigned, INDEX(productline_id)# FOREIGN KEY(productline_id) references insights.products(product_id)
-- productline_id int(11) unsigned, FOREIGN KEY(productline_id) references insights.productlines(productline_id)
);
DROP TRIGGER IF EXISTS insights.product_init;
DELIMITER //
CREATE TRIGGER insights.product_init BEFORE INSERT ON insights.products FOR EACH ROW
BEGIN
IF NEW.category_id = 0 THEN
SET NEW.category_id := NULL;
END IF;
-- IF NEW.product_display_name IS NULL THEN
-- SET NEW.product_display_name := NEW.product_name;
-- END IF;
IF NEW.productline_id IS NULL THEN
SET NEW.productline_id := NEW.product_id;
END IF;
END//
DELIMITER ;
-- DROP TABLE IF EXISTS insights.commercial_group;
-- CREATE TABLE insights.commercial_group
-- (
-- commercial_group_id int(10) unsigned, PRIMARY KEY(commercial_group_id),
-- flag_bearing_commercial_id int(10) unsigned, INDEX(flag_bearing_commercial_id)
-- );
DROP TABLE IF EXISTS insights.contents;
CREATE TABLE insights.contents
(
content_id int(11) unsigned, PRIMARY KEY(content_id),
content_title varchar(255), INDEX(content_title),
content_duration int(10) unsigned,
alphonso_owned boolean,
product_id int(11) unsigned, INDEX(product_id),# FOREIGN KEY(content_product_id) references insights.products(product_id),
content_group_id int(11) unsigned, INDEX(content_group_id),# FOREIGN KEY(content_group_id) references insights.contents(content_id),
content_display_title varchar(255), INDEX(content_display_title),
coop_product_id int(11) unsigned, INDEX(coop_product_id)# FOREIGN KEY(content_product_id) references insights.products(product_id)
);
DROP TRIGGER IF EXISTS insights.content_init;
DELIMITER //
CREATE TRIGGER insights.content_init BEFORE INSERT ON insights.contents FOR EACH ROW
BEGIN
IF NEW.content_group_id = 0 THEN
SET NEW.content_group_id := NEW.content_id;
END IF;
END//
DELIMITER ;
-- DROP TABLE IF EXISTS insights.coop;
-- CREATE TABLE insights.coop
-- (
-- commercial_id int(10) unsigned, FOREIGN KEY(commercial_id) references insights.commercial(commercial_id),
-- product_id int(10) unsigned, FOREIGN KEY(product_id) references insights.product(product_id)
-- );
DROP TABLE IF EXISTS insights.airings_master;
CREATE TABLE insights.airings_master
(
content_id int(11) unsigned, INDEX(content_id),# FOREIGN KEY(content_id) references insights.contents(content_id),
airing_start_time_UTC datetime, INDEX(airing_start_time_UTC),
pod_position int(10) unsigned,
spend int(10) unsigned,
tv_station_id int(10) unsigned, INDEX(tv_station_id),
tv_station_tz varchar(100), INDEX(tv_station_tz),
tv_network varchar(100), INDEX(tv_network),
show_title varchar(100), INDEX(show_title),
show_genres varchar(100),
show_start_time_UTC datetime,
show_end_time_UTC datetime,
UNIQUE KEY(content_id, airing_start_time_UTC, tv_station_id)
);
DROP TABLE IF EXISTS insights.content_product_brand_category;
CREATE TABLE insights.content_product_brand_category
(
content_id int(11) unsigned, PRIMARY KEY(content_id),
content_title varchar(255), INDEX(content_title),
content_duration int(10) unsigned,
alphonso_owned boolean,
content_group_id int(11) unsigned, INDEX(content_group_id),#content_group_id and content_duration should be used in combination to unique content groups
#content_group_title varchar(255), INDEX(content_group_title),
product_id int(11) unsigned, INDEX(product_id),
product_name varchar(120), INDEX(product_name),
productline_id int(11) unsigned, INDEX(productline_id),
#productline_name varchar(120), INDEX(productline_name),
brand_id int(11) unsigned, INDEX(brand_id),
brand_name varchar(120), INDEX(brand_name),
brand_group_id int(11) unsigned, INDEX(brand_group_id),
#brand_group_name varchar(120), INDEX(brand_group_name),
category_id int(10) unsigned DEFAULT NULL, INDEX(category_id),
category_name varchar(120), INDEX(category_name),
coop_product_id int(11) unsigned, INDEX(coop_product_id),
coop_product_name varchar(120), INDEX(coop_product_name),
coop_productline_id int(11) unsigned, INDEX(coop_productline_id),
#coop_productline_name varchar(120), INDEX(coop_productline_name),
coop_brand_id int(11) unsigned, INDEX(coop_brand_id),
coop_brand_name varchar(120), INDEX(coop_brand_name),
coop_brand_group_id int(11) unsigned, INDEX(coop_brand_group_id),
#coop_brand_group_name varchar(120), INDEX(coop_brand_group_name),
coop_category_id int(10) unsigned DEFAULT NULL, INDEX(coop_category_id),
coop_category_name varchar(120), INDEX(coop_category_name)
);
DROP TABLE IF EXISTS insights.airings;#content_product_brand_category_station_network_show
CREATE TABLE insights.airings
(
content_id int(10) unsigned, INDEX(content_id),# FOREIGN KEY(content_id) references insights.contents(content_id),
content_title varchar(255), INDEX(content_title),
content_duration int(10) unsigned,
alphonso_owned boolean,
content_group_id int(11) unsigned, INDEX(content_group_id),#content_group_id and content_duration should be used in combination to unique content groups
#content_group_title varchar(255), INDEX(content_group_title),
product_id int(11) unsigned, INDEX(product_id),
product_name varchar(120), INDEX(product_name),
productline_id int(11) unsigned, INDEX(productline_id),
#productline_name varchar(120), INDEX(productline_name),
brand_id int(11) unsigned, INDEX(brand_id),
brand_name varchar(120), INDEX(brand_name),
brand_group_id int(11) unsigned, INDEX(brand_group_id),
#brand_group_name varchar(120), INDEX(brand_group_name),
category_id int(10) unsigned DEFAULT NULL, INDEX(category_id),
category_name varchar(120), INDEX(category_name),
airing_start_time_UTC datetime, INDEX(airing_start_time_UTC),
airing_time datetime, INDEX(airing_time),
daypart varchar(24), INDEX(daypart),
pod_position int(10) unsigned,
spend int(10) unsigned,
tv_station_id int(10) unsigned, INDEX(tv_station_id),
tv_station_tz varchar(100), INDEX(tv_station_tz),
tv_network varchar(100), INDEX(tv_network),
show_title varchar(100), INDEX(show_title),
show_genres varchar(100),
show_start_time_UTC datetime,
show_end_time_UTC datetime,
show_start_time datetime,
show_end_time datetime,
coop_product_id int(11) unsigned, INDEX(coop_product_id),
coop_product_name varchar(120), INDEX(coop_product_name),
coop_productline_id int(11) unsigned, INDEX(coop_productline_id),
#coop_productline_name varchar(120), INDEX(coop_productline_name),
coop_brand_id int(11) unsigned, INDEX(coop_brand_id),
coop_brand_name varchar(120), INDEX(coop_brand_name),
coop_brand_group_id int(11) unsigned, INDEX(coop_brand_group_id),
#coop_brand_group_name varchar(120), INDEX(coop_brand_group_name),
coop_category_id int(10) unsigned DEFAULT NULL, INDEX(coop_category_id),
coop_category_name varchar(120), INDEX(coop_category_name),
UNIQUE KEY(content_id, airing_start_time_UTC, tv_station_id)
);
DROP TABLE IF EXISTS insights.tv_station_pricing;
CREATE TABLE insights.tv_station_pricing
(
tv_station_id int(10) unsigned, INDEX(tv_station_id),
tv_network varchar(100), INDEX(tv_network),
datetime_range_start datetime,
datetime_range_end datetime,
show_genres varchar(100),
commercial_duration int(10) unsigned,
tv_station_spot_price int(10) unsigned
) | true |
fae6db4db0eb52c77c42e432f3d42be87d77a256 | SQL | robertomassabr/rakkas-realworld | /prisma/migrations/20210818122947_init/migration.sql | UTF-8 | 2,917 | 3.90625 | 4 | [
"CC-BY-2.0",
"MIT",
"CC-BY-4.0",
"CC-BY-3.0"
] | permissive | -- CreateTable
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"email" TEXT NOT NULL,
"username" TEXT NOT NULL,
"bio" TEXT NOT NULL,
"image" TEXT,
"passwordHash" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "Article" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT NOT NULL,
"body" TEXT NOT NULL,
"authorId" INTEGER NOT NULL,
FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "Comment" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"body" TEXT NOT NULL,
"articleId" INTEGER NOT NULL,
"authorId" INTEGER NOT NULL,
FOREIGN KEY ("articleId") REFERENCES "Article" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "ArticleTags" (
"articleId" INTEGER NOT NULL,
"tagName" TEXT NOT NULL,
PRIMARY KEY ("articleId", "tagName"),
FOREIGN KEY ("articleId") REFERENCES "Article" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "_favorite" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL,
FOREIGN KEY ("A") REFERENCES "Article" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("B") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "_follows" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL,
FOREIGN KEY ("A") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("B") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email");
-- CreateIndex
CREATE UNIQUE INDEX "User.username_unique" ON "User"("username");
-- CreateIndex
CREATE INDEX "User.createdAt_index" ON "User"("createdAt");
-- CreateIndex
CREATE INDEX "User.updatedAt_index" ON "User"("updatedAt");
-- CreateIndex
CREATE INDEX "Article.createdAt_index" ON "Article"("createdAt");
-- CreateIndex
CREATE INDEX "Article.updatedAt_index" ON "Article"("updatedAt");
-- CreateIndex
CREATE INDEX "Comment.createdAt_index" ON "Comment"("createdAt");
-- CreateIndex
CREATE INDEX "Comment.updatedAt_index" ON "Comment"("updatedAt");
-- CreateIndex
CREATE UNIQUE INDEX "_favorite_AB_unique" ON "_favorite"("A", "B");
-- CreateIndex
CREATE INDEX "_favorite_B_index" ON "_favorite"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_follows_AB_unique" ON "_follows"("A", "B");
-- CreateIndex
CREATE INDEX "_follows_B_index" ON "_follows"("B");
| true |
4ec77868b69db83de93b7fb5c387b2a8a1914262 | SQL | nilsonrochabh/espacodapalavra | /module/Model/model/generated-sql/espacopalavra.sql | UTF-8 | 14,365 | 3.28125 | 3 | [] | no_license | -- MySQL Script generated by MySQL Workbench
-- 07/25/16 10:41:38
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema espacopalavra
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema espacopalavra
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `espacopalavra` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `espacopalavra` ;
-- -----------------------------------------------------
-- Table `espacopalavra`.`usuario`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`usuario` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`nome` VARCHAR(100) NOT NULL,
`email` VARCHAR(200) NOT NULL,
`atuacao` VARCHAR(100) NULL,
`genero` VARCHAR(100) NULL,
`senha` VARCHAR(250) NULL,
`descricao_contexto` VARCHAR(250) NULL,
`data_cadastro` DATETIME NOT NULL,
`is_admin` TINYINT(1) NOT NULL DEFAULT 0,
`imagem_profile` VARCHAR(200) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`proposicao`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`proposicao` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_usuario` INT UNSIGNED NOT NULL,
`nome` VARCHAR(250) NOT NULL,
`objetivo` TEXT NOT NULL,
`start` TEXT NULL,
`imagem` VARCHAR(200) NULL,
`tempo_total` TIME NULL,
`data_cadastro` DATETIME NOT NULL,
`is_rascunho` TINYINT(1) NOT NULL DEFAULT 1,
`categoria` ENUM('S', 'J', 'P') NOT NULL,
`qte_comentarios` INT NOT NULL DEFAULT 0,
`qte_curtidas` INT NOT NULL DEFAULT 0,
`qte_seguidores` INT NOT NULL DEFAULT 0,
`qte_concluidos` INT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
INDEX `fk_proposicao_usuario_idx` (`id_usuario` ASC),
CONSTRAINT `fk_proposicao_usuario`
FOREIGN KEY (`id_usuario`)
REFERENCES `espacopalavra`.`usuario` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`habilidade`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`habilidade` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`descricao` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`ambiente`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`ambiente` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`descricao` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`recurso`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`recurso` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`descricao` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`tamanho_turma`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`tamanho_turma` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`descricao` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`recurso_proposicao`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`recurso_proposicao` (
`id_recurso` INT UNSIGNED NOT NULL,
`id_proposicao` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id_recurso`, `id_proposicao`),
INDEX `fk_recurso_has_proposicao_proposicao1_idx` (`id_proposicao` ASC),
INDEX `fk_recurso_has_proposicao_recurso1_idx` (`id_recurso` ASC),
CONSTRAINT `fk_recurso_has_proposicao_recurso1`
FOREIGN KEY (`id_recurso`)
REFERENCES `espacopalavra`.`recurso` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_recurso_has_proposicao_proposicao1`
FOREIGN KEY (`id_proposicao`)
REFERENCES `espacopalavra`.`proposicao` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`tamanho_turma_proposicao`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`tamanho_turma_proposicao` (
`id_tamanho_turma` INT UNSIGNED NOT NULL,
`id_proposicao` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id_tamanho_turma`, `id_proposicao`),
INDEX `fk_tamanho_turma_proposicao_proposicao1_idx` (`id_proposicao` ASC),
INDEX `fk_tamanho_turma_proposicao_tamanho_turma1_idx` (`id_tamanho_turma` ASC),
CONSTRAINT `fk_tamanho_turma_proposicao_tamanho_turma1`
FOREIGN KEY (`id_tamanho_turma`)
REFERENCES `espacopalavra`.`tamanho_turma` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_tamanho_turma_proposicao_proposicao1`
FOREIGN KEY (`id_proposicao`)
REFERENCES `espacopalavra`.`proposicao` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`habilidade_proposicao`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`habilidade_proposicao` (
`id_habilidade` INT UNSIGNED NOT NULL,
`id_proposicao` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id_habilidade`, `id_proposicao`),
INDEX `fk_habilidade_proposicao_proposicao1_idx` (`id_proposicao` ASC),
INDEX `fk_habilidade_proposicao_habilidade1_idx` (`id_habilidade` ASC),
CONSTRAINT `fk_habilidade_proposicao_habilidade1`
FOREIGN KEY (`id_habilidade`)
REFERENCES `espacopalavra`.`habilidade` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_habilidade_proposicao_proposicao1`
FOREIGN KEY (`id_proposicao`)
REFERENCES `espacopalavra`.`proposicao` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`ambiente_proposicao`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`ambiente_proposicao` (
`id_ambiente` INT UNSIGNED NOT NULL,
`id_proposicao` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id_ambiente`, `id_proposicao`),
INDEX `fk_ambiente_proposicao_proposicao1_idx` (`id_proposicao` ASC),
INDEX `fk_ambiente_proposicao_ambiente1_idx` (`id_ambiente` ASC),
CONSTRAINT `fk_ambiente_proposicao_ambiente1`
FOREIGN KEY (`id_ambiente`)
REFERENCES `espacopalavra`.`ambiente` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_ambiente_proposicao_proposicao1`
FOREIGN KEY (`id_proposicao`)
REFERENCES `espacopalavra`.`proposicao` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`passo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`passo` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_proposicao` INT UNSIGNED NOT NULL,
`posicao` TINYINT UNSIGNED NOT NULL,
`titulo` VARCHAR(100) NOT NULL,
`local` VARCHAR(100) NULL,
`duracao` TIME NOT NULL,
`materiais_necessarios` VARCHAR(100) NULL,
`texto` TEXT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_passo_proposicao1_idx` (`id_proposicao` ASC),
CONSTRAINT `fk_passo_proposicao1`
FOREIGN KEY (`id_proposicao`)
REFERENCES `espacopalavra`.`proposicao` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`comentario`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`comentario` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_usuario` INT UNSIGNED NOT NULL,
`id_proposicao` INT UNSIGNED NOT NULL,
`data_cadastro` DATETIME NOT NULL,
`comentario` TEXT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_comentario_usuario1_idx` (`id_usuario` ASC),
INDEX `fk_comentario_proposicao1_idx` (`id_proposicao` ASC),
CONSTRAINT `fk_comentario_usuario1`
FOREIGN KEY (`id_usuario`)
REFERENCES `espacopalavra`.`usuario` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_comentario_proposicao1`
FOREIGN KEY (`id_proposicao`)
REFERENCES `espacopalavra`.`proposicao` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`curtir`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`curtir` (
`id_proposicao` INT UNSIGNED NOT NULL,
`id_usuario` INT UNSIGNED NOT NULL,
`data_cadastro` DATETIME NOT NULL,
PRIMARY KEY (`id_proposicao`, `id_usuario`),
INDEX `fk_curtir_usuario1_idx` (`id_usuario` ASC),
CONSTRAINT `fk_curtir_proposicao1`
FOREIGN KEY (`id_proposicao`)
REFERENCES `espacopalavra`.`proposicao` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_curtir_usuario1`
FOREIGN KEY (`id_usuario`)
REFERENCES `espacopalavra`.`usuario` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`reset_senha`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`reset_senha` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_usuario` INT UNSIGNED NOT NULL,
`codigo` VARCHAR(255) NOT NULL,
`data_cadastro` DATETIME NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_reset_senha_usuario1_idx` (`id_usuario` ASC),
CONSTRAINT `fk_reset_senha_usuario1`
FOREIGN KEY (`id_usuario`)
REFERENCES `espacopalavra`.`usuario` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`seguir`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`seguir` (
`id_proposicao` INT UNSIGNED NOT NULL,
`id_usuario` INT UNSIGNED NOT NULL,
`data_cadastro` DATETIME NOT NULL,
PRIMARY KEY (`id_proposicao`, `id_usuario`),
INDEX `fk_seguir_usuario1_idx` (`id_usuario` ASC),
CONSTRAINT `fk_seguir_proposicao1`
FOREIGN KEY (`id_proposicao`)
REFERENCES `espacopalavra`.`proposicao` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_seguir_usuario1`
FOREIGN KEY (`id_usuario`)
REFERENCES `espacopalavra`.`usuario` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `espacopalavra`.`concluir`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `espacopalavra`.`concluir` (
`id_proposicao` INT UNSIGNED NOT NULL,
`id_usuario` INT UNSIGNED NOT NULL,
`data_cadastro` DATETIME NOT NULL,
PRIMARY KEY (`id_proposicao`, `id_usuario`),
INDEX `fk_concluir_usuario1_idx` (`id_usuario` ASC),
CONSTRAINT `fk_concluir_proposicao1`
FOREIGN KEY (`id_proposicao`)
REFERENCES `espacopalavra`.`proposicao` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_concluir_usuario1`
FOREIGN KEY (`id_usuario`)
REFERENCES `espacopalavra`.`usuario` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
-- -----------------------------------------------------
-- Data for table `espacopalavra`.`habilidade`
-- -----------------------------------------------------
START TRANSACTION;
USE `espacopalavra`;
INSERT INTO `espacopalavra`.`habilidade` (`id`, `descricao`) VALUES (1, 'Coesão e coerência');
INSERT INTO `espacopalavra`.`habilidade` (`id`, `descricao`) VALUES (2, 'Tempos verbais');
INSERT INTO `espacopalavra`.`habilidade` (`id`, `descricao`) VALUES (3, 'Revisão do texto');
INSERT INTO `espacopalavra`.`habilidade` (`id`, `descricao`) VALUES (4, 'Revisão e edição');
INSERT INTO `espacopalavra`.`habilidade` (`id`, `descricao`) VALUES (5, 'Vocabulário');
COMMIT;
-- -----------------------------------------------------
-- Data for table `espacopalavra`.`ambiente`
-- -----------------------------------------------------
START TRANSACTION;
USE `espacopalavra`;
INSERT INTO `espacopalavra`.`ambiente` (`id`, `descricao`) VALUES (1, 'Espaço aberto');
INSERT INTO `espacopalavra`.`ambiente` (`id`, `descricao`) VALUES (2, 'Sala de aula');
COMMIT;
-- -----------------------------------------------------
-- Data for table `espacopalavra`.`recurso`
-- -----------------------------------------------------
START TRANSACTION;
USE `espacopalavra`;
INSERT INTO `espacopalavra`.`recurso` (`id`, `descricao`) VALUES (1, 'Um computador');
INSERT INTO `espacopalavra`.`recurso` (`id`, `descricao`) VALUES (2, 'Um computador por aluno');
INSERT INTO `espacopalavra`.`recurso` (`id`, `descricao`) VALUES (3, 'Papelaria');
INSERT INTO `espacopalavra`.`recurso` (`id`, `descricao`) VALUES (4, 'Projetor');
INSERT INTO `espacopalavra`.`recurso` (`id`, `descricao`) VALUES (5, 'Celulares com internet');
COMMIT;
-- -----------------------------------------------------
-- Data for table `espacopalavra`.`tamanho_turma`
-- -----------------------------------------------------
START TRANSACTION;
USE `espacopalavra`;
INSERT INTO `espacopalavra`.`tamanho_turma` (`id`, `descricao`) VALUES (1, '-5');
INSERT INTO `espacopalavra`.`tamanho_turma` (`id`, `descricao`) VALUES (2, '-10');
INSERT INTO `espacopalavra`.`tamanho_turma` (`id`, `descricao`) VALUES (3, '-15');
INSERT INTO `espacopalavra`.`tamanho_turma` (`id`, `descricao`) VALUES (4, '-20');
INSERT INTO `espacopalavra`.`tamanho_turma` (`id`, `descricao`) VALUES (5, '-30');
INSERT INTO `espacopalavra`.`tamanho_turma` (`id`, `descricao`) VALUES (6, '+30');
COMMIT;
| true |
cd2b6df7ea615a7424c43107feca0724189352b6 | SQL | TheGhostGroup/DynastyCore | /sql/updates/world/0001_cleanup_firestorm.sql | UTF-8 | 2,449 | 3.28125 | 3 | [] | no_license | -- Removing custom firestorm creatures
-- Cleanup loyalty npc, transmog npc and exp rate modifier npc
DELETE FROM creature WHERE id IN (SELECT entry FROM creature_template WHERE scriptname IN ('npc_loyalty_point','npc_legendary_transmogrificator','npc_rate_xp_modifier'));
-- delete creatures on GM island
DELETE FROM creature WHERE id IN (370048);
DELETE FROM creature where map=1 AND zoneid=876;
-- Removing custom firestorm gobject spawns based on phasemask and map, zone combination
-- select for zones
-- select * from gameobject where
-- map = 0 and zoneid = 11 and areaid=11;
-- map = 0 and zoneid = 139 and areaid=139;
-- map = 0 and zoneid = 214 and areaid=214;
-- map = 0 and zoneid = 2037 and areaid=2037;
-- map = 1 and zoneid = 0 and areaid=0;
-- map = 1 and zoneid = 876 and areaid=876;
-- map = 530 and zoneid = 0 and areaid=0;
-- map = 646 and zoneid = 0 and areaid=0;
-- map = 646 and zoneid = 5042 and areaid=5042;
-- map = 648 and zoneid = 4737 and areaid=4737;
-- map = 861 and zoneid = 5733 and areaid=5817;
-- delete query
DELETE FROM gameobject WHERE phasemask=4294967295 AND map < 1000 AND map NOT IN (654,720,730,860,870) AND id NOT IN (180751,18890,189990,202747,202748,233600,194264,183323,10227833,243477) ORDER BY map,zoneid;
DELETE FROM gameobject WHERE phasemask=1 AND map=0 AND zoneid=139 AND areaid=139 AND guid BETWEEN 50000000 AND 79999999;
DELETE FROM gameobject WHERE phasemask=1 AND map=0 AND zoneid=214 AND areaid=214 AND guid BETWEEN 50000000 AND 79999999;
DELETE FROM gameobject WHERE phasemask=1 AND map=0 AND zoneid=2037 AND areaid=2037 AND guid BETWEEN 50000000 AND 79999999;
DELETE FROM gameobject WHERE phasemask=1 AND map=1 AND zoneid=0 AND areaid=0 AND guid BETWEEN 30000000 AND 79999999;
DELETE FROM gameobject WHERE map=1 AND zoneid=876 AND areaid=876;
DELETE FROM gameobject WHERE phasemask=65535 AND map=646 AND zoneid=5042 AND areaid=5042 AND guid BETWEEN 4000000 AND 79999999;
DELETE FROM gameobject WHERE phasemask=1 AND map=648 AND zoneid=4737 AND areaid=4737 AND guid BETWEEN 50000000 AND 79999999;
DELETE FROM gameobject WHERE phasemask=1 AND map=861 AND zoneid=5733 AND guid BETWEEN 50000000 AND 79999999;
-- commands reset for our server
-- command
update command set security=3 where security <>3;
-- commands players
update command set security=0 where name in
("account","account lock","account set password","commands","dismount","gm ingame","help","save","server","server info"); | true |
e053a02b3d3e866b810ca9aaec88c474cf644f2c | SQL | noikiy/sc-project | /chuangying/shihua/protected/modules/market/install/market_2015_09_09.sql | UTF-8 | 2,012 | 3.53125 | 4 | [] | no_license | /*邀请码表*/
CREATE TABLE `cyShihuaInviteCode` (
`shihuaInviteCodeId` int(10) NOT NULL AUTO_INCREMENT COMMENT 'id',
`inviteCode` varchar(10) NOT NULL DEFAULT '' COMMENT '邀请码',
`isUsed` tinyint(4) NOT NULL DEFAULT 0 COMMENT '本条邀请码是否被使用 0:否 1:是',
`status` tinyint(4) NOT NULL DEFAULT 0,
`addTime` timestamp DEFAULT '0000-00-00 00:00:00',
`modTime` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`shihuaInviteCodeId`),
UNIQUE KEY (`inviteCode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '邀请码表';
/*用户和注册所使用的邀请码关联表*/
CREATE TABLE `cyShihuaUserInviteCode` (
`shihuaUserInviteCodeId` int(10) NOT NULL AUTO_INCREMENT COMMENT 'id',
`userId` int(10) NOT NULL DEFAULT 0 COMMENT '用户id',
`mob` varchar(63) NOT NULL DEFAULT '' COMMENT '用户手机',
`inviteCode` varchar(10) NOT NULL DEFAULT '' COMMENT '邀请码',
`inviteUserId` int(10) NOT NULL DEFAULT 0 COMMENT '邀请人的用户id',
`inviteUserName` varchar(255) NOT NULL DEFAULT '' COMMENT '邀请人的名字',
`inviteShopId` int(10) NOT NULL DEFAULT 0 COMMENT '邀请人的店铺id',
`inviteShopName` varchar(255) NOT NULL DEFAULT '' COMMENT '邀请人店铺名称',
`inviteCityCode` int(10) NOT NULL DEFAULT 0 COMMENT '邀请人区域代码',
`inviteCityName` varchar(63) NOT NULL DEFAULT '' COMMENT '邀请人城市名称',
`status` tinyint(4) NOT NULL DEFAULT 0,
`addTime` timestamp DEFAULT '0000-00-00 00:00:00',
`modTime` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`shihuaUserInviteCodeId`),
UNIQUE KEY (`userId`),
KEY (`inviteUserId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '用户和注册所使用的邀请码关联表';
/*给cyUserDevice表增加邀请码字段*/
ALTER TABLE `cyUserDevice` ADD COLUMN `inviteCode` varchar(10) NOT NULL DEFAULT '' COMMENT '邀请码';
| true |
17f41bb9e4adab63c1e95198e764f7ce7aa4ac8c | SQL | KhaledNouiraa/KhaledNouiraProjet | /Practical_Exercice/DataBase/buildstore_1_.sql | UTF-8 | 4,083 | 3.25 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Nov 13, 2020 at 10:47 AM
-- Server version: 10.4.13-MariaDB
-- PHP Version: 7.2.31
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: `buildstore(1)`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE `admin` (
`id_admin` int(11) NOT NULL,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `book`
--
CREATE TABLE `book` (
`id_book` int(11) NOT NULL,
`title_book` varchar(50) DEFAULT NULL,
`author_book` varchar(50) DEFAULT NULL,
`price_book` double DEFAULT NULL,
`releaseDate_book` date DEFAULT NULL,
`quantity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `book`
--
INSERT INTO `book` (`id_book`, `title_book`, `author_book`, `price_book`, `releaseDate_book`, `quantity`) VALUES
(5, 'JAVA', 'Malek BEN SALEM', 26.3, '2020-11-13', 99992);
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`id_orders` int(11) NOT NULL,
`id_user` int(11) NOT NULL,
`date_orders` date NOT NULL,
`total_orders` double NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `orders`
--
INSERT INTO `orders` (`id_orders`, `id_user`, `date_orders`, `total_orders`) VALUES
(1, 0, '2020-11-13', 0),
(3, 6, '2020-11-13', 263);
-- --------------------------------------------------------
--
-- Table structure for table `order_lines`
--
CREATE TABLE `order_lines` (
`id_line` int(11) NOT NULL,
`price` double NOT NULL,
`quantity` int(11) NOT NULL,
`id_order` int(11) NOT NULL,
`id_book` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`id_user` int(11) NOT NULL,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`id_user`, `first_name`, `last_name`, `username`, `password`) VALUES
(6, 'Etudiant', 'Polytech', 'polyUser', '****');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id_admin`);
--
-- Indexes for table `book`
--
ALTER TABLE `book`
ADD PRIMARY KEY (`id_book`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`id_orders`);
--
-- Indexes for table `order_lines`
--
ALTER TABLE `order_lines`
ADD PRIMARY KEY (`id_line`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id_user`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `id_admin` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `book`
--
ALTER TABLE `book`
MODIFY `id_book` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `order_lines`
--
ALTER TABLE `order_lines`
MODIFY `id_line` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `id_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36;
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 |
868cd70b7a00684a0c3e7aaeb92ceef3249f2f26 | SQL | vattikuti/assignment4 | /anudeep lab 4.sql | UTF-8 | 2,728 | 3.734375 | 4 | [] | no_license | -- lab-4 name:Anudeep vattikuti cwid:200 53 275 date:2/14/2014--
--1.get the cities of agents booking an order for customers 'basics'
select city
from agents
where aid in ( select aid
from orders
where cid in( select cid
from customers
where name= 'Basics'))
--2.Get the pid of products ordered through any agent who makes at least one order for a customer in kyoto--
select distinct pid
from orders
where aid in( select aid
from orders
where cid in( select cid
from customers
where city='Kyoto'))
order by pid asc
--3.Find the cids and names of customers who never placed an order through agent a03--
select cid ,name
from customers
where cid not in( select cid
from orders
where aid ='a03')
--4.Get the cids and names of customers who ordered both product p01 and p07 --
select cid,name
from customers
where cid in(select cid
from orders
where pid in('p01','p07'))
order by cid asc
--5.Get the pids of products ordered by any customers who ever placed an order through agent a03--
select distinct pid
from orders
where cid in(select cid
from orders
where aid='a03')
order by pid asc
--6.Get the names and discounts of all customers who place orders through agents in dallas or duluth--
select name,discount
from customers
where cid in(select cid
from orders
where aid in(select aid
from Agents
where city in('Dallas','Duluth')))
--7.. Find all customers who have the same discount as that of any customers in Dallas or Kyoto
select *
from customers
where discount in( select discount
from customers
where city not in('Dallas','Kyoto'))
and discount in (select discount
from customers
where city in('Dallas','Kyoto'))
and city not in ('Dallas','Kyoto')
| true |
5cd4d6ba06ffd8e6d6ddebdb8d0bd5e977a0512e | SQL | tghjkl777/oracle_sql_practice | /hr_quiz.sql | UHC | 6,374 | 4.4375 | 4 | [] | no_license | /*hr Quiz 1*/
/*https://carami.tistory.com/116?category=552237*/
select * from tab;
select * from employees;
desc employees
select * from dept;
select * from dept;
select * from jobs;
desc emp
/*1.
--1. å(Job Title) Sales Manager Ի
Ի(hire_date) Ͻÿ.
-- Ͻÿ.
*/
select to_char(hire_date,'YY') as "HIRE_YEAR", avg(salary)
from employees
where job_id='SA_MAN'
group by to_char(hire_date,'YY')
order by to_char(hire_date,'YY');
SELECT TO_CHAR(e.HIRE_DATE, 'YYYY') AS HIRE_DATE, AVG(e.salary) AS AVG
FROM EMPLOYEES e, JOBS j
WHERE e.JOB_ID = j.JOB_ID AND j.JOB_TITLE = 'Sales Manager'
GROUP BY TO_CHAR(e.HIRE_DATE,'YYYY')
ORDER BY TO_CHAR(e.HIRE_DATE,'YYYY') ASC;
/*2
(city) ִ μ ձ ȸϰ Ѵ.
-- ձ ú ø(city)
տ, ش Ͻÿ.
-- , ÿ ϴ 10 ̻ ϰ ȸϽÿ.
*/
select city, avg(salary) as sal ,count(city)
from ( select * from employees e, departments d, locations l
where e.department_id=d.department_id and d.location_id=l.location_id)
group by city having count(city)<10
order by sal;
SELECT l.CITY , AVG(e.SALARY) , COUNT(*)
FROM EMPLOYEES e, LOCATIONS l, DEPARTMENTS d
WHERE e.DEPARTMENT_ID = d.DEPARTMENT_ID AND d.LOCATION_ID = l.LOCATION_ID
GROUP BY l.CITY
HAVING COUNT(*) < 10
ORDER BY AVG(e.SALARY) ASC;
/*3
Public Accountant å(job_title)
ſ ٹ ִ ̸ Ͻÿ.
-- ( Public Accountant å(job_title) ٹϴ ʴ´.)
-- ̸ first_name, last_name Ʒ Ѵ.
*/
select e.employee_id, first_name||' '||last_name NAME
from employees e, jobs j, job_history jh
where e.employee_id=jh.employee_id and jh.job_id=j.job_id
and j.job_title='Public Accountant';
/*4
ڽ Ŵ (salary)
(last_name) (salary) Ͻÿ.
*/
select e.last_name,e.salary
from employees e , employees m
where e.manager_id=m.employee_id
and e.salary>m.salary;
/*5
2007 Ի(hire_date) (employee_id),
̸(first_name), (last_name),
-- μ(department_name) ȸմϴ.
-- ̶, μ ġ , <Not Assigned> Ͻÿ.
*/
select employee_id, first_name,last_name, nvl(department_name,'<Not Assigned>')
from employees left outer join departments using(department_id)
where hire_date like '07%';
/*6
(job_title) Sales Representative ߿
(salary) 9,000̻, 10,000
-- ̸(first_name), (last_name) (salary) Ͻÿ*/
select first_name, last_name, salary
from employees e , jobs j
where e.job_id=j.job_id and
e.salary between 9000 and 10000
and j.job_title='Sales Representative';
/*7
μ ް ִ ̸, μ̸, Ͻÿ.
-- ̸ last_name ϸ, μ̸ ϰ,
-- μ ̸ Ͽ մϴ.
12 ; Ѵ.*/
select e.last_name, a.*
from employees e,(select department_id ,department_name , min(salary) mi
from employees natural join departments
group by department_id,department_name) a
where e.salary=a.mi
order by a.department_name;
select last_name, department_name, e.salary
from (select department_id, min(salary)
FROM employees GROUP BY department_id ) e natural join departments
order by department_name;
select last_name,
select department_id, min(salary)
FROM employees GROUP BY department_id;
/*8
EMPLOYEES ̺ ȸ ó
6° 10 °
-- 5 last_name, first_name, salary ȸϴ sql ۼϽÿ.*/
select last_name,first_name, salary
from(
select rank() over (order by salary desc) ranking,last_name,first_name, salary
from employees
order by salary desc)
where ranking between 6 and 10;
/*9 Ʋ!!!!
μ (city) Seattle ̸,
ش Ŵ ̸, μ̸ Ͻÿ.
-- ̶ Ŵ <>̶ Ͻÿ.
̸ last_name ϸ,
-- ̸ Ͻÿ
*/
select e.last_name,nvl(m.last_name,''),e.department_name
from(select e.employee_id, e.last_name, d.department_name,e.manager_id
from employees e, departments d ,locations l
where e.department_id=d.department_id and
d.location_id=l.location_id and l.city='Seattle') e, employees m
where e.manager_id=m.employee_id
;
SELECT
E.E_NAME, NVL(E.M_NAME, '<>'), D.DEPARTMENT_NAME
FROM
(
SELECT
A.LAST_NAME AS E_NAME, B.LAST_NAME AS M_NAME, A.DEPARTMENT_ID
FROM EMPLOYEES A
LEFT JOIN EMPLOYEES B
ON A.MANAGER_ID = B.EMPLOYEE_ID
) E, DEPARTMENTS D, LOCATIONS L
WHERE L.CITY = 'Seattle' AND E.DEPARTMENT_ID = D.DEPARTMENT_ID AND D.LOCATION_ID = L.LOCATION_ID
ORDER BY E.E_NAME ASC
;
/*10
(job) (salary) ϰ Ѵ.
-- (job_title) ȸϽÿ.
30,000 ū Ͻÿ.
*/
select job_title, sum(salary)
from employees natural join jobs
group by job_title having sum(salary)>30000
order by sum(salary) desc;
/*11
(employee) ؼ (employee_id), ̸(first_name),
(job_title),
-- μ (department_name) ȸϽÿ.
-- ø(city) Seattle (location)
μ (department) ٹϴ ȣ Ͻÿ.
*/
/*
select e.employee_id, e.first_name, j.job_title ,d.department_name
from
*/ | true |
9f91143fe2d73e0a1aab8072d94775828479eb98 | SQL | c-eng/holbertonschool-higher_level_programming | /0x0D-SQL_introduction/15-groups.sql | UTF-8 | 151 | 2.78125 | 3 | [] | no_license | -- Counts number of rectors with the same score in second_table
SELECT score,COUNT(*) as number FROM second_table GROUP BY score ORDER BY number DESC;
| true |
b8a7a8cef6772d0a5ba3b276e9fb704c6fa821f1 | SQL | concourse/concourse | /atc/db/migration/migrations/1579713200_alter_parent_id_constraint_on_volumes.down.sql | UTF-8 | 251 | 2.953125 | 3 | [
"CC-BY-NC-ND-2.0",
"Apache-2.0"
] | permissive |
ALTER TABLE volumes DROP CONSTRAINT volumes_parent_id_fkey;
ALTER TABLE ONLY volumes
ADD CONSTRAINT volumes_parent_id_fkey FOREIGN KEY (parent_id, parent_state) REFERENCES volumes(id, state) ON DELETE RESTRICT;
DROP INDEX missing_volumes_idx;
| true |
6f840cf5eea415e9119a49e399b743fb5c868420 | SQL | KZoneOfX/review | /documents/review.sql | UTF-8 | 8,380 | 3.546875 | 4 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50710
Source Host : localhost:53306
Source Database : review
Target Server Type : MYSQL
Target Server Version : 50710
File Encoding : 65001
Date: 2016-03-29 22:59:09
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for i_config
-- ----------------------------
DROP TABLE IF EXISTS `i_config`;
CREATE TABLE `i_config` (
`id` bigint(8) NOT NULL,
`config_name` varchar(32) DEFAULT NULL COMMENT '属性名称',
`config_sign` varchar(32) DEFAULT NULL COMMENT '属性 在系统中显示 标签',
`description` varchar(512) DEFAULT NULL COMMENT '对于属性的描述',
`state` int(2) DEFAULT NULL COMMENT '属性状态',
`config_type` varchar(32) DEFAULT NULL COMMENT '系统属性的类型',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统属性相关';
-- ----------------------------
-- Table structure for i_paper
-- ----------------------------
DROP TABLE IF EXISTS `i_paper`;
CREATE TABLE `i_paper` (
`id` bigint(16) NOT NULL AUTO_INCREMENT,
`paper_name` varchar(128) DEFAULT NULL COMMENT '论文 名称',
`paper_path` varchar(512) DEFAULT NULL COMMENT '论文文件 路径',
`paper_comment_path` varchar(512) DEFAULT NULL COMMENT '论文评论文件 路径',
`paper_result` varchar(128) DEFAULT NULL COMMENT '论文结果',
`paper_score` varchar(512) DEFAULT NULL COMMENT '论文成绩',
`paper_create_time` datetime DEFAULT NULL COMMENT '论文提交时间',
`paper_submit_person_id` bigint(16) NOT NULL COMMENT '论文提交人id',
`std_id` bigint(16) NOT NULL COMMENT '学生ID',
`state` INT(2) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统论文 表';
-- ----------------------------
-- Table structure for i_permission
-- ----------------------------
DROP TABLE IF EXISTS `i_permission`;
CREATE TABLE `i_permission` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '权限id',
`pid` BIGINT(20) DEFAULT NULL
COMMENT '权限父节点id',
`name` VARCHAR(32) DEFAULT NULL
COMMENT '权限名',
`permission_sign` varchar(128) DEFAULT NULL COMMENT '权限标识,程序中判断使用,如"user:create"',
`description` varchar(256) DEFAULT NULL COMMENT '权限描述,UI界面显示使用',
`url` VARCHAR(20) DEFAULT NULL
COMMENT '权限 路径',
`state` INT(2) DEFAULT NULL,
`is_parent` INT(2) DEFAULT NULL
COMMENT '是否为父节点',
PRIMARY KEY (`id`)
)
ENGINE = InnoDB
AUTO_INCREMENT = 35
DEFAULT CHARSET = utf8
COMMENT = '权限表';
-- ----------------------------
-- Table structure for i_role
-- ----------------------------
DROP TABLE IF EXISTS `i_role`;
CREATE TABLE `i_role` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '角色id',
`role_name` varchar(32) DEFAULT NULL COMMENT '角色名',
`role_sign` varchar(128) DEFAULT NULL COMMENT '角色标识,程序中判断使用,如"admin"',
`description` varchar(256) DEFAULT NULL COMMENT '角色描述,UI界面显示使用',
`state` INT(2) DEFAULT NULL,
PRIMARY KEY (`id`)
)
ENGINE = InnoDB
AUTO_INCREMENT = 6
DEFAULT CHARSET = utf8
COMMENT = '角色表';
-- ----------------------------
-- Table structure for i_role_permission
-- ----------------------------
DROP TABLE IF EXISTS `i_role_permission`;
CREATE TABLE `i_role_permission` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表id',
`role_id` bigint(20) unsigned DEFAULT NULL COMMENT '角色id',
`permission_id` bigint(20) unsigned DEFAULT NULL COMMENT '权限id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='角色与权限关联表';
-- ----------------------------
-- Table structure for i_tch_paper
-- ----------------------------
DROP TABLE IF EXISTS `i_tch_paper`;
CREATE TABLE `i_tch_paper` (
`id` bigint(16) NOT NULL AUTO_INCREMENT,
`tch_id` bigint(16) DEFAULT NULL,
`paper_id` bigint(16) DEFAULT NULL,
`tch_paper_status` varchar(128) CHARACTER SET gbk DEFAULT NULL,
`tch_paper_result` varchar(128) CHARACTER SET gbk DEFAULT NULL,
`tch_paper_comment` text CHARACTER SET gbk,
`tch_review_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for i_user
-- ----------------------------
DROP TABLE IF EXISTS `i_user`;
CREATE TABLE `i_user` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户id',
`username` VARCHAR(50) NOT NULL
COMMENT '用户名 学生学号、教学工号、管理员工号',
`password` CHAR(64) NOT NULL
COMMENT '密码',
`state` INT(1) NOT NULL
COMMENT '状态 0账号已被删除,1账号正在使用',
PRIMARY KEY (`id`)
)
ENGINE = InnoDB
AUTO_INCREMENT = 3
DEFAULT CHARSET = utf8
COMMENT = '用户表';
-- ----------------------------
-- Table structure for i_user_info
-- ----------------------------
DROP TABLE IF EXISTS `i_user_info`;
CREATE TABLE `i_user_info` (
`user_id` BIGINT(16) UNSIGNED NOT NULL AUTO_INCREMENT
COMMENT '用户id',
`real_name` varchar(32) DEFAULT NULL COMMENT '真实姓名 学生姓名、教师姓名、管理员名称',
`place` varchar(16) DEFAULT NULL COMMENT '所属教学点',
`email` varchar(32) DEFAULT NULL COMMENT '邮件',
`phone` varchar(16) DEFAULT NULL COMMENT '手机号',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`create_person_id` BIGINT(16) DEFAULT NULL
COMMENT '创建账号 管理员的ID',
`last_login_time` datetime DEFAULT NULL COMMENT '最后登陆时间',
`stu_review_no` varchar(16) DEFAULT NULL COMMENT '学生盲评编号',
`stu_paper_status` int(1) DEFAULT NULL COMMENT '学生论文 状态 0未提交,1已提交第一次提交,2已提交第二次提交',
`stu_paper_submit_time_start` datetime DEFAULT NULL COMMENT '学生 论文提交时间',
`stu_paper_submit_time_over` datetime DEFAULT NULL COMMENT '学生 论文提交结束时间',
`stu_tch_id` bigint(16) DEFAULT NULL COMMENT '学生的 指导教师Id',
`std_admin_id` bigint(16) DEFAULT NULL COMMENT '学生的 管理员Id',
`tch_job_title` varchar(16) DEFAULT NULL COMMENT '教师职称',
`tch_department` varchar(32) DEFAULT NULL COMMENT '教师 所属研究所',
`tch_office_phone` varchar(16) DEFAULT NULL COMMENT '教室 办公室电话',
`tch_work_place` varchar(32) DEFAULT NULL COMMENT '教师 所属 教学点',
`tch_paper_review_time_start` datetime DEFAULT NULL COMMENT '教师 评审论文开始时间',
`tch_paper_review_time_over` datetime DEFAULT NULL COMMENT '教师 评审论文开始时间',
PRIMARY KEY (`user_id`)
)
ENGINE = InnoDB
AUTO_INCREMENT = 3
DEFAULT CHARSET = utf8
ROW_FORMAT = DYNAMIC
COMMENT = '用户表';
-- ----------------------------
-- Table structure for i_user_role
-- ----------------------------
DROP TABLE IF EXISTS `i_user_role`;
CREATE TABLE `i_user_role` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表id',
`user_id` bigint(20) unsigned DEFAULT NULL COMMENT '用户id',
`role_id` bigint(20) unsigned DEFAULT NULL COMMENT '角色id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='用户与角色关联表';
| true |
32ec2f6251ef20d46c48d16b12320a8523990688 | SQL | pipepi/gta | /src/db/ddl_t_task.sql | UTF-8 | 319 | 3.515625 | 4 | [
"Apache-2.0"
] | permissive | create table t_task
(
id int auto_increment comment '任务ID'
primary key,
parent_id int null comment '父任务ID',
name varchar(50) null comment '任务名称',
content varchar(1024) null comment '任务描述'
)
comment '任务表' engine=InnoDB
;
create index t_task_parent_id_index
on t_task (parent_id)
; | true |
560fe464316c15c9061511735154d19bd8850210 | SQL | GaryYinCode/shipment-management | /src/main/resources/scripts/db/schema.sql | UTF-8 | 1,329 | 3.59375 | 4 | [] | no_license | DROP TABLE IF EXISTS TRADE;
CREATE TABLE TRADE
(
ID VARCHAR(36) NOT NULL COMMENT 'id, PK',
TITLE VARCHAR(128) NULL COMMENT 'title',
QUANTITY INT(11) NOT NULL DEFAULT 0 COMMENT 'quantity',
CREATEDATE TIMESTAMP(6) NULL DEFAULT CURRENT_TIMESTAMP(6) COMMENT 'create date',
CREATEUSERID VARCHAR(36) NULL COMMENT 'create user id',
CREATEIP VARCHAR(16) NULL COMMENT 'create ip',
PRIMARY KEY (ID)
);
DROP TABLE IF EXISTS SHIPMENT;
CREATE TABLE SHIPMENT
(
ID VARCHAR(36) NOT NULL COMMENT 'id, PK',
TRADEID VARCHAR(36) NOT NULL COMMENT 'trade id',
TYPE INT NULL DEFAULT 1 COMMENT 'shipment type: 1=root, 2=split, 3=merge.',
SPLITID VARCHAR(36) NULL COMMENT 'the id which the shipment was split from',
OPERATETYPE INT NULL DEFAULT 0 COMMENT 'operate type: 0=none, 1=split, 2=merged.',
MERGEDID VARCHAR(36) NULL COMMENT 'the id which the shipment was merged to',
QUANTITY INT(11) NOT NULL DEFAULT 0 COMMENT 'quantity',
CREATEDATE TIMESTAMP(6) NULL DEFAULT CURRENT_TIMESTAMP(6) COMMENT 'create date',
CREATEUSERID VARCHAR(36) NULL COMMENT 'create user id',
CREATEIP VARCHAR(16) NULL COMMENT 'create ip',
PRIMARY KEY (ID)
);
CREATE INDEX IDX_SHIPMENT_TRADEID ON SHIPMENT (TRADEID);
| true |
2418685eacb114a93b576c48e7b92fccb078d3fe | SQL | Axita31/NoteMarketPlaceHTML | /MVC/notesmarketplace.sql | UTF-8 | 35,069 | 3.265625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 03, 2021 at 07:44 PM
-- Server version: 10.4.17-MariaDB
-- PHP Version: 7.4.15
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: `notesmarketplace`
--
-- --------------------------------------------------------
--
-- Table structure for table `category`
--
CREATE TABLE `category` (
`ID` int(10) UNSIGNED NOT NULL,
`Category_name` varchar(34) NOT NULL,
`Description` varchar(500) NOT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `category`
--
INSERT INTO `category` (`ID`, `Category_name`, `Description`, `CreatedDate`, `CreatedBy`, `ModifiedDate`, `ModifiedBy`, `IsActive`) VALUES
(1, 'PDF(Digital)', 'Notes in pdf formate', '2021-03-23 15:26:51', NULL, NULL, NULL, b'1'),
(2, 'scanned', 'Scanned notes', '2021-03-23 15:26:51', NULL, NULL, NULL, b'1'),
(3, 'Hard copy', 'hard copy notes', '2021-03-23 15:29:38', NULL, NULL, NULL, b'1'),
(4, 'Hand-Writing', 'Handwriiten notes', '2021-03-23 15:29:38', NULL, NULL, NULL, b'1');
-- --------------------------------------------------------
--
-- Table structure for table `country`
--
CREATE TABLE `country` (
`ID` int(10) UNSIGNED NOT NULL,
`Country_Name` varchar(34) NOT NULL,
`Country_Code` varchar(50) NOT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `country`
--
INSERT INTO `country` (`ID`, `Country_Name`, `Country_Code`, `CreatedDate`, `CreatedBy`, `ModifiedDate`, `ModifiedBy`, `IsActive`) VALUES
(1, 'Australia', '61', '2021-03-23 15:36:41', NULL, NULL, NULL, b'1'),
(2, 'China', '86', '2021-03-23 15:36:41', NULL, NULL, NULL, b'1'),
(3, 'Canada', '1', '2021-03-23 15:40:48', NULL, NULL, NULL, b'1'),
(4, 'Germany', '49', '2021-03-23 15:40:48', NULL, NULL, NULL, b'1'),
(5, 'India', '91', '2021-03-23 15:42:38', NULL, NULL, NULL, b'1'),
(6, 'Japan', '81', '2021-03-23 15:43:10', NULL, NULL, NULL, b'1'),
(7, 'Pakistan', '92', '2021-03-23 15:43:10', NULL, NULL, NULL, b'1'),
(8, 'USA', '1', '2021-03-23 15:46:12', NULL, NULL, NULL, b'1'),
(9, 'United Kingdom', '44', '2021-03-23 15:46:12', NULL, NULL, NULL, b'1');
-- --------------------------------------------------------
--
-- Table structure for table `downloads`
--
CREATE TABLE `downloads` (
`ID` int(10) UNSIGNED NOT NULL,
`NoteID` int(10) UNSIGNED NOT NULL,
`SellerID` int(10) UNSIGNED NOT NULL,
`DownloaderID` int(10) UNSIGNED NOT NULL,
`IsSellerHasAllowedDownload` bit(1) NOT NULL,
`AttachmentPath` varchar(500) DEFAULT NULL,
`IsAttachmentDownloaded` bit(1) NOT NULL,
`AttachmentDownloadedDate` datetime DEFAULT NULL,
`IsPaid` int(11) UNSIGNED NOT NULL,
`PurchasedPrice` decimal(10,0) DEFAULT NULL,
`NoteTitle` varchar(100) NOT NULL,
`NoteCategory` varchar(100) NOT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `downloads`
--
INSERT INTO `downloads` (`ID`, `NoteID`, `SellerID`, `DownloaderID`, `IsSellerHasAllowedDownload`, `AttachmentPath`, `IsAttachmentDownloaded`, `AttachmentDownloadedDate`, `IsPaid`, `PurchasedPrice`, `NoteTitle`, `NoteCategory`, `CreatedDate`, `CreatedBy`, `ModifiedDate`, `ModifiedBy`) VALUES
(1, 11, 1, 1, b'1', NULL, b'1', '2021-04-01 16:25:02', 4, '126', 'Data Science', 'PDF', '2021-04-01 16:25:02', NULL, NULL, NULL),
(2, 12, 1, 1, b'1', NULL, b'1', '2021-04-02 16:29:47', 5, '150', 'History', 'social', '2021-04-01 16:29:47', NULL, NULL, NULL),
(3, 13, 3, 3, b'1', NULL, b'1', '2021-04-02 16:54:32', 4, '100', 'DCDR', 'PDF', '2021-04-02 16:54:32', NULL, NULL, NULL),
(4, 15, 3, 1, b'1', NULL, b'1', '2021-04-02 16:54:32', 5, '99', 'Data Science', 'Scanner', '2021-04-01 16:54:32', NULL, NULL, NULL),
(5, 16, 1, 3, b'1', NULL, b'1', '2021-04-01 16:25:02', 5, '200', 'AI', 'IT', '2021-04-01 17:05:10', NULL, NULL, NULL),
(6, 17, 1, 3, b'1', NULL, b'1', '2021-04-01 17:05:10', 4, '210', 'Python', 'hard copy', '2021-04-01 17:05:10', NULL, NULL, NULL),
(7, 18, 3, 1, b'1', NULL, b'1', '2021-04-01 17:11:13', 4, '105', 'web technology', 'pDF', '2021-04-02 17:11:13', NULL, NULL, NULL),
(8, 19, 1, 3, b'1', NULL, b'1', '2021-04-02 17:11:13', 5, '180', 'Java', 'Hand-written', '2021-04-02 17:11:13', NULL, NULL, NULL),
(9, 20, 3, 1, b'1', NULL, b'1', '2021-04-02 17:18:34', 5, '98', 'AI', 'PDF', '2021-04-01 17:18:34', NULL, NULL, NULL),
(10, 21, 3, 1, b'1', NULL, b'1', '2021-04-02 17:18:34', 5, '149', 'CA', 'Social', '2021-04-02 17:18:34', NULL, NULL, NULL),
(11, 22, 1, 3, b'1', NULL, b'1', '2021-04-03 17:26:47', 5, '170', 'AI', 'Computer', '2021-04-02 17:26:47', NULL, NULL, NULL),
(12, 24, 1, 3, b'1', NULL, b'1', '2021-04-02 17:26:47', 4, '139', 'Python', 'Scanned', '2021-04-02 17:26:47', NULL, NULL, NULL),
(13, 26, 3, 1, b'1', NULL, b'1', '2021-04-02 17:18:34', 5, '105', 'Database Management', 'Manage', '2021-04-02 17:36:59', NULL, NULL, NULL),
(15, 26, 3, 1, b'1', NULL, b'1', '2021-04-02 17:18:34', 5, '105', 'Database Management', 'Manage', '2021-04-02 17:36:59', NULL, NULL, NULL),
(17, 27, 1, 3, b'1', NULL, b'1', '2021-04-01 17:11:13', 4, '120', 'AI', 'IT', '2021-03-17 21:54:22', NULL, NULL, NULL),
(18, 28, 1, 3, b'1', NULL, b'1', '2021-04-02 20:06:31', 4, '136', 'Python', 'IT', '2021-03-23 15:40:48', NULL, NULL, NULL),
(19, 29, 3, 1, b'1', NULL, b'1', '2021-04-01 16:25:02', 5, '126', 'maths', 'IT', '2021-03-26 10:52:57', NULL, NULL, NULL),
(20, 32, 1, 3, b'1', NULL, b'1', '2021-04-01 20:08:01', 5, '99', 'english', 'eng', '2021-03-23 15:43:10', NULL, NULL, NULL),
(21, 33, 3, 1, b'1', NULL, b'1', '2021-04-01 16:25:02', 5, '250', 'Basic elecronics', 'IT', '2021-03-17 21:54:22', NULL, NULL, NULL),
(22, 34, 1, 3, b'1', NULL, b'1', '2021-04-02 16:54:32', 4, '180', 'C++', 'CE', '2021-03-23 15:29:38', NULL, NULL, NULL),
(23, 35, 3, 1, b'1', NULL, b'1', '2021-04-01 16:25:02', 4, '150', 'Operating system', 'CE', '2021-03-26 10:52:57', NULL, NULL, NULL),
(24, 36, 1, 3, b'1', NULL, b'1', '2021-04-01 17:05:10', 5, '225', 'Java', 'IT', '2021-04-01 20:12:27', NULL, NULL, NULL),
(25, 37, 1, 3, b'1', NULL, b'1', '2021-04-02 16:29:47', 5, '150', 'Co', 'CE', '2021-03-17 20:44:53', NULL, NULL, NULL),
(26, 38, 3, 1, b'1', NULL, b'1', '2021-04-02 17:11:13', 4, '136', 'MCWC', 'IT', '2021-03-23 15:36:41', NULL, NULL, NULL),
(27, 39, 3, 1, b'1', NULL, b'1', '2021-04-03 17:26:47', 5, '105', 'DDBMS', 'CE', '2021-03-17 21:54:22', NULL, NULL, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `notes`
--
CREATE TABLE `notes` (
`ID` int(10) UNSIGNED NOT NULL,
`SellerID` int(11) UNSIGNED NOT NULL,
`Status` int(11) UNSIGNED NOT NULL,
`Actioned_By` int(11) UNSIGNED DEFAULT NULL,
`Admin_Remarks` varchar(500) DEFAULT NULL,
`PublishedDate` datetime DEFAULT NULL,
`Note_Title` varchar(100) NOT NULL,
`Category` int(11) UNSIGNED NOT NULL,
`Note_Display_Picture` varchar(500) DEFAULT NULL,
`Note_types` int(10) UNSIGNED DEFAULT NULL,
`Note_Pages` smallint(6) DEFAULT NULL,
`Description` varchar(500) DEFAULT NULL,
`University` varchar(100) NOT NULL,
`Country` int(10) UNSIGNED NOT NULL,
`Course` varchar(100) NOT NULL,
`Course_Code` varchar(50) NOT NULL,
`Professor_Name` varchar(100) NOT NULL,
`Is_Paid` int(10) UNSIGNED NOT NULL,
`Price` decimal(10,0) DEFAULT NULL,
`NotesPreview` varchar(255) DEFAULT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `notes`
--
INSERT INTO `notes` (`ID`, `SellerID`, `Status`, `Actioned_By`, `Admin_Remarks`, `PublishedDate`, `Note_Title`, `Category`, `Note_Display_Picture`, `Note_types`, `Note_Pages`, `Description`, `University`, `Country`, `Course`, `Course_Code`, `Professor_Name`, `Is_Paid`, `Price`, `NotesPreview`, `CreatedDate`, `CreatedBy`, `ModifiedDate`, `ModifiedBy`, `IsActive`) VALUES
(11, 1, 8, NULL, NULL, '2021-04-02 10:05:19', 'science', 2, '../Members/default/note-default.jpg', 2, 250, 'jwrghurh', 'dmdvjtsgrb', 8, 'IT', '16', 'zenif', 4, '500', '../Members/1/11/Preview_1617347963.jpg', '2021-04-02 12:49:23', 1, '2021-04-02 12:49:23', 1, b'1'),
(12, 1, 6, NULL, NULL, '2021-04-02 10:05:32', 'Data Science', 3, '../Members/1/12/DP_1617348350.jpg', 1, 200, 'data science peper solution', 'gec', 5, 'it', '16', 'janak', 5, '200', '../Members/1/12/Preview_1617348350.jpg', '2021-04-02 12:55:50', 1, '2021-04-02 12:55:50', 1, b'1'),
(13, 1, 8, NULL, NULL, '2021-04-02 10:05:37', 'basic elecronics', 3, '../Members/1/13/DP_1617352461.jpg', 2, 250, 'basic elecronics reference book', 'Sal institute', 5, 'IT', '16', 'saurabh sukla', 5, '100', '../Members/1/13/Preview_1617352461.jpg', '2021-04-02 14:04:21', 1, '2021-04-02 14:04:21', 1, b'1'),
(15, 1, 6, NULL, NULL, '2021-04-01 10:05:47', 'Data Science', 1, '../Members/1/15/DP_1617371273.jpg', 1, 250, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque voluptatum sit, iusto temporibus ipsam. Nesciunt earum ipsam error, aut vitae molestiae sit.', 'University of California', 8, 'Computer Engineering', '240520', 'Mr rechard brown', 4, '200', '../Members/1/15/Preview_1617371273.png', '2021-04-02 19:17:53', 1, '2021-04-02 19:17:53', 1, b'1'),
(16, 1, 9, NULL, NULL, '2021-04-03 10:05:56', 'Computer Operating System - Final Exam Book With Paper Solution', 2, '../Members/1/16/DP_1617371450.jpg', 2, 300, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque voluptatum sit, iusto temporibus ipsam. Nesciunt earum ipsam error, aut vitae molestiae sit.', 'University of California', 8, 'IT', '16', 'saurabh sukla', 4, '300', '../Members/1/16/Preview_1617371451.png', '2021-04-02 19:20:50', 1, '2021-04-02 19:20:50', 1, b'1'),
(17, 1, 8, NULL, NULL, '2021-04-03 10:06:04', 'Computer Science - The complete reference', 3, '../Members/1/17/DP_1617371613.jpg', 1, 350, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque voluptatum sit, iusto temporibus ipsam. Nesciunt earum ipsam error, aut vitae molestiae sit.', 'University of Australia', 1, 'Computer Engineering', '240520', 'Miss Zenif shah', 5, '410', '../Members/1/17/Preview_1617371613.png', '2021-04-02 19:23:33', 1, '2021-04-02 19:23:33', 1, b'1'),
(18, 1, 8, NULL, NULL, '2021-04-03 10:06:09', 'Basic Computer Engineering Tech India Publication Series', 4, '../Members/1/18/DP_1617371794.jpg', 1, 350, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque voluptatum sit, iusto temporibus ipsam. Nesciunt earum ipsam error, aut vitae molestiae sit.', 'University of Chine', 2, 'MBA', '213050', 'Mr arjun brown', 5, '230', '../Members/1/18/Preview_1617371794.png', '2021-04-02 19:26:33', 1, '2021-04-02 19:26:33', 1, b'1'),
(19, 1, 8, NULL, NULL, '2021-04-03 10:06:13', 'Computer Science - The complete reference - Seventh Edition', 1, '../Members/1/19/DP_1617371917.jpg', 1, 450, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque voluptatum sit, iusto temporibus ipsam. Nesciunt earum ipsam error, aut vitae molestiae sit.', 'University of Germany', 4, 'MCA', '215061', 'Miss Khyati shah', 4, '500', '../Members/1/19/Preview_1617371917.png', '2021-04-02 19:28:37', 1, '2021-04-02 19:28:37', 1, b'1'),
(20, 1, 8, NULL, NULL, '2021-04-03 10:06:20', 'Computer Operating System - Final Exam Book With Paper Solution', 2, '../Members/1/20/DP_1617372067.jpg', 2, 300, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque voluptatum sit, iusto temporibus ipsam. Nesciunt earum ipsam error, aut vitae molestiae sit.', 'University of India', 5, 'Computer Engineering', '240520', 'Miss Axita Khunt', 4, '100', '../Members/1/20/Preview_1617372068.png', '2021-04-02 19:31:07', 1, '2021-04-02 19:31:07', 1, b'1'),
(21, 1, 8, NULL, NULL, '2021-04-03 10:06:24', 'Computer Science - The complete reference', 3, '../Members/1/21/DP_1617372309.jpg', 2, 250, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque voluptatum sit, iusto temporibus ipsam. Nesciunt earum ipsam error, aut vitae molestiae sit.', 'University of Japan', 6, 'MBA', '213050', 'Miss kasi shah', 4, '410', '../Members/1/21/Preview_1617372310.png', '2021-04-02 19:35:09', 1, '2021-04-02 19:35:09', 1, b'1'),
(22, 1, 9, NULL, NULL, '2021-04-03 10:06:27', 'Basic Computer Engineering Tech India Publication Series', 4, '../Members/1/22/DP_1617372472.jpg', 1, 450, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque voluptatum sit, iusto temporibus ipsam. Nesciunt earum ipsam error, aut vitae molestiae sit.', 'Sal institute', 7, 'MCA', '215061', 'Miss Aditi bhatiya', 5, '500', '../Members/1/22/Preview_1617372472.png', '2021-04-02 19:37:52', 1, '2021-04-02 19:37:52', 1, b'1'),
(24, 1, 8, NULL, NULL, '2021-04-03 10:06:34', 'Computer Operating System - Final Exam Book With Paper Solution', 3, '../Members/1/24/DP_1617372827.jpg', 1, 350, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque voluptatum sit, iusto temporibus ipsam. Nesciunt earum ipsam error, aut vitae molestiae sit.', 'University of California', 8, 'Computer Engineering', '240520', 'Mr chetan kapdiya', 5, '410', '../Members/1/24/Preview_1617372827.png', '2021-04-02 19:43:47', 1, '2021-04-02 19:43:47', 1, b'1'),
(26, 1, 9, NULL, NULL, '2021-04-03 10:07:15', 'Course Management', 2, '../Members/default/note-default.jpg', 2, 450, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque voluptatum sit, iusto temporibus ipsam. Nesciunt earum ipsam error, aut vitae molestiae sit.', 'University of India', 5, 'MBA', '213050', 'saurabh sukla', 4, '200', '../Members/1/26/Preview_1617424473.png', '2021-04-03 10:04:32', 1, '2021-04-03 10:04:32', 1, b'1'),
(27, 1, 8, NULL, NULL, '2021-04-02 15:39:12', 'History', 1, '../Members/1/27/DP_1617443897.jpg', 1, 250, 'lorem ispum book', 'University of ja', 6, '', '', '', 4, '0', NULL, '2021-04-03 15:28:17', 1, '2021-04-03 15:28:17', 1, b'1'),
(28, 1, 8, NULL, NULL, '2021-04-02 15:39:17', 'History', 1, '../Members/default/note-default.jpg', 1, 250, 'lorem ispum book', 'University of Japan', 6, 'MBA', '213050', 'Mr rechard brown', 4, '100', '../Members/1/28/Preview_1617444062.png', '2021-04-03 15:31:02', 1, '2021-04-03 15:31:02', 1, b'1'),
(29, 1, 9, NULL, NULL, '2021-04-02 15:39:22', 'History', 3, '../Members/1/29/DP_1617444175.jpg', 1, 450, 'history book', 'Sal institute', 5, 'Computer Engineering', '240520', 'Miss kasi shah', 5, '500', '../Members/1/29/Preview_1617444175.png', '2021-04-03 15:32:55', 1, '2021-04-03 15:32:55', 1, b'1'),
(32, 1, 8, NULL, NULL, '2021-04-01 15:25:58', 'History', 2, '../Members/1/29/DP_1617444175.jpg', 2, 250, 'lorem book', 'appolo institute', 5, 'IT', '16', 'Abdul kalam', 5, '250', '../Members/1/29/Preview_1617444175.png', '2021-04-01 15:25:58', 1, '2021-04-02 15:40:50', 1, b'1'),
(33, 1, 8, NULL, NULL, '2021-04-02 15:25:58', 'Maths', 3, '../Members/1/29/DP_1617444175.jpg', 2, 300, 'maths book', 'AIT', 5, 'Computer', '13', 'mr prabhash patel', 4, '200', '../Members/1/29/Preview_1617444175.png', '2021-04-02 15:25:58', 1, '2021-04-02 15:25:58', 1, b'1'),
(34, 1, 9, NULL, NULL, '2021-04-02 16:08:02', 'History', 3, '../Members/1/34/DP_1617445423.jpg', 1, 450, 'lorem book', 'University of Germany', 4, 'IT', '213050', 'Mr rechard brown', 5, '100', '../Members/1/34/Preview_1617445423.png', '2021-04-03 15:53:43', 1, '2021-04-03 15:53:43', 1, b'1'),
(35, 1, 8, NULL, NULL, '2021-04-02 16:08:07', 'Maths', 4, '../Members/1/35/DP_1617445539.jpg', 1, 500, 'Maths book', 'University of India', 5, 'MCA', '240520', 'zenif', 4, '600', '../Members/1/35/Preview_1617445539.png', '2021-04-03 15:55:39', 1, '2021-04-03 15:55:39', 1, b'1'),
(36, 1, 6, NULL, NULL, '2021-04-03 16:08:11', 'Data Science', 3, '../Members/1/36/DP_1617445668.jpg', 2, 350, 'data book', 'Sal institute', 5, 'MCA', '215061', 'Mr chetan kapdiya', 4, '200', '../Members/1/36/Preview_1617445669.png', '2021-04-03 15:57:48', 1, '2021-04-03 15:57:48', 1, b'1'),
(37, 1, 8, NULL, NULL, '2021-04-03 16:08:16', 'History', 2, '../Members/1/37/DP_1617445812.jpg', 1, 350, 'history book', 'University of California', 8, 'MBA', '213050', 'Mr arjun brown', 5, '100', '../Members/1/37/Preview_1617445813.png', '2021-04-03 16:00:12', 1, '2021-04-03 16:00:12', 1, b'1'),
(38, 1, 9, NULL, NULL, '2021-04-02 16:08:21', 'science', 3, '../Members/1/38/DP_1617445953.jpg', 2, 450, 'notes desc', 'University of Australia', 1, 'Computer Engineering', '240520', 'Mr rechard brown', 4, '200', '../Members/1/38/Preview_1617445953.png', '2021-04-03 16:02:33', 1, '2021-04-03 16:02:33', 1, b'1'),
(39, 1, 8, NULL, NULL, '2021-04-03 16:08:26', 'History', 1, '../Members/1/39/DP_1617446127.jpg', 2, 300, 'history book', 'University of Canada', 3, 'MCA', '215061', 'Miss Aditi bhatiya', 4, '500', '../Members/1/39/Preview_1617446127.png', '2021-04-03 16:05:27', 1, '2021-04-03 16:05:27', 1, b'1');
-- --------------------------------------------------------
--
-- Table structure for table `notesattachment`
--
CREATE TABLE `notesattachment` (
`ID` int(10) UNSIGNED NOT NULL,
`Note_ID` int(10) UNSIGNED NOT NULL,
`File_Name` varchar(100) NOT NULL,
`Path` varchar(255) NOT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `notesattachment`
--
INSERT INTO `notesattachment` (`ID`, `Note_ID`, `File_Name`, `Path`, `CreatedDate`, `CreatedBy`, `ModifiedDate`, `ModifiedBy`, `IsActive`) VALUES
(5, 12, '5_1617348350pdf', '../Members/1/12/Attachements/5_1617348350.pdf', '2021-04-02 12:55:50', 1, NULL, NULL, b'1'),
(6, 13, '6_1617352461pdf', '../Members/1/13/Attachements/6_1617352461.pdf', '2021-04-02 14:04:21', 1, NULL, NULL, b'1'),
(7, 15, '7_1617371274pdf', '../Members/1/15/Attachements/7_1617371274.pdf', '2021-04-02 19:17:53', 1, NULL, NULL, b'1'),
(8, 16, '8_1617371451pdf', '../Members/1/16/Attachements/8_1617371451.pdf', '2021-04-02 19:20:51', 1, NULL, NULL, b'1'),
(9, 17, '9_1617371613pdf', '../Members/1/17/Attachements/9_1617371613.pdf', '2021-04-02 19:23:33', 1, NULL, NULL, b'1'),
(10, 18, '10_1617371794pdf', '../Members/1/18/Attachements/10_1617371794.pdf', '2021-04-02 19:26:34', 1, NULL, NULL, b'1'),
(11, 19, '11_1617371918pdf', '../Members/1/19/Attachements/11_1617371918.pdf', '2021-04-02 19:28:37', 1, NULL, NULL, b'1'),
(12, 20, '12_1617372069pdf', '../Members/1/20/Attachements/12_1617372069.pdf', '2021-04-02 19:31:09', 1, NULL, NULL, b'1'),
(13, 21, '13_1617372311pdf', '../Members/1/21/Attachements/13_1617372311.pdf', '2021-04-02 19:35:11', 1, NULL, NULL, b'1'),
(14, 24, '14_1617372828pdf', '../Members/1/24/Attachements/14_1617372827.pdf', '2021-04-02 19:43:47', 1, NULL, NULL, b'1'),
(16, 27, '16_1617443897pdf', '../Members/1/27/Attachements/16_1617443897.pdf', '2021-04-03 15:28:17', 1, NULL, NULL, b'1'),
(17, 28, '17_1617444062pdf', '../Members/1/28/Attachements/17_1617444062.pdf', '2021-04-03 15:31:02', 1, NULL, NULL, b'1'),
(18, 29, '18_1617444175pdf', '../Members/1/29/Attachements/18_1617444175.pdf', '2021-04-03 15:32:55', 1, NULL, NULL, b'1'),
(19, 29, '18_1617443897pdf', '../Members/1/29/Attachements//19_161744063.pdf', '2021-04-02 15:45:07', 1, NULL, NULL, b'1'),
(20, 34, '20_1617445424pdf', '../Members/1/34/Attachements/20_1617445424.pdf', '2021-04-03 15:53:43', 1, NULL, NULL, b'1'),
(21, 35, '21_1617445539pdf', '../Members/1/35/Attachements/21_1617445539.pdf', '2021-04-03 15:55:39', 1, NULL, NULL, b'1'),
(22, 36, '22_1617445669pdf', '../Members/1/36/Attachements/22_1617445669.pdf', '2021-04-03 15:57:49', 1, NULL, NULL, b'1'),
(23, 37, '23_1617445813pdf', '../Members/1/37/Attachements/23_1617445813.pdf', '2021-04-03 16:00:13', 1, NULL, NULL, b'1'),
(24, 38, '24_1617445954pdf', '../Members/1/38/Attachements/24_1617445954.pdf', '2021-04-03 16:02:33', 1, NULL, NULL, b'1'),
(25, 39, '25_1617446127pdf', '../Members/1/39/Attachements/25_1617446127.pdf', '2021-04-03 16:05:27', 1, NULL, NULL, b'1');
-- --------------------------------------------------------
--
-- Table structure for table `referencedata`
--
CREATE TABLE `referencedata` (
`ID` int(10) UNSIGNED NOT NULL,
`Value` varchar(100) NOT NULL,
`DataValue` varchar(100) NOT NULL,
`RefCategory` varchar(100) NOT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `referencedata`
--
INSERT INTO `referencedata` (`ID`, `Value`, `DataValue`, `RefCategory`, `CreatedDate`, `CreatedBy`, `ModifiedDate`, `ModifiedBy`, `IsActive`) VALUES
(1, 'Male', 'M', 'Gender', '2021-03-26 11:46:35', 3, '2021-03-26 11:46:35', 3, b'1'),
(2, 'Female', 'Fe', 'Gender', '2021-03-26 11:46:35', 3, '2021-03-26 11:46:35', 3, b'1'),
(3, 'Unknown', 'U', 'Gender', '2021-03-26 11:48:00', 3, '2021-03-26 11:48:00', 3, b'0'),
(4, 'Paid', 'P', 'Selling Mode', '2021-03-26 11:48:00', 3, '2021-03-26 11:48:00', 3, b'1'),
(5, 'Free', 'F', 'Selling Modes', '2021-03-26 11:49:37', 3, '2021-03-26 11:49:37', 3, b'1'),
(6, 'Draft', 'Draft', 'Notes Status', '2021-03-26 11:49:37', 3, '2021-03-26 11:49:37', 3, b'1'),
(7, 'Submitted for Review', 'Submitted for Review', 'Notes Status', '2021-03-26 11:51:33', 3, '2021-03-26 11:51:33', 3, b'1'),
(8, 'In Review', 'In Review', 'Notes Stauts', '2021-03-26 11:51:33', 3, '2021-03-26 11:51:33', 3, b'1'),
(9, 'Published', 'Approved', 'Notes Status', '2021-03-26 11:53:28', 3, '2021-03-26 11:53:28', 3, b'1'),
(10, 'Rejected', 'Rejected', 'Notes Status', '2021-03-26 11:54:23', 3, '2021-03-26 11:54:23', 3, b'1'),
(11, 'Removed', 'Removed', 'Notes Status', '2021-03-26 11:54:23', 3, '2021-03-26 11:54:23', 3, b'1');
-- --------------------------------------------------------
--
-- Table structure for table `reports`
--
CREATE TABLE `reports` (
`ID` int(10) UNSIGNED NOT NULL,
`NoteID` int(10) UNSIGNED NOT NULL,
`UserID` int(10) UNSIGNED NOT NULL,
`againstDownloadID` int(10) UNSIGNED NOT NULL,
`Remarks` varchar(500) NOT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `review_rating`
--
CREATE TABLE `review_rating` (
`ID` int(10) UNSIGNED NOT NULL,
`NoteID` int(10) UNSIGNED NOT NULL,
`UserID` int(10) UNSIGNED NOT NULL,
`againstdownloadID` int(10) UNSIGNED NOT NULL,
`ratings` decimal(10,0) NOT NULL,
`Comments` varchar(500) NOT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `system_configuration`
--
CREATE TABLE `system_configuration` (
`ID` int(10) UNSIGNED NOT NULL,
`UserID` int(10) UNSIGNED NOT NULL,
`Key_info` varchar(100) NOT NULL,
`Value` varchar(255) NOT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `type`
--
CREATE TABLE `type` (
`ID` int(10) UNSIGNED NOT NULL,
`Type_Name` varchar(34) NOT NULL,
`Description` varchar(500) NOT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `type`
--
INSERT INTO `type` (`ID`, `Type_Name`, `Description`, `CreatedDate`, `CreatedBy`, `ModifiedDate`, `ModifiedBy`, `IsActive`) VALUES
(1, 'FREE', 'Free notes', '2021-03-23 11:38:29', NULL, NULL, NULL, b'1'),
(2, 'PAID', 'paid notes', '2021-03-22 15:35:55', NULL, NULL, NULL, b'1');
-- --------------------------------------------------------
--
-- Table structure for table `userroles`
--
CREATE TABLE `userroles` (
`ID` int(11) UNSIGNED NOT NULL,
`Name` varchar(50) NOT NULL,
`Description` varchar(255) DEFAULT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(10) NOT NULL DEFAULT b'0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `userroles`
--
INSERT INTO `userroles` (`ID`, `Name`, `Description`, `CreatedDate`, `CreatedBy`, `ModifiedDate`, `ModifiedBy`, `IsActive`) VALUES
(1, 'notes-member', 'members', '2021-03-22 11:30:18', NULL, NULL, NULL, b'0000000000'),
(2, 'note-admin', 'admin', '2021-03-22 11:30:54', NULL, NULL, NULL, b'0000000000'),
(3, 'notes-superdmin', 'superadmin', '2021-03-22 11:31:11', NULL, NULL, NULL, b'0000000000');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`ID` int(10) UNSIGNED NOT NULL,
`RoleID` int(10) UNSIGNED NOT NULL,
`FirstName` varchar(50) NOT NULL,
`LastName` varchar(50) NOT NULL,
`EmailID` varchar(100) NOT NULL,
`Password` varchar(24) NOT NULL,
`IsEmailVerified` bit(10) NOT NULL DEFAULT b'0',
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`IsActive` bit(10) NOT NULL DEFAULT b'0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`ID`, `RoleID`, `FirstName`, `LastName`, `EmailID`, `Password`, `IsEmailVerified`, `CreatedDate`, `CreatedBy`, `ModifiedDate`, `IsActive`) VALUES
(1, 1, 'Axita', 'Patel', 'axita31.patel@gmail.com', 'Axita31patel', b'0000000001', '2021-03-27 11:36:45', NULL, NULL, b'0000000001'),
(2, 2, 'Axita', 'Khunt', 'axita31.khunt@gmail.com', 'Axita31khunt', b'0000000001', '2021-03-17 20:44:53', NULL, NULL, b'0000000001'),
(3, 1, 'pritesh', 'khunt', 'khuntpritesh5@gmail.com', 'Pritesh26khunt', b'0000000001', '2021-04-03 16:32:38', NULL, NULL, b'0000000001');
-- --------------------------------------------------------
--
-- Table structure for table `users-details`
--
CREATE TABLE `users-details` (
`ID` int(11) UNSIGNED NOT NULL,
`Role_Id` int(11) UNSIGNED NOT NULL,
`Note_Id` int(11) UNSIGNED NOT NULL,
`User_Type` varchar(16) NOT NULL,
`Dob` datetime DEFAULT NULL,
`Gender` int(10) UNSIGNED DEFAULT NULL,
`Phone_No_Country_Code` int(10) UNSIGNED NOT NULL,
`Phone_No` varchar(20) NOT NULL,
`Profile_Pic` varchar(500) DEFAULT NULL,
`Secondary_Email` varchar(100) DEFAULT NULL,
`Address_1` varchar(100) NOT NULL,
`Address_2` varchar(100) NOT NULL,
`City` varchar(50) NOT NULL,
`State` varchar(50) NOT NULL,
`Zip_Code` varchar(50) NOT NULL,
`Country` varchar(50) NOT NULL,
`University` varchar(100) DEFAULT NULL,
`College` varchar(100) DEFAULT NULL,
`CreatedDate` datetime DEFAULT NULL,
`CreatedBy` int(11) DEFAULT NULL,
`ModifiedDate` datetime DEFAULT NULL,
`ModifiedBy` int(11) DEFAULT NULL,
`IsActive` bit(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `category`
--
ALTER TABLE `category`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `country`
--
ALTER TABLE `country`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `downloads`
--
ALTER TABLE `downloads`
ADD PRIMARY KEY (`ID`),
ADD KEY `downloads_ibfk_1` (`NoteID`),
ADD KEY `SellerID` (`SellerID`),
ADD KEY `DownloaderID` (`DownloaderID`);
--
-- Indexes for table `notes`
--
ALTER TABLE `notes`
ADD PRIMARY KEY (`ID`),
ADD KEY `SellerID` (`SellerID`),
ADD KEY `Status` (`Status`),
ADD KEY `Actioned_By` (`Actioned_By`),
ADD KEY `Category` (`Category`),
ADD KEY `Note_types` (`Note_types`),
ADD KEY `Country` (`Country`),
ADD KEY `Is_Paid` (`Is_Paid`);
--
-- Indexes for table `notesattachment`
--
ALTER TABLE `notesattachment`
ADD PRIMARY KEY (`ID`),
ADD KEY `Note_ID` (`Note_ID`);
--
-- Indexes for table `referencedata`
--
ALTER TABLE `referencedata`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `reports`
--
ALTER TABLE `reports`
ADD PRIMARY KEY (`ID`),
ADD KEY `againstDownloadID` (`againstDownloadID`),
ADD KEY `UserID` (`UserID`),
ADD KEY `NoteID` (`NoteID`);
--
-- Indexes for table `review_rating`
--
ALTER TABLE `review_rating`
ADD PRIMARY KEY (`ID`),
ADD KEY `NoteID` (`NoteID`),
ADD KEY `againstdownloadID` (`againstdownloadID`),
ADD KEY `UserID` (`UserID`);
--
-- Indexes for table `system_configuration`
--
ALTER TABLE `system_configuration`
ADD PRIMARY KEY (`ID`),
ADD KEY `UserID` (`UserID`);
--
-- Indexes for table `type`
--
ALTER TABLE `type`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `userroles`
--
ALTER TABLE `userroles`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`ID`),
ADD UNIQUE KEY `EmailID` (`EmailID`),
ADD KEY `RoleID` (`RoleID`);
--
-- Indexes for table `users-details`
--
ALTER TABLE `users-details`
ADD PRIMARY KEY (`ID`),
ADD KEY `Role_Id` (`Role_Id`),
ADD KEY `Note_Id` (`Note_Id`),
ADD KEY `Phone_No_Country_Code` (`Phone_No_Country_Code`),
ADD KEY `Gender` (`Gender`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `country`
--
ALTER TABLE `country`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `downloads`
--
ALTER TABLE `downloads`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;
--
-- AUTO_INCREMENT for table `notes`
--
ALTER TABLE `notes`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=40;
--
-- AUTO_INCREMENT for table `notesattachment`
--
ALTER TABLE `notesattachment`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26;
--
-- AUTO_INCREMENT for table `referencedata`
--
ALTER TABLE `referencedata`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `reports`
--
ALTER TABLE `reports`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `review_rating`
--
ALTER TABLE `review_rating`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `system_configuration`
--
ALTER TABLE `system_configuration`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `type`
--
ALTER TABLE `type`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `userroles`
--
ALTER TABLE `userroles`
MODIFY `ID` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `users-details`
--
ALTER TABLE `users-details`
MODIFY `ID` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `downloads`
--
ALTER TABLE `downloads`
ADD CONSTRAINT `downloads_ibfk_1` FOREIGN KEY (`NoteID`) REFERENCES `notes` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `downloads_ibfk_2` FOREIGN KEY (`SellerID`) REFERENCES `users` (`ID`),
ADD CONSTRAINT `downloads_ibfk_3` FOREIGN KEY (`DownloaderID`) REFERENCES `users` (`ID`);
--
-- Constraints for table `notes`
--
ALTER TABLE `notes`
ADD CONSTRAINT `notes_ibfk_1` FOREIGN KEY (`SellerID`) REFERENCES `users` (`ID`),
ADD CONSTRAINT `notes_ibfk_2` FOREIGN KEY (`Status`) REFERENCES `referencedata` (`ID`),
ADD CONSTRAINT `notes_ibfk_3` FOREIGN KEY (`Actioned_By`) REFERENCES `users` (`ID`),
ADD CONSTRAINT `notes_ibfk_4` FOREIGN KEY (`Category`) REFERENCES `category` (`ID`),
ADD CONSTRAINT `notes_ibfk_5` FOREIGN KEY (`Note_types`) REFERENCES `type` (`ID`),
ADD CONSTRAINT `notes_ibfk_6` FOREIGN KEY (`Country`) REFERENCES `country` (`ID`),
ADD CONSTRAINT `notes_ibfk_7` FOREIGN KEY (`Is_Paid`) REFERENCES `referencedata` (`ID`);
--
-- Constraints for table `notesattachment`
--
ALTER TABLE `notesattachment`
ADD CONSTRAINT `notesattachment_ibfk_1` FOREIGN KEY (`Note_ID`) REFERENCES `notes` (`ID`);
--
-- Constraints for table `reports`
--
ALTER TABLE `reports`
ADD CONSTRAINT `reports_ibfk_1` FOREIGN KEY (`againstDownloadID`) REFERENCES `downloads` (`ID`),
ADD CONSTRAINT `reports_ibfk_2` FOREIGN KEY (`UserID`) REFERENCES `users` (`ID`),
ADD CONSTRAINT `reports_ibfk_3` FOREIGN KEY (`NoteID`) REFERENCES `notes` (`ID`);
--
-- Constraints for table `review_rating`
--
ALTER TABLE `review_rating`
ADD CONSTRAINT `review_rating_ibfk_1` FOREIGN KEY (`NoteID`) REFERENCES `notes` (`ID`),
ADD CONSTRAINT `review_rating_ibfk_2` FOREIGN KEY (`againstdownloadID`) REFERENCES `downloads` (`ID`),
ADD CONSTRAINT `review_rating_ibfk_3` FOREIGN KEY (`UserID`) REFERENCES `users` (`ID`);
--
-- Constraints for table `system_configuration`
--
ALTER TABLE `system_configuration`
ADD CONSTRAINT `system_configuration_ibfk_1` FOREIGN KEY (`UserID`) REFERENCES `users` (`ID`);
--
-- Constraints for table `users`
--
ALTER TABLE `users`
ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`RoleID`) REFERENCES `userroles` (`ID`);
--
-- Constraints for table `users-details`
--
ALTER TABLE `users-details`
ADD CONSTRAINT `users-details_ibfk_1` FOREIGN KEY (`Role_Id`) REFERENCES `userroles` (`ID`),
ADD CONSTRAINT `users-details_ibfk_2` FOREIGN KEY (`Note_Id`) REFERENCES `notes` (`ID`),
ADD CONSTRAINT `users-details_ibfk_3` FOREIGN KEY (`Phone_No_Country_Code`) REFERENCES `country` (`ID`),
ADD CONSTRAINT `users-details_ibfk_4` FOREIGN KEY (`Gender`) REFERENCES `referencedata` (`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 |
06ab794c10f031cb724e0359258b17da4cb43d8d | SQL | mershicorn/University-BD | /university DB.sql | UTF-8 | 1,105 | 2.875 | 3 | [] | no_license | CREATE TABLE "Faculty" (
"id_faculty" serial,
"id_address" integer,
"foundation_year" year,
"dean" varchar
);
CREATE TABLE "Faculty_address" (
"id_address" serial,
"id_faculty" int,
"adress" varchar
);
CREATE TABLE "Degree" (
"id_degree" serial,
"name_degree" varchar
);
CREATE TABLE "Subject" (
"id_subject" serial,
"id_faculty" int,
"nam_subject" varchar,
"term" int,
"hours_amt" int,
"control_form" enum,
"id_lecturer" varchar
);
CREATE TABLE "Lecturer" (
"id_lecturer" serial,
"name_surname" varchar,
"l_birthdate" varchar,
"id_degree" varchar,
"position" varchar,
"id_faculty" varchar
);
ALTER TABLE "Faculty_address" ADD FOREIGN KEY ("id_faculty") REFERENCES "Faculty" ("id_faculty");
ALTER TABLE "Subject" ADD FOREIGN KEY ("id_faculty") REFERENCES "Faculty" ("id_faculty");
ALTER TABLE "Subject" ADD FOREIGN KEY ("id_lecturer") REFERENCES "Lecturer" ("id_lecturer");
ALTER TABLE "Lecturer" ADD FOREIGN KEY ("id_degree") REFERENCES "Degree" ("id_degree");
ALTER TABLE "Lecturer" ADD FOREIGN KEY ("id_faculty") REFERENCES "Faculty" ("id_faculty"); | true |
807118209b670d965d20207a2238189f2f39fec2 | SQL | gjbex/training-material | /DataStorage/Sql/ExperimentDB/07_insert_exp3.sql | UTF-8 | 799 | 2.59375 | 3 | [
"CC-BY-4.0"
] | permissive | INSERT INTO experiments
(experiment_id, start_date, end_date, experiment_description)
VALUES
(3, '2015-11-21 09:05:00', NULL,
'third experiment');
INSERT INTO staff_assignments
(experiment_id, researcher_id)
VALUES
(3, 1),
(3, 2);
INSERT INTO runs
(run_id, experiment_id, run_type_id, tissue_id, run_date)
VALUES
(7, 3, 2, 3, '2015-11-21 09:19:00');
INSERT INTO parameter_values
(run_id, parameter_id, parameter_value)
VALUES
(7, 1, 60.0),
(7, 2, 0.15);
INSERT INTO result_values
(run_id, result_id, result_value)
VALUES
(7, 1, 0.05),
(7, 2, 0.03);
| true |
4a9871f97bd241dcd6545f5b7451442e821478d4 | SQL | kubeflow/community | /devstats/config/util_sql/devstats_log_table.sql | UTF-8 | 714 | 3.359375 | 3 | [
"Apache-2.0"
] | permissive | CREATE TABLE gha_logs (
id integer NOT NULL,
dt timestamp without time zone DEFAULT now(),
msg text,
prog character varying(32) not null default '',
proj character varying(32) not null,
run_dt timestamp without time zone not null
);
ALTER TABLE gha_logs OWNER TO gha_admin;
CREATE SEQUENCE gha_logs_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE gha_logs_id_seq OWNER TO gha_admin;
ALTER SEQUENCE gha_logs_id_seq OWNED BY gha_logs.id;
ALTER TABLE ONLY gha_logs ALTER COLUMN id SET DEFAULT nextval('gha_logs_id_seq'::regclass);
CREATE INDEX logs_dt_idx ON gha_logs USING btree (dt);
CREATE INDEX logs_id_idx ON gha_logs USING btree (id);
| true |
f401f2df4412f443a688641743f4c8e8eaf7921d | SQL | ElvisNogueira/Projeto_GYM | /src/bd/GYM_BD.sql | WINDOWS-1252 | 9,456 | 3 | 3 | [
"Apache-2.0"
] | permissive | CREATE TABLE endereco(
id serial PRIMARY KEY,
bairro Varchar(255),
uf Varchar(2),
cidade Varchar(255),
cep Varchar(255),
logradouro Varchar(255),
num int
);
CREATE TABLE aluno(
id serial PRIMARY KEY,
nome Varchar(255),
cpf Varchar(14) unique,
status Varchar(50),
data_nascimento date,
sexo Varchar(10),
vencimento_mens int,
endereco_id int references endereco(id),
rg VARCHAR(30),
email VARCHAR(100),
celular VARCHAR(15),
tipo_plano VARCHAR(15),
valor_plano float
);
CREATE TABLE funcionario(
id serial PRIMARY KEY,
nome Varchar(255),
cpf Varchar(14) unique,
salario float,
telefone Varchar(20),
login Varchar(255) unique,
senha Varchar(255),
rg varchar(50),
data_nascimento date,
sexo varchar(20),
status varchar(20),
email varchar(20),
data_admissao date,
data_demissao date,
funcao varchar(50),
cadAlunoAcessar boolean,
cadAlunoCadastrar boolean,
cadAlunoEditar boolean,
cadAlunoExcluir boolean,
cadAlunoRecebPag boolean,
cadFuncAcessar boolean,
cadFuncCadastrar boolean,
cadFuncEditar boolean,
cadFuncExcluir boolean,
cadFuncRecebPag boolean,
avFisicaAcessar boolean,
fichaTreinoAcessar boolean,
relatorioAcessar boolean,
relatorioCadastrar boolean,
relatorioEditar boolean,
relatorioExcluir boolean,
relatorioRecebPag boolean,
lancarPagAcessar boolean,
lancarPagCadastrar boolean,
lancarPagEditar boolean,
lancarPagExcluir boolean,
lancarPagRecebPag boolean,
controleCaixaAcessar boolean,
controleCaixaCadastrar boolean,
controleCaixaEditar boolean,
controleCaixaExcluir boolean,
controleCaixaRecebPag boolean,
endereco_id int references endereco(id)
);
CREATE TABLE composicao_corporal(
id serial PRIMARY KEY,
peso_gorda float,
peso_magra float,
imc float,
rcq float,
porcentual_gordura float,
pressao_arterial Varchar(10)
);
CREATE TABLE metas_ideais(
id serial PRIMARY KEY,
peso float,
imc float,
nivel Varchar,
porcentual_gordura float
);
CREATE TABLE perimetria(
id serial PRIMARY KEY,
altura float,
cintura float,
peso float,
coxa_esquerda float,
panturrilha_esquerda float,
ombro float,
braco_esquerdo float,
coxa_direita float,
abdomem float,
torax float,
quadril float,
panturrilha_direita float,
braco_direito float,
ante_braco_direito float,
ante_braco_esquerdo float
);
CREATE TABLE dobras_cutaneas(
id serial PRIMARY KEY,
peitoral float,
axilar_media float,
abdominal float,
coxa float,
bicipita float,
supra_iliaca float,
subscapular float,
tricipital float
);
CREATE TABLE exercicio(
id serial PRIMARY KEY,
tipo Varchar(50),
nome Varchar(255)
);
CREATE TABLE instrutor(
id serial PRIMARY KEY,
cref int unique,
funcionario_id int references funcionario(id)
);
CREATE TABLE ficha_de_treino(
id serial PRIMARY KEY,
instrutor_id int references instrutor(id),
aluno_id int references aluno(id),
objetivo VARCHAR(255),
observacao VARCHAR(255),
data date,
dataReavaliacao date
);
CREATE TABLE ficha_exercicio(
id serial PRIMARY KEY,
repeticoes int,
ordem int,
dia Varchar(50),
serie int,
exercicio_id int references exercicio(id),
ficha_treino_id int references ficha_de_treino(id)
);
CREATE TABLE anamnese(
id serial PRIMARY KEY,
tabagismo boolean,
restricaoArticular boolean,
cardiopatias boolean,
medicamentos boolean,
hipertensao boolean,
outros boolean,
diabetes boolean,
probPulmonares boolean,
ativFisica boolean,
nivel VARCHAR(255),
tabagismoObs VARCHAR(500),
restricaoArticularObs VARCHAR(500),
cardiopatiasObs VARCHAR(500),
medicamentosObs VARCHAR(500),
hipertensaoObs VARCHAR(500),
outrosObs VARCHAR(500),
diabetesObs VARCHAR(500),
probPulmonaresObs VARCHAR(500),
ativFisicaObs VARCHAR(500)
);
CREATE TABLE avaliacao(
id serial PRIMARY KEY,
objetivo Varchar(255),
proxima_avaliacao date,
data date,
anamnese_id int references anamnese(id),
composicao_corporal_id int references composicao_corporal(id),
metas_ideais_id int references metas_ideais(id),
perimetria_id int references perimetria(id),
dobras_cutaneas_id int references dobras_cutaneas(id),
aluno_id int references aluno(id),
instrutor_id int references instrutor(id)
);
CREATE TABLE pagamento(
id serial PRIMARY KEY,
valor float,
descricao Varchar(255),
data date,
dataVenc date,
formaPag VARCHAR(50),
aluno_id int references aluno(id),
funcionario_id int references funcionario(id)
);
CREATE TABLE historico(
id serial PRIMARY KEY,
nome Varchar(255),
tipo Varchar(255)
);
CREATE TABLE parcelas(
id serial PRIMARY KEY,
data_de_vencimento date,
valor float,
status VARCHAR(255),
aluno_id int references aluno(id),
conta_id int references historico(id)
);
CREATE TABLE controle_financeiro(
id serial PRIMARY KEY,
data date,
descricao Varchar(255),
valor float,
historico_id int references historico(id)
);
CREATE TABLE cadastro_academia(
id serial PRIMARY KEY,
nome Varchar(255),
nome_fantasia Varchar(255),
nome_proprietario Varchar(255),
cnpj Varchar(255),
cpf Varchar(255),
logo Varchar(255),
email Varchar(255),
telefone Varchar(255),
celular Varchar(255),
endereco_id int references endereco(id)
);
INSERT INTO exercicio (tipo, nome) VALUES
('Abdome','Elevao de perna'),('Abdome','Elevao de perna alternada'), ('Abdome','Infra Tesoura'),
('Abdome','Oblquo - Rotao de tronco'),('Abdome','Oblquo Flexo lateral de troco em p'),('Abdome','Oblquo Flexo lateral de troco no solo'),
('Abdome','Oblquo Toque no calcanhar'), ('Abdome','Prancha'),('Abdome','Remador'),
('Abdome','Roda de suspenso'),('Abdome','Superior curto'),('Abdome','Superior longo'),
('Aerbico','Bike'),('Aerbico','Elptico'), ('Aerbico','Esteira'),
('Bceps','Rosca 90'),('Bceps','Rosca alternada'),('Bceps','Rosca concentrada'),
('Bceps','Rosca de punho'),('Bceps','Rosca de punho inversa'),('Bceps','Rosca direta'),
('Bceps','Rosca martelo'),('Bceps','Rosca scott'),('Costas','Crucifixo Inverso'),
('Costas','Poll dow'),('Costas','Puxador alto costa'),('Costas','Puxador alto frente'),
('Costas','Ramada cavalinho'),('Costas','Ramada curvada'),('Costas','Ramada unilateral'),
('Costas','Remada sentada'),('Costas','Voador inverso'),('Glteo','Cadeira abdutora curvada'),
('Glteo','Cadeira abdutora reta'),('Glteo','Coice no cross'),('Glteo','Elevao da pelve'),
('Glteo','Elevao lateral de perna'),('Glteo','Flexora deitada'),('Glteo','Flexora em p'),
('Glteo','Quatro apoios'),('Glteo','Quatro apoios cachorrinho'),('Glteo','Stiff'),
('Ombro','Desenvolvimento de ombro'),('Ombro','Elevao frontal'),('Ombro','Elevao frontal martelo'),
('Ombro','Elevao lateral'),('Ombro','Encolhimento dos ombros'),('Ombro','Remada alta'),
('Ombro','Rotao externa'),('Peito','Cross over'),('Peito','Crucifixo'),
('Peito','Crucifixo inclinado'),('Peito','Poll over'),('Peito','Supino declinado'),
('Peito','Supino inclinado'),('Peito','Supino reto'),('Peito','Voador '),
('Perna','Adutora'),('Perna','Agachamento'),('Perna','Agachamento sum'),
('Perna','Avano'),('Perna','Cadeira adutora'),('Perna','Extensora'),
('Perna','Leg press '),('Perna','Leg press sum'),('Perna','Panturrilha'),
('Trceps','Coice'),('Trceps','Cord'),('Trceps','Francs'),
('Trceps','No banco'),('Trceps','Puley'),('Trceps','Testal');
INSERT INTO historico (nome, tipo) VALUES
('Salrio','Dbito'),('Conta de gua','Dbito'),('Conta de luz','Dbito'),
('Conta de telefone','Dbito'),('Contabilidade','Dbito'),('Dispesas caf e almoo','Dbito'),
('Imprestimos','Dbito'),('Impostos','Dbito'),('Doaes','Dbito'),
('Compra de materiais de escritrio','Dbito'),('Compra de materiais de limpeza','Dbito'),('Compra de materiais de manuteno','Dbito'),
('Aquisio de mquinas','Dbito'),('Prestao de servios de manuteno','Dbito'),('Acerto de caixa','Dbito'),
('Outras receitas','Crdito'),('Mensalidade','Crdito'),('Avaliao Fsica','Crdito');
insert into endereco (bairro,uf,cidade,cep,logradouro,num) values ('Santa Rosa','PE','Floresta','56400-000','Rua Tito Rosa','123');
insert into funcionario (nome,cpf,salario,telefone,login,senha,rg,data_nascimento,sexo,status,email,data_admissao,
data_demissao,funcao,cadAlunoAcessar,cadAlunoCadastrar,cadAlunoEditar,cadAlunoExcluir,cadAlunoRecebPag,cadFuncAcessar,cadFuncCadastrar,cadFuncEditar,cadFuncExcluir,cadFuncRecebPag,avFisicaAcessar,fichaTreinoAcessar,relatorioAcessar,relatorioCadastrar,relatorioEditar,relatorioExcluir,relatorioRecebPag,lancarPagAcessar,lancarPagCadastrar,lancarPagEditar,lancarPagExcluir,lancarPagRecebPag,controleCaixaAcessar,controleCaixaCadastrar,controleCaixaEditar,controleCaixaExcluir,controleCaixaRecebPag,endereco_id) values
('ADMIN','00000000','0','9','admin','admin','8','1997-12-02','Unissex','ativo','email','2018-07-08',null,'Root',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,1);
insert into instrutor (cref,funcionario_id) values ('12345','1'); | true |
9eef66b00ea5ce7d70819045ac19e5bb936ec900 | SQL | agalan33/Db-Project-Python | /schema.sql | UTF-8 | 5,447 | 3.546875 | 4 | [] | no_license | drop table if exists contacts;
drop table if exists ismember;
drop table if exists replies;
drop table if exists reactions;
drop table if exists contains;
drop table if exists messages;
drop table if exists chats;
drop table if exists users;
drop table if exists hashtags;
CREATE TABLE users(uid serial primary key , username varchar(10), ufirst_name varchar(20), ulast_name varchar(20), uemail varchar(30), upassword varchar (15),
uphone varchar(30), uage int);
CREATE TABLE contacts(ownerid int references users(uid), contactid int references users(uid),
primary key(ownerid, contactid));
create table chats(
cid serial primary key,
cname varchar(20),
uid integer references users(uid)
);
create table isMember(
uid integer references users(uid),
cid integer references chats(cid),
primary key (uid, cid)
);
create table messages(
mid serial primary key,
mimage varchar(200),
mtext varchar(200),
uid integer references users(uid),
cid integer references chats(cid),
mdate timestamp with time zone default now()
);
create table replies(
original_id integer references messages(mid),
reply_id integer references messages(mid),
primary key (original_id, reply_id)
);
create table reactions(
rid serial primary key,
rlike integer,
rdislike integer,
mid integer references messages(mid),
uid integer references users(uid),
rdate timestamp with time zone default now()
);
create table hashtags(
hid serial primary key,
htext varchar(30)
);
create table contains(
mid integer references messages(mid),
hid integer references hashtags(hid),
primary key (mid, hid)
);
/*Users*/
INSERT INTO users("uid", "username", "ufirst_name", "ulast_name", "uemail", "upassword", "uphone", "uage") VALUES (DEFAULT, 'adahid33', 'Adahid', 'Galan', 'adahid.galan@upr.edu', 'colegio', '787-000-0000', 22);
INSERT INTO users("uid", "username", "ufirst_name", "ulast_name", "uemail", "upassword", "uphone", "uage") VALUES (DEFAULT, 'eduardo13', 'Eduardo', 'Perez', 'eduardo.perez13@upr.edu', 'colegio', '787-000-0000', 22);
INSERT INTO users("uid", "username", "ufirst_name", "ulast_name", "uemail", "upassword", "uphone", "uage") VALUES (DEFAULT, 'cerosado', 'Cristian', 'Rosado', 'cristian.rosado@upr.edu', 'colegio', '787-000-0000', 21);
/*Contacts*/
INSERT INTO contacts ("ownerid", "contactid") VALUES (1, 2);
INSERT INTO contacts ("ownerid", "contactid") VALUES (1, 3);
INSERT INTO contacts ("ownerid", "contactid") VALUES (2, 1);
INSERT INTO contacts ("ownerid", "contactid") VALUES (2, 3);
INSERT INTO contacts ("ownerid", "contactid") VALUES (3, 1);
INSERT INTO contacts ("ownerid", "contactid") VALUES (3, 2);
/*Chats*/
INSERT INTO public.chats (cid, cname, uid) VALUES (1, 'testchat1', 1);
INSERT INTO public.chats (cid, cname, uid) VALUES (2, 'testchat2', 2);
/*isMember*/
INSERT INTO public.ismember (uid, cid) VALUES (1, 1);
INSERT INTO public.ismember (uid, cid) VALUES (2, 1);
INSERT INTO public.ismember (uid, cid) VALUES (3, 1);
/*messages*/
INSERT INTO public.messages (mid, mimage, mtext, uid, cid, mdate) VALUES (1, 'https://material.angular.io/assets/img/examples/shiba2.jpg', 'Hello, test message', 1, 1, '2019-04-06 18:00:47.487313');
INSERT INTO public.messages (mid, mimage, mtext, uid, cid, mdate) VALUES (4, null, 'No paso na ahi', 3, 1, '2019-04-06 19:20:43.950704');
INSERT INTO public.messages (mid, mimage, mtext, uid, cid, mdate) VALUES (6, null, 'Reply to message with id 5', 1, 1, '2019-04-07 16:35:08.664723');
INSERT INTO public.messages (mid, mimage, mtext, uid, cid, mdate) VALUES (5, '/static/images/image.jpeg', 'Photo from /static folder on flask', 2, 1, '2019-04-07 03:55:23.530286');
INSERT INTO public.messages (mid, mimage, mtext, uid, cid, mdate) VALUES (3, 'http://images.performgroup.com/di/library/omnisport/cc/db/lebron-james-kobe-bryant-52517-usnews-getty-ftr_1r8z6lo46q6c91k0uvx8eznzvf.jpg?t=1061837212&w=960&quality=70', 'Mmmmm #QuePasoAhi,', 2, 1, '2019-04-06 17:59:56.858107');
INSERT INTO public.messages (mid, mimage, mtext, uid, cid, mdate) VALUES (2, 'https://cdn-s3.si.com/s3fs-public/styles/marquee_large_2x/public/2019/03/06/lebron-james-lakers-lead-plans.jpg?itok=kHQ4OZ7G', 'Lakers! #StriveForGreatness #LA#2019', 1, 1, '2019-04-06 17:59:56.858107');
/*replies*/
INSERT INTO public.replies (original_id, reply_id) VALUES (3, 4);
INSERT INTO public.replies (original_id, reply_id) VALUES (5, 6);
/*reactions*/
INSERT INTO public.reactions (rid, rlike, rdislike, mid, uid, rdate) VALUES (1, 1, null, 1, 2, '2019-04-09 01:42:27.804627');
INSERT INTO public.reactions (rid, rlike, rdislike, mid, uid, rdate) VALUES (2, 1, null, 1, 3, '2019-04-09 01:42:49.190614');
INSERT INTO public.reactions (rid, rlike, rdislike, mid, uid, rdate) VALUES (3, null, 1, 1, 1, '2019-04-09 01:44:15.655632');
/*Hashtags*/
INSERT INTO hashtags (hid, htext) VALUES (1, '#LA');
INSERT INTO hashtags (hid, htext) VALUES (2, '#nba');
INSERT INTO hashtags (hid, htext) VALUES (3, '#playoffs');
INSERT INTO hashtags (hid, htext) VALUES (4, '#db');
/*contains*/
INSERT INTO contains (mid, hid) VALUES (3, 4);
INSERT INTO contains (mid, hid) VALUES (3, 3);
INSERT INTO contains (mid, hid) VALUES (3, 2);
INSERT INTO contains (mid, hid) VALUES (3, 1);
INSERT INTO contains (mid, hid) VALUES (2, 4);
INSERT INTO contains (mid, hid) VALUES (2, 1);
INSERT INTO contains (mid, hid) VALUES (1, 4);
INSERT INTO contains (mid, hid) VALUES (1, 3); | true |
5cd533cebde96c3dcb79b9afb280f0de57d0cd88 | SQL | nilu-000/furry-octo-giggle | /src/db.sql | UTF-8 | 1,146 | 4.0625 | 4 | [] | no_license | CREATE DATABASE bookstore;
CREATE TABLE books(
id SERIAL NOT NULL,
name VARCHAR(32) NOT NULL,
isbn VARCHAR(32),
PRIMARY KEY(id)
);
CREATE TABLE authors(
id SERIAL NOT NULL,
fullname VARCHAR(32) NOT NULL,
email VARCHAR(32) NOT NULL UNIQUE,
PRIMARY KEY(id)
);
CREATE TABLE book_author(
book_id SERIAL
REFERENCES books(id),
author_id SERIAL
REFERENCES authors(id)
);
INSERT INTO books(name) VALUES('Dr.Sleep'),('Becoming'), ('Sputnik Sweetheart');
INSERT INTO authors(fullname, email)
VALUES('Stephen King', 's.king@mail.com'),
('Michelle Obama', 'm.obama@mail.com'),
('Hakuri Murakami', 'murakami@mail.com');
INSERT INTO book_author(book_id, author_id) VALUES(1,1), (2,2), (3,3);
SELECT * FROM books b JOIN book_author ba ON b.id=ba.book_id
JOIN authors a ON a.id=ba.author_id;
SELECT * FROM users u JOIN admins a ON a.id=u.id;
CREATE TABLE users(
id SERIAL NOT NULL,
fullname VARCHAR(64) NOT NULL,
email VARCHAR(64) NOT NULL UNIQUE,
password VARCHAR(128) NOT NULL,
PRIMARY KEY(id)
);
CREATE TABLE admins(
id SERIAL NOT NULL,
admin_id SERIAL
REFERENCES users(id),
PRIMARY KEY(id)
);
| true |
ef81fa2277d23eeb5508ee46fe4dec8c9ccbc0f3 | SQL | ShayRow/phpForm | /dbname.sql | UTF-8 | 3,091 | 3.1875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Хост: 127.0.0.1:3306
-- Время создания: Мар 24 2020 г., 19:53
-- Версия сервера: 10.3.13-MariaDB-log
-- Версия PHP: 7.1.32
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 */;
--
-- База данных: `dbname`
--
-- --------------------------------------------------------
--
-- Структура таблицы `images`
--
CREATE TABLE `images` (
`id_image` int(11) NOT NULL,
`id_user` int(11) NOT NULL,
`image` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `images`
--
INSERT INTO `images` (`id_image`, `id_user`, `image`) VALUES
(75, 1, 'abd_192251.jpg'),
(76, 1, 'b-i_127088.jpg'),
(77, 1, 'fcd5cd97af33e77a8128f51635.jpg'),
(78, 33, 'aAeBywr_QH820813.jpg'),
(79, 33, 'FFQJhelpzaY12642.jpg'),
(80, 33, '-ikf-Fh_tCc17532.jpg'),
(81, 33, 'l2ePA8fsg-A5630.jpg'),
(82, 33, 'pMy6JgQASko62301.jpg'),
(83, 33, 'eDcTdVb_153490.jpg'),
(84, 34, 'luxfon86394.jpg'),
(85, 34, 'Z-0vj8TSyZE8118.jpg'),
(86, 34, '6vkyM3AS7LM26053.jpg');
-- --------------------------------------------------------
--
-- Структура таблицы `users`
--
CREATE TABLE `users` (
`id_user` int(11) NOT NULL,
`login` text NOT NULL,
`password` text NOT NULL,
`nickname` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `users`
--
INSERT INTO `users` (`id_user`, `login`, `password`, `nickname`) VALUES
(1, 'admin', 'admin', 'admin'),
(33, 'root', 'root', 'root'),
(34, 'lety', 'lety', 'lety');
--
-- Индексы сохранённых таблиц
--
--
-- Индексы таблицы `images`
--
ALTER TABLE `images`
ADD PRIMARY KEY (`id_image`),
ADD KEY `id_user` (`id_user`);
--
-- Индексы таблицы `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id_user`);
--
-- AUTO_INCREMENT для сохранённых таблиц
--
--
-- AUTO_INCREMENT для таблицы `images`
--
ALTER TABLE `images`
MODIFY `id_image` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=87;
--
-- AUTO_INCREMENT для таблицы `users`
--
ALTER TABLE `users`
MODIFY `id_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35;
--
-- Ограничения внешнего ключа сохраненных таблиц
--
--
-- Ограничения внешнего ключа таблицы `images`
--
ALTER TABLE `images`
ADD CONSTRAINT `images_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
c53925ca417de53ee603dc36ede35d27fc3882d2 | SQL | vicrobert/wisdom-medical | /wm-infosys-web/script/database/database-schema.sql | UTF-8 | 1,183 | 3.109375 | 3 | [] | no_license | /*
SQLyog Enterprise - MySQL GUI v6.15
MySQL - 5.7.22-log : Database - wm_web
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
create database if not exists `wm_web`;
USE `wm_web`;
/*!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' */;
/*Table structure for table `sys_config` */
DROP TABLE IF EXISTS `sys_config`;
CREATE TABLE `sys_config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`description` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`value` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC;
/*Data for the table `sys_config` */
insert into `sys_config`(`id`,`description`,`name`,`value`) values (1,'默认省份','DEFAULT_PROVINCE','上海'),(2,'默认医院','DEFAULT_HOSPITAL','上海第二人民医院'),(3,'默认城市','DEFAULT_CITY','上海');
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
| true |
fc9a2de8f30d6779d914748a0ec87d1a5ac2db72 | SQL | BanguyenHuu/SocialNetworkServer | /src/main/resources/social.sql | UTF-8 | 4,085 | 2.96875 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: localhost Database: doan
-- ------------------------------------------------------
-- Server version 5.7.21-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `friends`
--
DROP TABLE IF EXISTS `friends`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `friends` (
`user1_id` varchar(15) NOT NULL,
`user2_id` varchar(15) NOT NULL,
`time_create` date DEFAULT NULL,
PRIMARY KEY (`user1_id`,`user2_id`),
KEY `fl_user2_friend_idx` (`user2_id`),
CONSTRAINT `fk_user1_friend` FOREIGN KEY (`user1_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fl_user2_friend` FOREIGN KEY (`user2_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `message`
--
DROP TABLE IF EXISTS `message`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `message` (
`sender_id` varchar(15) NOT NULL,
`receiver_id` varchar(15) NOT NULL,
`send_tiem` date DEFAULT NULL,
`content` longtext,
`img` longtext,
`video` longtext,
KEY `fk_sender_id_idx` (`sender_id`),
KEY `fk-reciever_id_idx` (`receiver_id`),
CONSTRAINT `fk-reciever_id` FOREIGN KEY (`receiver_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_sender_id` FOREIGN KEY (`sender_id`) REFERENCES `user` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `post`
--
DROP TABLE IF EXISTS `post`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `post` (
`post_id` varchar(15) NOT NULL,
`userpost_id` varchar(15) DEFAULT NULL,
`time_post` date DEFAULT NULL,
`content` longtext,
`img` longtext,
`video` longtext,
PRIMARY KEY (`post_id`),
KEY `post_fk_idx` (`userpost_id`),
CONSTRAINT `post_fk` FOREIGN KEY (`userpost_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user` (
`user_id` varchar(15) NOT NULL,
`username` varchar(45) DEFAULT NULL,
`password` varchar(15) DEFAULT NULL,
`email` longtext,
`avatar` longtext,
`birthday` date DEFAULT NULL,
`token` varchar(45) DEFAULT NULL,
`city` varchar(25) DEFAULT NULL,
`job` varchar(25) DEFAULT NULL,
`sex` bit(1) DEFAULT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-05-13 8:56:16
| true |
25c5dfbcbb8043bf122529423c06694847c0260c | SQL | CarlosGabrielGomez/mysql-example | /script-biblioteca.sql | UTF-8 | 1,587 | 3.90625 | 4 | [] | no_license | --dbb-biblioteca
--1. Precio promedio de los libros de Salamandra
SELECT editoriales.nombre,avg(libros.precio)as 'precio promedio' from libros inner join editoriales on libros.id_editorial=editoriales.id_editorial GROUP by editoriales.nombre
SELECT editoriales.nombre,avg(libros.precio)as 'precio promedio' from libros inner join editoriales on libros.id_editorial=editoriales.id_editorial GROUP by editoriales.nombre having editoriales.nombre='Salamandra'
--2. Mostrar cantidad de libros de cada editorial (cantidad | editorial)
SELECT editoriales.nombre ,COUNT(libros.id_editorial) 'libros por editorial' from libros inner join editoriales on libros.id_editorial=editoriales.id_editorial GROUP by editoriales.nombre
--3. ¿Cuál es el libro más barato de la editorial Alfaguara?
SELECT libros.titulo,libros.precio,editoriales.nombre from libros inner join editoriales on libros.id_editorial=editoriales.id_editorial WHERE editoriales.nombre='Alfaguara' ORDER by libros.precio ASC LIMIT 1
--4. Mostrar título, autor y precio del libro junto a una columna que indique si es caro (precio > 450) o barato (precio < 450)
SELECT libros.titulo,libros.autor,.libros.precio ,if(libros.precio>450,'caro','barato') from libros
--5. Mostrar los libros de la editorial Paidos que salgan menos de $600. El resultado a mostrar debe ser: titulo| autor | precio| editorial
SELECT libros.titulo,libros.autor,.libros.precio,editoriales.nombre FROM libros inner join editoriales on libros.id_editorial=editoriales.id_editorial where editoriales.nombre='Paidos' and libros.precio<600 | true |
5aa52e249ae5ec5f4649438ae7bde6d1db158775 | SQL | Nevercomes/TaBook | /db/ta_book.sql | UTF-8 | 41,398 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | /*
Navicat Premium Data Transfer
Source Server : Terminal
Source Server Type : MySQL
Source Server Version : 100135
Source Host : localhost:3306
Source Schema : ta_book
Target Server Type : MySQL
Target Server Version : 100135
File Encoding : 65001
Date: 27/03/2019 15:00:27
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for book_borrow_buy
-- ----------------------------
DROP TABLE IF EXISTS `book_borrow_buy`;
CREATE TABLE `book_borrow_buy` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`status` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '借书申请的状态',
`requester_words` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '申请者借书申请的留言',
`requester_words_done` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '借书者对所有者的评价、留言',
`requester_give_score` decimal(2, 2) NULL DEFAULT NULL COMMENT '借书者对所有者的打分',
`owner_words_done` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所有者对借书者的评价、留言',
`owner_give_score` decimal(2, 2) NULL DEFAULT NULL COMMENT '所有者对借书者的打分',
`cancel` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '申请者撤销请求标记',
`type` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '借书1 买书2',
`book_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '指向书籍实例副本的指针',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_comment_long
-- ----------------------------
DROP TABLE IF EXISTS `book_comment_long`;
CREATE TABLE `book_comment_long` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`title` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`score` decimal(2, 2) NULL DEFAULT NULL,
`like_num` decimal(10, 0) NULL DEFAULT NULL,
`school_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '学校id/冗余',
`book_root_id` int(11) NULL DEFAULT NULL COMMENT '一级书籍id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_comment_reply
-- ----------------------------
DROP TABLE IF EXISTS `book_comment_reply`;
CREATE TABLE `book_comment_reply` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`book_comment_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '指向长书评的指针',
`like_num` decimal(10, 0) NULL DEFAULT NULL,
`school_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '学校id/冗余',
`content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_comment_short
-- ----------------------------
DROP TABLE IF EXISTS `book_comment_short`;
CREATE TABLE `book_comment_short` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`score` decimal(2, 2) NULL DEFAULT NULL,
`like_num` decimal(10, 0) NULL DEFAULT NULL COMMENT '点赞数',
`school_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '学校id/冗余',
`book_root_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '一级书籍id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_index_borrow
-- ----------------------------
DROP TABLE IF EXISTS `book_index_borrow`;
CREATE TABLE `book_index_borrow` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`book_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`status` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '1' COMMENT '是否处于显示状态 显示1(默认) 不显示0',
`expired_time` datetime(0) NULL DEFAULT NULL COMMENT '设置的失效时间',
`sort` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '可能存在的排序',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_index_buy
-- ----------------------------
DROP TABLE IF EXISTS `book_index_buy`;
CREATE TABLE `book_index_buy` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`book_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`status` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否处于显示状态 显示1(默认) 不显示0',
`expired_time` datetime(0) NULL DEFAULT NULL COMMENT '设置的失效时间',
`sort` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '可能存在的排序',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_index_head
-- ----------------------------
DROP TABLE IF EXISTS `book_index_head`;
CREATE TABLE `book_index_head` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`type` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '推荐的类型 book1 comment2 other3',
`book_class_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`book_comment_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`other_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '跳转到他处的url',
`status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '1' COMMENT '是否处于显示状态 显示1(默认) 不显示0',
`expired_time` datetime(0) NULL DEFAULT NULL COMMENT '设置的失效时间',
`img_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配图的url',
`sort` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '可能存在的排序',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_info_add
-- ----------------------------
DROP TABLE IF EXISTS `book_info_add`;
CREATE TABLE `book_info_add` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`book_root_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '指向book_root的指针',
`book_class_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '指向book_class的指针',
`name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`author` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`press` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`year` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`owner_comment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '书籍上传时所有者留下的评价,可修改',
`type` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '书籍上架类型,0下架,1借书,2卖书',
`price` decimal(4, 2) NULL DEFAULT NULL COMMENT '上架卖书,书籍价格',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_info_class
-- ----------------------------
DROP TABLE IF EXISTS `book_info_class`;
CREATE TABLE `book_info_class` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NOT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`book_root_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '指向root的指针',
`ISBN` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`version` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '版本 (第几版)不一定输入 可能在 root以名字输入',
`press` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出版社',
`year` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '年份',
`score` decimal(2, 2) NULL DEFAULT NULL COMMENT '分数',
`intro` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '简介',
`img_url` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图片url',
PRIMARY KEY (`id`) USING BTREE,
INDEX `index1`(`book_root_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_info_instance
-- ----------------------------
DROP TABLE IF EXISTS `book_info_instance`;
CREATE TABLE `book_info_instance` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`book_class_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '指向class的指针',
`user_add_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '指向book_user_add的指针',
`owner_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '书籍所有者id',
`holder_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '书籍当前持有者的id',
`school_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '学校id/额外冗余',
`campus_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '校区id',
`status` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '书籍当前状态',
`like_num` decimal(10, 0) NULL DEFAULT NULL COMMENT '书籍获赞数',
`total_borrowed` decimal(10, 0) NULL DEFAULT NULL COMMENT '书籍累计借阅 冗余',
PRIMARY KEY (`id`) USING BTREE,
INDEX `index1`(`book_class_id`) USING BTREE,
INDEX `index2`(`owner_id`) USING BTREE,
INDEX `index3`(`holder_id`) USING BTREE,
INDEX `index4`(`school_id`) USING BTREE,
INDEX `index5`(`user_add_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_info_root
-- ----------------------------
DROP TABLE IF EXISTS `book_info_root`;
CREATE TABLE `book_info_root` (
`id` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '书名',
`author` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '作者',
`sort_seq` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '分类序列 定长01字符串',
`represent_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'book_class代表root的id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_user_favorites
-- ----------------------------
DROP TABLE IF EXISTS `book_user_favorites`;
CREATE TABLE `book_user_favorites` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`book_class_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`type` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收藏类型',
`book_comment_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '长书评id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for book_user_info
-- ----------------------------
DROP TABLE IF EXISTS `book_user_info`;
CREATE TABLE `book_user_info` (
`id` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '指向sys_user的指针',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名',
`credit_score` decimal(10, 0) NULL DEFAULT NULL COMMENT '信誉分数',
PRIMARY KEY (`id`) USING BTREE,
INDEX `index1`(`user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for msg_notice
-- ----------------------------
DROP TABLE IF EXISTS `msg_notice`;
CREATE TABLE `msg_notice` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
`create_time` datetime(0) NOT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`type` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '类型',
`title` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标题',
`content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '内容',
`status` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '状态',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for msg_notice_record
-- ----------------------------
DROP TABLE IF EXISTS `msg_notice_record`;
CREATE TABLE `msg_notice_record` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`msg_notice_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '通知通告ID',
`user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '接受人',
`read_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0' COMMENT '阅读标记',
`read_time` datetime(0) NULL DEFAULT NULL COMMENT '阅读时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `index1`(`msg_notice_id`) USING BTREE,
INDEX `index2`(`user_id`) USING BTREE,
INDEX `index3`(`read_flag`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_area
-- ----------------------------
DROP TABLE IF EXISTS `sys_area`;
CREATE TABLE `sys_area` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '编号',
`parent_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '父级编号',
`parent_ids` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所有父级编号',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称',
`sort` decimal(10, 0) NOT NULL COMMENT '排序',
`code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区域编码',
`type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区域类型',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`create_date` datetime(0) NOT NULL COMMENT '创建时间',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新者',
`update_date` datetime(0) NOT NULL COMMENT '更新时间',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注信息',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`) USING BTREE,
INDEX `sys_area_parent_id`(`parent_id`) USING BTREE,
INDEX `sys_area_del_flag`(`del_flag`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '区域表' ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_dict
-- ----------------------------
DROP TABLE IF EXISTS `sys_dict`;
CREATE TABLE `sys_dict` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '编号',
`value` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '数据值',
`label` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '标签名',
`type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '类型',
`description` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '描述',
`sort` decimal(10, 0) NOT NULL COMMENT '排序(升序)',
`parent_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '父级编号',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`create_date` datetime(0) NOT NULL COMMENT '创建时间',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新者',
`update_date` datetime(0) NOT NULL COMMENT '更新时间',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注信息',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`) USING BTREE,
INDEX `sys_dict_value`(`value`) USING BTREE,
INDEX `sys_dict_label`(`label`) USING BTREE,
INDEX `sys_dict_del_flag`(`del_flag`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '字典表' ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_log
-- ----------------------------
DROP TABLE IF EXISTS `sys_log`;
CREATE TABLE `sys_log` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '编号',
`type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '1' COMMENT '日志类型',
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '日志标题',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
`create_date` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`remote_addr` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作IP地址',
`user_agent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户代理',
`request_uri` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求URI',
`method` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作方式',
`params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '操作提交的数据',
`exception` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '异常信息',
PRIMARY KEY (`id`) USING BTREE,
INDEX `sys_log_create_by`(`create_by`) USING BTREE,
INDEX `sys_log_request_uri`(`request_uri`(191)) USING BTREE,
INDEX `sys_log_type`(`type`) USING BTREE,
INDEX `sys_log_create_date`(`create_date`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '日志表' ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_mdict
-- ----------------------------
DROP TABLE IF EXISTS `sys_mdict`;
CREATE TABLE `sys_mdict` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '编号',
`parent_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '父级编号',
`parent_ids` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所有父级编号',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称',
`sort` decimal(10, 0) NOT NULL COMMENT '排序',
`description` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`create_date` datetime(0) NOT NULL COMMENT '创建时间',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新者',
`update_date` datetime(0) NOT NULL COMMENT '更新时间',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注信息',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`) USING BTREE,
INDEX `sys_mdict_parent_id`(`parent_id`) USING BTREE,
INDEX `sys_mdict_del_flag`(`del_flag`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '多级字典表' ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_menu
-- ----------------------------
DROP TABLE IF EXISTS `sys_menu`;
CREATE TABLE `sys_menu` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '编号',
`parent_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '父级编号',
`parent_ids` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所有父级编号',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称',
`sort` decimal(10, 0) NOT NULL COMMENT '排序',
`href` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '链接',
`target` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '目标',
`icon` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图标',
`is_show` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '是否在菜单中显示',
`permission` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限标识',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`create_date` datetime(0) NOT NULL COMMENT '创建时间',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新者',
`update_date` datetime(0) NOT NULL COMMENT '更新时间',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注信息',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`) USING BTREE,
INDEX `sys_menu_parent_id`(`parent_id`) USING BTREE,
INDEX `sys_menu_del_flag`(`del_flag`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单表' ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_office
-- ----------------------------
DROP TABLE IF EXISTS `sys_office`;
CREATE TABLE `sys_office` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '编号',
`parent_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '父级编号',
`parent_ids` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所有父级编号',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称',
`sort` decimal(10, 0) NOT NULL COMMENT '排序',
`area_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '归属区域',
`code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区域编码',
`type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '机构类型',
`grade` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '机构等级',
`address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系地址',
`zip_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮政编码',
`master` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '负责人',
`phone` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '电话',
`fax` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '传真',
`email` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱',
`USEABLE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否启用',
`PRIMARY_PERSON` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '主负责人',
`DEPUTY_PERSON` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '副负责人',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`create_date` datetime(0) NOT NULL COMMENT '创建时间',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新者',
`update_date` datetime(0) NOT NULL COMMENT '更新时间',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注信息',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`) USING BTREE,
INDEX `sys_office_parent_id`(`parent_id`) USING BTREE,
INDEX `sys_office_del_flag`(`del_flag`) USING BTREE,
INDEX `sys_office_type`(`type`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '机构表' ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '编号',
`office_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '归属机构',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色名称',
`enname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '英文名称',
`role_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色类型',
`data_scope` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据范围',
`is_sys` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否系统数据',
`useable` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否可用',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`create_date` datetime(0) NOT NULL COMMENT '创建时间',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新者',
`update_date` datetime(0) NOT NULL COMMENT '更新时间',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注信息',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`) USING BTREE,
INDEX `sys_role_del_flag`(`del_flag`) USING BTREE,
INDEX `sys_role_enname`(`enname`(191)) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色表' ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_role_menu
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_menu`;
CREATE TABLE `sys_role_menu` (
`role_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色编号',
`menu_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '菜单编号',
PRIMARY KEY (`role_id`, `menu_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色-菜单' ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_role_office
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_office`;
CREATE TABLE `sys_role_office` (
`role_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色编号',
`office_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '机构编号',
PRIMARY KEY (`role_id`, `office_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色-机构' ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
`id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '编号',
`company_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '归属公司',
`office_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '归属部门',
`login_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '登录名',
`password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码',
`no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工号',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '姓名',
`email` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱',
`phone` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '电话',
`mobile` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机',
`user_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户类型',
`photo` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户头像',
`login_ip` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最后登陆IP',
`login_date` datetime(0) NULL DEFAULT NULL COMMENT '最后登陆时间',
`login_flag` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否可登录',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建者',
`create_date` datetime(0) NOT NULL COMMENT '创建时间',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新者',
`update_date` datetime(0) NOT NULL COMMENT '更新时间',
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注信息',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`) USING BTREE,
INDEX `sys_user_office_id`(`office_id`) USING BTREE,
INDEX `sys_user_login_name`(`login_name`) USING BTREE,
INDEX `sys_user_company_id`(`company_id`) USING BTREE,
INDEX `sys_user_update_date`(`update_date`) USING BTREE,
INDEX `sys_user_del_flag`(`del_flag`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户表' ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for sys_user_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_role`;
CREATE TABLE `sys_user_role` (
`user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户编号',
`role_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色编号',
PRIMARY KEY (`user_id`, `role_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户-角色' ROW_FORMAT = Compact;
SET FOREIGN_KEY_CHECKS = 1;
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.