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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ca0d07b4505f1afa546e65c633869e8639b6a0e4 | SQL | oogiisar/notourbackyard-server | /migrations/005.do.create_cleanups.sql | UTF-8 | 307 | 2.515625 | 3 | [] | no_license | CREATE TABLE cleanups (
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
location INTEGER REFERENCES region(id) NOT NULL,
user_name INTEGER REFERENCES users(id) NOT NULL,
date TIMESTAMP NOT NULL DEFAULT now(),
type_of_trash garbage_type NOT NULL,
quantity INTEGER NOT NULL
); | true |
4def0b260115d65766b733c202e2c2413d3acb4e | SQL | ArrettB/omni-workspace | /servicetrax/ims/initial_trace_plans/view-invoices/customer_name_lookup.sql | UTF-8 | 156 | 2.796875 | 3 | [] | no_license | SELECT DISTINCT iev.customer_name, iev.customer_name
FROM invoices_extranet_v iev
WHERE iev.organization_id = 2
ORDER BY iev.customer_name | true |
535e0d67fdd0c46fb91a406c62f603ab50916414 | SQL | zhangyu2222z/JAVA-000 | /Week_09/bizuo_homework2/4.sql | UTF-8 | 1,126 | 2.734375 | 3 | [] | no_license | /*
SQLyog Ultimate v12.09 (64 bit)
MySQL - 5.7.32-log : Database - db1
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`db1` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `db1`;
/*Table structure for table `t_freeze1` */
DROP TABLE IF EXISTS `t_freeze1`;
CREATE TABLE `t_freeze1` (
`acctid` int(32) NOT NULL,
`rmb` decimal(12,4) NOT NULL DEFAULT '0.0000',
`dollar` decimal(12,4) NOT NULL DEFAULT '0.0000'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `t_freeze1` */
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
| true |
b72e39c977180be8d3287c0438e34a59e01f1a7e | SQL | PetrovPetar5/Databases-MSSQL-EntityFramework-SoftUni-Problems | /MSSQL/Exams/ExamTwentySeventhJune/TwentySeventhJune/6.CurrentClients.sql | UTF-8 | 259 | 3.828125 | 4 | [] | no_license | SELECT CONCAT(C.FirstName,' ',C.LastName) AS [Client],ABS(DATEDIFF(DAY,'2017/04/24',J.IssueDate)) AS [Days going], J.[Status] FROM JOBS AS J
JOIN Clients AS C ON J.ClientId = C.ClientId
WHERE J.FinishDate IS NULL
ORDER BY [Days going] DESC, C.ClientId ASC | true |
96b8aadb8106b32028338631d3c4ea116439a333 | SQL | ipf-tlp-2019/MiSalud | /SQL_BD/bd_sistema_medico.sql | UTF-8 | 8,006 | 2.96875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 02-08-2019 a las 08:17:31
-- Versión del servidor: 10.1.38-MariaDB
-- Versión de 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 */;
--
-- Base de datos: `bd_sistema_medico`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `departamento`
--
CREATE TABLE `departamento` (
`ID_DEPARTAMENTO` int(11) NOT NULL,
`DESCRI_:DEPARTAMENTO` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `departamento_medico`
--
CREATE TABLE `departamento_medico` (
`ID_DEPARTAMENTO_MEDICO` int(11) NOT NULL,
`DESCRI_DEPARTAMENTO_MEDICO` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `direccion`
--
CREATE TABLE `direccion` (
`ID_DIRECCION` int(11) NOT NULL,
`DESCRI_DIRECCION` varchar(45) NOT NULL,
`RELA_LOCALIDAD` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `grupo_sanguinio`
--
CREATE TABLE `grupo_sanguinio` (
`ID_GRUPO_SANGUINEO` int(11) NOT NULL,
`DESCRI_GRUPO_SANGUINEO` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `historial_medico`
--
CREATE TABLE `historial_medico` (
`ID_HISTORIAL_MEDICO` int(11) NOT NULL,
`RELA_DEPARTAMENTO_MEDICO` int(11) NOT NULL,
`DESCRI_TIPO_ESTUDIO` varchar(45) NOT NULL,
`FECHA_HISTORIAL_MEDICO` date NOT NULL,
`ARCHIVO_ADJ_HISTORIAL_MEDICO` blob,
`RELA_INSTITUCION_MEDICA` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `institucion_medica`
--
CREATE TABLE `institucion_medica` (
`ID_INSTITUCION_MEDICA` int(11) NOT NULL,
`DESCRI_INTITUCION_MEDICA` varchar(45) NOT NULL,
`RELA_DIRECCION` int(11) NOT NULL,
`RELA_TELEFONO` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `localidad`
--
CREATE TABLE `localidad` (
`ID_LOCALIDAD` int(11) NOT NULL,
`DESCRI_LOCALIDAD` varchar(45) NOT NULL,
`RELA_DEPARTAMENTO` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `medico_asociado`
--
CREATE TABLE `medico_asociado` (
`ID_MEDICO_ASOCIADO` int(11) NOT NULL,
`NOMBRE_MEDICO` varchar(45) NOT NULL,
`APELLIDO_MEDICO` varchar(45) NOT NULL,
`MATRICULA_MEDICO` int(10) NOT NULL,
`ESPECIALIDAD_MEDICO` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `medico_asociado`
--
INSERT INTO `medico_asociado` (`ID_MEDICO_ASOCIADO`, `NOMBRE_MEDICO`, `APELLIDO_MEDICO`, `MATRICULA_MEDICO`, `ESPECIALIDAD_MEDICO`) VALUES
(1, 'Juan ', 'Perez', 48596, 'Medico Cirujano'),
(2, 'Josefina', 'Ramirez', 98324, 'Radiología '),
(3, 'Tomas ', 'Caporal', 78165, 'Kinesiología '),
(4, 'Agustina ', 'Delgado', 58469, 'Ginecología '),
(5, 'Gastón Francisco', 'Lovera ', 84695, 'Cardiología '),
(6, 'René', 'Favaloro', 65987, 'Medico Cirujano');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `persona`
--
CREATE TABLE `persona` (
`ID_PERSONA` int(11) NOT NULL,
`NOMBRE_PERSONA` varchar(45) NOT NULL,
`APELLIDO_PERSONA` varchar(45) NOT NULL,
`FECHA_NAC_PERSONA` date NOT NULL,
`RELA_DIRECCION` int(11) NOT NULL,
`RELA_GRUPO_SANGUINEO` int(11) NOT NULL,
`DESCRI_ALERGIAS` varchar(45) NOT NULL,
`DONANTE_PERSONA` varchar(1) NOT NULL,
`RELA_HISTORIAL_MEDICO` int(11) NOT NULL,
`RELA_TELEFONO` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `telefono`
--
CREATE TABLE `telefono` (
`ID_TELEFONO` int(11) NOT NULL,
`NRO_TELEFONO` int(11) NOT NULL,
`RELA_TIPO_TELEFONO` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `tipo_telefono`
--
CREATE TABLE `tipo_telefono` (
`ID_TIPO_TELEFONO` int(11) NOT NULL,
`DESCRI_TIPO_TELEFONO` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `usuario`
--
CREATE TABLE `usuario` (
`ID_USUARIO` int(10) NOT NULL,
`NOMBRE_USUARIO` varchar(10) NOT NULL,
`APELLIDO_USUARIO` varchar(20) NOT NULL,
`CORREO_USUARIO` varchar(30) NOT NULL,
`PASSWORD_USUARIO` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `usuario`
--
INSERT INTO `usuario` (`ID_USUARIO`, `NOMBRE_USUARIO`, `APELLIDO_USUARIO`, `CORREO_USUARIO`, `PASSWORD_USUARIO`) VALUES
(1, 'Alejandro', 'Bernal', 'alebernalmatias@gmail.com', '1234'),
(2, 'Anabel', 'Arguello', 'anabel@gmail.com', '1234'),
(3, 'Alejandro', 'Sanabria', 'aalesann@gmail.com', '1234');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `usuarios`
--
CREATE TABLE `usuarios` (
`ID_USUARIOS` int(11) NOT NULL,
`NOMBRE_USUARIOS` varchar(45) NOT NULL,
`PASSWORD_USUARIOS` varchar(45) NOT NULL,
`RELA_TIPO_USUARIO` int(11) NOT NULL,
`CORREO_USUARIO` varchar(45) NOT NULL,
`RELA_PERSONA` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla `departamento`
--
ALTER TABLE `departamento`
ADD PRIMARY KEY (`ID_DEPARTAMENTO`);
--
-- Indices de la tabla `departamento_medico`
--
ALTER TABLE `departamento_medico`
ADD PRIMARY KEY (`ID_DEPARTAMENTO_MEDICO`);
--
-- Indices de la tabla `direccion`
--
ALTER TABLE `direccion`
ADD PRIMARY KEY (`ID_DIRECCION`);
--
-- Indices de la tabla `grupo_sanguinio`
--
ALTER TABLE `grupo_sanguinio`
ADD PRIMARY KEY (`ID_GRUPO_SANGUINEO`);
--
-- Indices de la tabla `historial_medico`
--
ALTER TABLE `historial_medico`
ADD PRIMARY KEY (`ID_HISTORIAL_MEDICO`);
--
-- Indices de la tabla `institucion_medica`
--
ALTER TABLE `institucion_medica`
ADD PRIMARY KEY (`ID_INSTITUCION_MEDICA`);
--
-- Indices de la tabla `medico_asociado`
--
ALTER TABLE `medico_asociado`
ADD PRIMARY KEY (`ID_MEDICO_ASOCIADO`);
--
-- Indices de la tabla `persona`
--
ALTER TABLE `persona`
ADD PRIMARY KEY (`ID_PERSONA`);
--
-- Indices de la tabla `telefono`
--
ALTER TABLE `telefono`
ADD PRIMARY KEY (`ID_TELEFONO`);
--
-- Indices de la tabla `tipo_telefono`
--
ALTER TABLE `tipo_telefono`
ADD PRIMARY KEY (`ID_TIPO_TELEFONO`);
--
-- Indices de la tabla `usuario`
--
ALTER TABLE `usuario`
ADD PRIMARY KEY (`ID_USUARIO`);
--
-- Indices de la tabla `usuarios`
--
ALTER TABLE `usuarios`
ADD PRIMARY KEY (`ID_USUARIOS`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla `medico_asociado`
--
ALTER TABLE `medico_asociado`
MODIFY `ID_MEDICO_ASOCIADO` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT de la tabla `usuario`
--
ALTER TABLE `usuario`
MODIFY `ID_USUARIO` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
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 |
73b761f0155bd03a4c6d26faa4c342bb789fb611 | SQL | krishnamohankaruturi/secret | /aart-web-dependencies/db/other/DE9175.sql | UTF-8 | 3,419 | 4.03125 | 4 | [] | no_license | --DE 9175 Populating missing group indicator for reading and history
DO
$BODY$
DECLARE
readingRecords RECORD;
historyRecords RECORD;
groupingInd1 character varying(50);
groupingInd2 character varying(50);
testTypeCode character varying(10);
BEGIN
RAISE NOTICE 'Get Reading enrollmenttesttypes';
FOR readingRecords IN (
select enttsa.*, en.studentid, st.statestudentidentifier
from enrollmenttesttypesubjectarea enttsa
join enrollment en on enttsa.enrollmentid = en.id
join student st on en.studentid = st.id
where en.currentschoolyear=2015 and en.activeflag is true
and st.stateid=51 and st.activeflag is true and enttsa.activeflag is true
and enttsa.subjectareaid = 17 and testtypeid in (2,18,19)
and enttsa.groupingindicator1 is null and groupingindicator2 is null
)
LOOP
--RAISE NOTICE 'enrollmenttesttypesubjectarea Id = %, enrollmentid = %, studentid = %', readingRecords.id, readingRecords.enrollmentid, readingRecords.studentid;
--RAISE NOTICE 'groupingInd1 = %, groupingInd2 = %, testTypeCode = %', groupingInd1, groupingInd2, testTypeCode;
groupingInd1 = null;
groupingInd2 = null;
testTypeCode = null;
select grouping_reading_1, grouping_reading_2, state_reading_assess into groupingInd1, groupingInd2, testTypeCode
from kids_record_staging where state_student_identifier=readingRecords.statestudentidentifier
and state_reading_assess in ('2','3','C','c') order by id desc limit 1;
IF (groupingInd1 is not null or groupingInd2 is not null) THEN
RAISE NOTICE 'Updating..with..groupingInd1 = %, groupingInd2 = %, testTypeCode = %', groupingInd1, groupingInd2, testTypeCode;
update enrollmenttesttypesubjectarea
set groupingindicator1=groupingInd1, groupingindicator2=groupingInd2
where id=readingRecords.id;
END IF;
END LOOP;
RAISE NOTICE 'Get history enrollmenttesttypes';
FOR historyRecords IN (
select enttsa.*, en.studentid, st.statestudentidentifier
from enrollmenttesttypesubjectarea enttsa
join enrollment en on enttsa.enrollmentid = en.id
join student st on en.studentid = st.id
where en.currentschoolyear=2015 and en.activeflag is true
and st.stateid=51 and st.activeflag is true and enttsa.activeflag is true
and enttsa.subjectareaid = 20 and testtypeid in (2,18,19)
and enttsa.groupingindicator1 is null and groupingindicator2 is null
)
LOOP
--RAISE NOTICE 'enrollmenttesttypesubjectarea Id = %, enrollmentid = %, studentid = %', historyRecords.id, historyRecords.enrollmentid, historyRecords.studentid;
--RAISE NOTICE 'groupingInd1 = %, groupingInd2 = %, testTypeCode = %', groupingInd1, groupingInd2, testTypeCode;
groupingInd1 = null;
groupingInd2 = null;
testTypeCode = null;
select grouping_history_1, grouping_history_2, state_history_assess into groupingInd1, groupingInd2, testTypeCode
from kids_record_staging where state_student_identifier=historyRecords.statestudentidentifier
and state_history_assess in ('2','3','C','c') order by id desc limit 1;
IF (groupingInd1 is not null or groupingInd2 is not null) THEN
RAISE NOTICE 'Updating..with..groupingInd1 = %, groupingInd2 = %, testTypeCode = %', groupingInd1, groupingInd2, testTypeCode;
update enrollmenttesttypesubjectarea
set groupingindicator1=groupingInd1, groupingindicator2=groupingInd2
where id=historyRecords.id;
END IF;
END LOOP;
END;
$BODY$; | true |
1dbc320ab9c760eb656de975b4e0eee2fc57044b | SQL | pirat77/QuestStoreBackendAndSQL | /QuestStore.sql | UTF-8 | 4,688 | 3.6875 | 4 | [] | no_license | create table user_types
(
id integer not null
constraint user_types_pk
primary key,
name text not null
);
alter table user_types
owner to postgres;
create table teams
(
id serial not null
constraint teams_pk
primary key,
name text not null
);
alter table teams
owner to postgres;
create table students_details
(
id serial not null
constraint students_pk
primary key,
wallet integer not null,
total_money integer not null,
team_id integer not null
constraint team_id
references teams
);
alter table students_details
owner to postgres;
create table users
(
id serial not null
constraint users_pk
primary key,
login text not null,
password text not null,
first_name text not null,
last_name text not null,
is_active boolean not null,
user_type_id integer not null
constraint user_type_id
references user_types,
student_id integer
constraint student_id
references students_details
);
alter table users
owner to postgres;
create unique index users_id_uindex
on users (id);
create unique index users_login_uindex
on users (login);
create unique index students_id_uindex
on students_details (id);
create unique index teams_id_uindex
on teams (id);
create table classrooms
(
id serial not null
constraint classrooms_pk
primary key,
name text not null
);
alter table classrooms
owner to postgres;
create unique index classrooms_id_uindex
on classrooms (id);
create table levels
(
id serial not null
constraint levels_pk
primary key,
name text not null,
value integer not null
);
alter table levels
owner to postgres;
create unique index levels_id_uindex
on levels (id);
create table users_classrooms
(
mentor_id integer not null
constraint mentor_id
references users,
classroom_id integer not null
constraint classroom_id
references classrooms
);
alter table users_classrooms
owner to postgres;
create table quests
(
id serial not null
constraint quests_pk
primary key,
name text not null,
description text not null,
value integer not null,
category_id integer not null
);
alter table quests
owner to postgres;
create unique index quests_id_uindex
on quests (id);
create table students_details_quests
(
student_id integer not null
constraint student_id
references students_details,
quest_id integer not null
constraint quest_id
references quests,
date date not null
);
alter table students_details_quests
owner to postgres;
create table categories
(
id serial not null
constraint categories_pk
primary key,
name text
);
alter table categories
owner to postgres;
create unique index categories_id_uindex
on categories (id);
create table artifacts
(
id serial not null
constraint artifacts_pk
primary key,
name text not null,
description text not null,
value integer not null,
category_id integer not null
constraint category_id
references categories
);
alter table artifacts
owner to postgres;
create unique index artifacts_id_uindex
on artifacts (id);
create table students_details_artifacts
(
student_id integer not null
constraint student_id
references students_details,
artifact_id integer not null
constraint artifact_id
references artifacts,
date date
);
alter table students_details_artifacts
owner to postgres;
create table whiprounds
(
id serial not null
constraint whiprounds_pk
primary key,
name integer not null,
artifact_id integer not null
constraint artifact_id
references artifacts
);
alter table whiprounds
owner to postgres;
create unique index whiprounds_id_uindex
on whiprounds (id);
create table students_details_whiprounds
(
student_id integer not null
constraint student_id
references students_details,
whipround_id integer not null
constraint whipround_id
references whiprounds,
value integer not null,
date date not null
);
alter table students_details_whiprounds
owner to postgres;
| true |
702280e7ff277c581821a553743b70c3dc91a8b9 | SQL | aforrester08/Spending-Tracker-App | /db/spending_tracker.sql | UTF-8 | 483 | 3.234375 | 3 | [] | no_license | DROP TABLE transactions;
DROP TABLE merchants;
DROP TABLE tags;
DROP TABLE budget;
CREATE TABLE budget (
id SERIAL8 PRIMARY KEY,
amount INT8
);
CREATE TABLE tags (
id SERIAL8 PRIMARY KEY,
type VARCHAR(255)
);
CREATE TABLE merchants (
id SERIAL8 PRIMARY KEY,
name VARCHAR(255)
);
CREATE TABLE transactions (
id SERIAL8 PRIMARY KEY,
merchant_id INT8 REFERENCES merchants(id),
tag_id INT8 REFERENCES tags(id),
amount INT8,
time_stmp timestamp DEFAULT now()
);
| true |
c0e0d3219fc8c6d2938523725f552aa397b39001 | SQL | hannanyusop/ezprint | /database.sql | UTF-8 | 7,529 | 3.53125 | 4 | [] | no_license | -- --------------------------------------------------------
-- Host: localhost
-- Server version: 5.7.24 - MySQL Community Server (GPL)
-- Server OS: Win64
-- HeidiSQL Version: 9.5.0.5332
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-- Dumping database structure for ezprint
DROP DATABASE IF EXISTS `ezprint`;
CREATE DATABASE IF NOT EXISTS `ezprint` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `ezprint`;
-- Dumping structure for table ezprint.accounts
DROP TABLE IF EXISTS `accounts`;
CREATE TABLE IF NOT EXISTS `accounts` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) unsigned NOT NULL,
`credit_balance` float(10,2) NOT NULL DEFAULT '0.00',
`credit_total` float(10,2) NOT NULL DEFAULT '0.00',
`address` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_accounts_users` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
-- Dumping data for table ezprint.accounts: ~0 rows (approximately)
/*!40000 ALTER TABLE `accounts` DISABLE KEYS */;
INSERT INTO `accounts` (`id`, `user_id`, `credit_balance`, `credit_total`, `address`) VALUES
(1, 3, 0.00, 0.00, '');
/*!40000 ALTER TABLE `accounts` ENABLE KEYS */;
-- Dumping structure for table ezprint.add_on
DROP TABLE IF EXISTS `add_on`;
CREATE TABLE IF NOT EXISTS `add_on` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`description` varchar(255) DEFAULT NULL,
`price` float(10,2) NOT NULL DEFAULT '0.00',
`is_active` smallint(1) NOT NULL DEFAULT '0',
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
-- Dumping data for table ezprint.add_on: ~0 rows (approximately)
/*!40000 ALTER TABLE `add_on` DISABLE KEYS */;
INSERT INTO `add_on` (`id`, `name`, `description`, `price`, `is_active`, `updated_at`) VALUES
(1, 'BINDING', '', 1.00, 1, NULL),
(2, 'DELIVERY', '', 2.00, 1, NULL),
(3, 'HARD COVER', '', 5.00, 1, NULL);
/*!40000 ALTER TABLE `add_on` ENABLE KEYS */;
-- Dumping structure for table ezprint.credit_transaction
DROP TABLE IF EXISTS `credit_transaction`;
CREATE TABLE IF NOT EXISTS `credit_transaction` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`account_id` int(11) NOT NULL,
`job_id` int(11) NOT NULL DEFAULT '0',
`staff_id` int(11) unsigned NOT NULL,
`type` int(11) DEFAULT NULL,
`amount` double NOT NULL DEFAULT '0',
`current_balance` double NOT NULL DEFAULT '0',
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_credit_transaction_users` (`staff_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Dumping data for table ezprint.credit_transaction: ~0 rows (approximately)
/*!40000 ALTER TABLE `credit_transaction` DISABLE KEYS */;
/*!40000 ALTER TABLE `credit_transaction` ENABLE KEYS */;
-- Dumping structure for table ezprint.jobs
DROP TABLE IF EXISTS `jobs`;
CREATE TABLE IF NOT EXISTS `jobs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) NOT NULL,
`staff_id` int(11) NOT NULL,
`file` varchar(255) NOT NULL,
`total_page` int(11) NOT NULL DEFAULT '1',
`printing_mode` int(11) NOT NULL DEFAULT '1',
`printing_mode_price` double(10,2) NOT NULL DEFAULT '0.00',
`notes` longtext,
`status` int(11) NOT NULL DEFAULT '1',
`total_price` double(10,2) NOT NULL DEFAULT '0.00',
`pickup_code` varchar(50) DEFAULT NULL,
`pickup_date` timestamp NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`completed_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Dumping data for table ezprint.jobs: ~0 rows (approximately)
/*!40000 ALTER TABLE `jobs` DISABLE KEYS */;
/*!40000 ALTER TABLE `jobs` ENABLE KEYS */;
-- Dumping structure for table ezprint.jobs_has_add_on
DROP TABLE IF EXISTS `jobs_has_add_on`;
CREATE TABLE IF NOT EXISTS `jobs_has_add_on` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_id` int(11) NOT NULL,
`add_on_id` int(11) NOT NULL,
`price` double(10,2) DEFAULT '0.00',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Dumping data for table ezprint.jobs_has_add_on: ~0 rows (approximately)
/*!40000 ALTER TABLE `jobs_has_add_on` DISABLE KEYS */;
/*!40000 ALTER TABLE `jobs_has_add_on` ENABLE KEYS */;
-- Dumping structure for table ezprint.options
DROP TABLE IF EXISTS `options`;
CREATE TABLE IF NOT EXISTS `options` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`value` varchar(255) DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
-- Dumping data for table ezprint.options: ~2 rows (approximately)
/*!40000 ALTER TABLE `options` DISABLE KEYS */;
INSERT INTO `options` (`id`, `name`, `value`, `updated_at`) VALUES
(1, 'price_black_and_white', '0.20', '2019-11-15 21:19:28'),
(2, 'price_colour', '0.50', '2019-11-15 21:34:21');
/*!40000 ALTER TABLE `options` ENABLE KEYS */;
-- Dumping structure for table ezprint.roles
DROP TABLE IF EXISTS `roles`;
CREATE TABLE IF NOT EXISTS `roles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
-- Dumping data for table ezprint.roles: ~3 rows (approximately)
/*!40000 ALTER TABLE `roles` DISABLE KEYS */;
INSERT INTO `roles` (`id`, `name`) VALUES
(3, 'customer'),
(1, 'manager'),
(2, 'staff');
/*!40000 ALTER TABLE `roles` ENABLE KEYS */;
-- Dumping structure for table ezprint.users
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`role_id` int(11) NOT NULL DEFAULT '3',
`email` varchar(50) NOT NULL,
`password` varchar(255) DEFAULT NULL,
`reset_password_key` varchar(255) DEFAULT NULL,
`fullname` varchar(50) DEFAULT NULL,
`last_login_at` datetime DEFAULT NULL,
`last_ip_address` varchar(50) DEFAULT NULL,
`is_active` smallint(1) NOT NULL DEFAULT '0',
`is_confirm` smallint(1) NOT NULL DEFAULT '0',
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
-- Dumping data for table ezprint.users: ~1 rows (approximately)
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` (`id`, `role_id`, `email`, `password`, `reset_password_key`, `fullname`, `last_login_at`, `last_ip_address`, `is_active`, `is_confirm`, `created_at`) VALUES
(1, 1, 'admin@ezprint.my', '$2y$12$sAdS7Z4PX.PW0JIG.oSTT.eCm12XjEd8CVKTcyQBY8NosPCtNCK1m', NULL, 'MANAGER EZPRINT', '2019-11-17 13:42:36', '127.0.0.1', 1, 1, '2019-11-17 13:40:59'),
(2, 2, 'staff@ezprint.my', '$2y$10$QVzz61ytFRUnIX0owe.yb.wU4PFKly4HrXcyfwNmIC/tjoqdUBF32', NULL, '', NULL, NULL, 1, 1, '2019-11-17 13:45:56'),
(3, 3, 'customer@test.my', '$2y$10$/ZZMXLD11qhKfhzyaLa.CuuLmuw3pUeMm7JX/p5GQ5mxOdxc7iLzq', NULL, 'CUSTOMER DEFAULT', NULL, NULL, 1, 1, '2019-11-17 14:07:15');
/*!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 |
13aece63d072023745eec0f24f1e552456bf977e | SQL | yang00333/data_class_0420 | /Homework-sql.sql | UTF-8 | 23,591 | 4.125 | 4 | [] | no_license |
-- 1. Prepare a list of offices sorted by country, state, city.
SELECT country, state, city
FROM classicmodels.offices;
-- 2. How many employees are there in the company?
SELECT count(employeenumber)
FROM classicmodels.employees;
-- 3. What is the total of payments received?
SELECT sum(amount)
FROM classicmodels.payments;
-- 4. List the product lines that contain 'Cars'.
SELECT productLine
FROM classicmodels.productlines
Where productLine like '%Cars%';
-- 5. Report total payments for October 28, 2004.
SELECT sum(amount)
FROM classicmodels.payments
WHERE paymentDate = '2004-10-28';
-- 6. Report those payments greater than $100,000.
SELECT *
FROM classicmodels.payments
WHERE amount < 100000;
-- 7. List the products in each product line.
SELECT *
FROM classicmodels.products
ORDER BY productLine;
-- 8. How many products in each product line?
SELECT productLine, count(productCode) as product_quantity
FROM classicmodels.products
GROUP BY productLine
ORDER BY product_quantity DESC;
-- 9. What is the minimum payment received?
SELECT min(amount)
FROM classicmodels.payments;
-- 10. List all payments greater than twice the average payment.
SELECT amount
FROM classicmodels.payments
WHERE amount > 2 * (select avg(amount) from classicmodels.payments);
-- 11. What is the average percentage markup of the MSRP on buyPrice?
SELECT (avg(MSRP) - avg(buyPrice))/avg(buyPrice)
FROM classicmodels.products;
-- 12. How many distinct products does ClassicModels sell?
SELECT count(productCode)
FROM classicmodels.products;
-- 13. Report the name and city of customers who don't have sales representatives?
SELECT CustomerName, city
FROM classicmodels.customers
WHERE salesRepEmployeeNumber IS NULL;
-- 14. What are the names of executives with VP or Manager in their title? Use the CONCAT function to combine the employee's first name and last name into a single field for reporting.
SELECT concat(firstName, lastName)
FROM classicmodels.employees
WHERE jobTitle like '%VP%' or jobTitle like '%Manager%';
-- 15. Which orders have a value greater than $5,000?
SELECT *
FROM classicmodels.payments
WHERE amount > 5000
ORDER BY amount;
having total_value>5000;
-- One to many relationship
-- 1. Report the account representative for each customer.
select customername, concat(firstname,' ',lastname) as salesRep_name from customers c, employees e
where c.salesrepemployeenumber=e.employeenumber;
-- 2. Report total payments for Atelier graphique.
select customername, sum(amount) as total_payment from payments p, customers c
where c.customernumber=p.customernumber
and customername='Atelier graphique';
-- 3. Report the total payments by date
select sum(amount) as total_payment, paymentdate from payments
group by paymentdate;
-- 4. Report the products that have not been sold.
select productname from products p
where p.productcode not in (select distinct productcode from orderdetails);
-- 5. List the amount paid by each customer.
select customername, sum(amount) as total_amount from customers c, payments p
where p.customernumber=c.customernumber
group by customername;
-- 6. How many orders have been placed by Herkku Gifts?
select customername, count(ordernumber) as total_orders from customers c, orders o
where o.customernumber=c.customernumber
and customername='Herkku Gifts';
-- 7. Who are the employees in Boston?
select employeenumber, concat(firstname,' ',lastname) as emp_name, city from offices o, employees e
where e.officecode=o.officecode
and city='Boston';
-- 8. Report those payments greater than $100,000. Sort the report so the customer who made the highest payment appears first.
select customername, amount from payments p, customers c
where p.customernumber=c.customernumber
and amount>100000
order by amount desc;
-- 9. List the value of 'On Hold' orders.
select o.ordernumber, o.status, sum(priceeach*quantityordered) as total_value from orders o, orderdetails d
where o.ordernumber=d.ordernumber
and o.status='On Hold'
group by o.ordernumber;
-- 10. Report the number of orders 'On Hold' for each customer.
select customername, count(ordernumber) as total_onHold_orders from customers c, orders o
where c.customernumber=o.customernumber
and o.status='On Hold'
group by c.customernumber;
-- Many to many relationship
-- 1. List products sold by order date.
select productname, orderdate from orders o, orderdetails d, products p
where p.productcode=d.productcode
and o.ordernumber=d.ordernumber
order by orderdate;
-- 2. List the order dates in descending order for orders for the 1940 Ford Pickup Truck.
select orderdate from orders o, orderdetails d, products p
where p.productcode=d.productcode
and o.ordernumber=d.ordernumber
and productname='1940 Ford Pickup Truck'
order by orderdate desc;
-- 3. List the names of customers and their corresponding order number where a particular order from that customer has a value greater than $25,000?
select customername, o.ordernumber, sum(priceeach*quantityordered) as total_value from customers c, orders o, orderdetails d
where c.customernumber=o.customernumber
and o.ordernumber=d.ordernumber
group by o.ordernumber
having total_value>25000;
-- 4. Are there any products that appear on all orders?
select distinct productname from products p, orderdetails o
where p.productcode=o.productcode
group by o.ordernumber
having count(distinct o.ordernumber) =count(distinct o.ordernumber,o.productcode);
-- 5. List the names of products sold at less than 80% of the MSRP.
select distinct productname from orderdetails o, products p
where o.productcode=p.productcode
and 1.0*priceeach/msrp<0.8;
-- 6. Reports those products that have been sold with a markup of 100% or more (i.e., the priceEach is at least twice the buyPrice)
select distinct productname from orderdetails o, products p
where o.productcode=p.productcode
and priceeach>buyprice*2;
-- 7. List the products ordered on a Monday.
select productname, orderdate from orders o, orderdetails d, products p
where p.productcode=d.productcode
and o.ordernumber=d.ordernumber
and weekday(orderdate)=0
order by orderdate;
-- 8. What is the quantity on hand for products listed on 'On Hold' orders?
select productname, quantityinstock from orders o, orderdetails d, products p
where p.productcode=d.productcode
and o.ordernumber=d.ordernumber
and o.status='On Hold';
-- Regular expressions
-- 1. Find products containing the name 'Ford'.
select productname from products
where productname like '%Ford%';
-- 2. List products ending in 'ship'.
select productname from products
where productname like '%ship';
-- 3. Report the number of customers in Denmark, Norway, and Sweden.
select country, count(distinct customernumber) as total_customer from customers
where country in ('Denmark', 'Norway', 'Sweden')
group by country;
-- 4. What are the products with a product code in the range S700_1000 to S700_1499?
select productname, productcode from products
where productcode regexp 'S700_1[0-4][0-9][0-9]';
-- 5. Which customers have a digit in their name?
select customername from customers
where customername regexp '[0-9]';
-- 6. List the names of employees called Dianne or Diane.
select firstname, lastname from employees
where firstname in ('Dianne', 'Diane')
or lastname in ('Dianne', 'Diane');
-- 7. List the products containing ship or boat in their product name.
select productname from products
where productname like '%ship%'
or productname like '%boat%';
-- 8. List the products with a product code beginning with S700.
select productname, productcode from products
where productcode like 'S700%';
-- 9. List the names of employees called Larry or Barry.
select firstname, lastname from employees
where firstname in ('Larry', 'Barry')
or lastname in ('Larry', 'Barry');
-- 10. List the names of employees with non-alphabetic characters in their names.
select firstname, lastname from employees
where firstname like '%[^a-zA-Z]%'
or lastname like '%[^a-zA-Z]%';
-- 11. List the vendors whose name ends in Diecast
select distinct productvendor from products
where productvendor like '%Diecast';
-- General queries
-- 1. Who is at the top of the organization (i.e., reports to no one).
select employeenumber, firstname, lastname from employees
where reportsto is null;
-- 2. Who reports to William Patterson?
select employeenumber, firstname, lastname from employees
where reportsto=(select employeenumber from employees where firstname='William' and lastname='Patterson');
-- 3. List all the products purchased by Herkku Gifts.
select distinct productname, customername from products p, orderdetails d, orders o, customers c
where c.customernumber=o.customernumber
and o.ordernumber=d.ordernumber
and p.productcode=d.productcode
and c.customername='Herkku Gifts' ;
-- 4. Compute the commission for each sales representative, assuming the commission is 5% of the value of an order. Sort by employee last name and first name.
select lastname, firstname, 0.05*sum(priceeach*quantityordered) as commission from employees e
left join customers c on e.employeenumber=c.salesrepemployeenumber
left join orders o on o.customernumber=c.customernumber
left join orderdetails d on o.ordernumber=d.ordernumber
group by salesrepemployeenumber
order by lastname, firstname;
-- 5. What is the difference in days between the most recent and oldest order date in the Orders file?
select datediff(max(orderdate), min(orderdate)) as date_difference from orders;
-- 6. Compute the average time between order date and ship date for each customer ordered by the largest difference.
select customername, avg(datediff(shippeddate, orderdate)) as date_difference from customers c, orders o
where o.customernumber=c.customernumber
group by c.customernumber
order by date_difference desc;
-- 7. What is the value of orders shipped in August 2004? (Hint).
select left(shippeddate, 7) as ship_month, sum(priceeach*quantityordered) as value_aug2004 from orders o, orderdetails d
where o.ordernumber=d.ordernumber
and left(shippeddate, 7)='2004-08'
group by ship_month;
-- 8. Compute the total value ordered, total amount paid, and their difference for each customer for orders placed in 2004 and payments received in 2004 (Hint; Create views for the total paid and total ordered).
select *, total_value-total_payment as amount_difference from (
select customername, sum(priceeach*quantityordered) as total_value, sum(amount) as total_payment from customers c
left join orders o on o.customernumber=c.customernumber
left join orderdetails d on d.ordernumber=o.ordernumber
left join payments p on p.customernumber=c.customernumber
where left(o.orderdate,4)='2004'
and left(p.paymentdate,4)='2004'
group by c.customernumber)t;
-- 9. List the employees who report to those employees who report to Diane Murphy. Use the CONCAT function to combine the employee's first name and last name into a single field for reporting.
select concat(e1.firstname, ' ', e1.lastname)as full_name from employees e1
join employees e2 on e1.reportsto=e2.employeenumber
join employees e3 on e2.reportsto=e3.employeenumber
where concat(e3.firstname, ' ', e3.lastname)='Diane Murphy';
-- 10. What is the percentage value of each product in inventory sorted by the highest percentage first (Hint: Create a view first).
select productname, quantityinstock, concat(quantityinstock/total_inv*100, '%') as percentage_value
from products p,(select sum(quantityinstock) as total_inv from products) t
order by percentage_value desc;
-- 11. Write a function to convert miles per gallon to liters per 100 kilometers.
DELIMITER
create function MPG_to_LPK(mpg decimal(10, 2), distance decimal(10, 2) )
returns decimal(10, 2)
deterministic
begin
declare liters_needed decimal(10, 2);
set liters_needed = ((100 * 3.785411784) / (mpg * 1.609344)/ 100) * distance;
return liters_needed;
end
select MPG_to_LPK(32, 60);
-- 12. Write a procedure to increase the price of a specified product category by a given percentage. You will need to create a product table with appropriate data to test your procedure. Alternatively, load the ClassicModels database on your personal machine so you have complete access. You have to change the DELIMITER prior to creating the procedure.
drop procedure increase_price
DELIMITER
create procedure increase_price(in target_prod_code varchar(15), in percentage decimal)
begin
update products
set msrp=(1+percentage/100)*msrp
where productcode=target_prod_code;
end
DELIMITER
call increase_price('test_10000', 20);
-- 13. What is the value of orders shipped in August 2004? (Hint).
select left(shippeddate, 7) as ship_month, sum(priceeach*quantityordered) as value_aug2004 from orders o, orderdetails d
where o.ordernumber=d.ordernumber
and left(shippeddate, 7)='2004-08'
group by ship_month;
-- 14. What is the ratio the value of payments made to orders received for each month of 2004. (i.e., divide the value of payments made by the orders received)?
select left(orderdate, 7) as order_month, sum(priceeach*quantityordered) as total_value, sum(amount) as total_payment, sum(priceeach*quantityordered)/sum(amount) as ratio
from orders o
join orderdetails d on o.ordernumber=d.ordernumber
join payments p on p.customernumber=o.customernumber
where year(orderdate)=2004
and year(paymentdate)=2004
group by order_month;
-- 15. What is the difference in the amount received for each month of 2004 compared to 2003?
select t1.months, total_amount_2003, total_amount_2004, total_amount_2003-total_amount_2004 as differences
from
(select month(paymentdate) as months, sum(amount) as total_amount_2003 from payments
where left(paymentdate, 4)='2003'
group by months)t1,
(select month(paymentdate) as months, sum(amount) as total_amount_2004 from payments
where left(paymentdate, 4)='2004'
group by months)t2
where t1.months=t2.months
order by t1.months;
-- 16. Write a procedure to report the amount ordered in a specific month and year for customers containing a specified character string in their name.
drop procedure amount_ordered
DELIMITER
create procedure amount_ordered(in months int, in years int, in str varchar(50))
begin
select customername, sum(quantityordered*priceeach) as total_amount
from customers c, orders o, orderdetails d
where c.customernumber=o.customernumber
and d.ordernumber=o.ordernumber
and year(orderdate)=years
and month(orderdate)=months
and customername like concat('%', str, '%')
group by c.customernumber;
end
DELIMITER
call amount_ordered(5, 2003, 'i');
-- 17. Write a procedure to change the credit limit of all customers in a specified country by a specified percentage.
drop procedure change_creditLimit
DELIMITER
create procedure change_creditLimit(in cust_country varchar(50), in percentage decimal)
begin
update customers
set creditLimit=creditLimit*(1+percentage/100)
where country=cust_country;
end
DELIMITER
call change_creditLimit('UK', 20);
-- 18. Basket of goods analysis: A common retail analytics task is to analyze each basket or order to learn what products are often purchased together. Report the names of products that appear in the same order ten or more times.
select distinct case when product_1>product_2 then concat(product_1,' & ',product_2) else concat(product_2,' & ',product_1) end as combinations
from
(select distinct d1.productcode as product_1, d2.productcode as product_2 from orderdetails d1, orderdetails d2
where d1.ordernumber=d2.ordernumber
and d1.productcode!=d2.productcode
group by d1.productcode, d2.productcode
having count(*)>=10)t
group by combinations;
-- 19. ABC reporting: Compute the revenue generated by each customer based on their orders. Also, show each customer's revenue as a percentage of total revenue. Sort by customer name.
/* select customername, sum(amount) as revenue, sum(amount)/total_revenue as ratio from payments p, customers c,
(select sum(amount) as total_revenue from payments) t
where c.customernumber=p.customernumber
group by c.customernumber
order by customername; */
select customername, sum(priceeach*quantityordered) as revenue, sum(priceeach*quantityordered)/total_revenue as ratio
from customers c, orders o, orderdetails d, (select sum(priceeach*quantityordered) as total_revenue from orderdetails) t
where c.customernumber=o.customernumber
and o.ordernumber=d.ordernumber
group by c.customernumber
order by customername;
-- 20. Compute the profit generated by each customer based on their orders. Also, show each customer's profit as a percentage of total profit. Sort by profit descending.
select customername, sum((priceeach-buyprice)*quantityordered) as profit, sum((priceeach-buyprice)*quantityordered)/total_profit as ratio
from customers c, orders o, orderdetails d, products p, (select sum((priceeach-buyprice)*quantityordered) as total_profit from orderdetails d, products p where d.productcode=p.productcode) t
where c.customernumber=o.customernumber
and o.ordernumber=d.ordernumber
and p.productcode=d.productcode
group by c.customernumber
order by profit desc;
-- 21. Compute the revenue generated by each sales representative based on the orders from the customers they serve.
select salesrepemployeenumber, sum(priceeach*quantityordered) as revenue, sum(priceeach*quantityordered)/total_revenue as ratio
from customers c, orders o, orderdetails d, (select sum(priceeach*quantityordered) as total_revenue from orderdetails) t
where c.customernumber=o.customernumber
and o.ordernumber=d.ordernumber
group by c.salesrepemployeenumber;
-- 22. Compute the profit generated by each sales representative based on the orders from the customers they serve. Sort by profit generated descending.
select salesrepemployeenumber, sum((priceeach-buyprice)*quantityordered) as profit, sum((priceeach-buyprice)*quantityordered)/total_profit as ratio
from customers c, orders o, orderdetails d, products p, (select sum((priceeach-buyprice)*quantityordered) as total_profit from orderdetails d, products p where d.productcode=p.productcode) t
where c.customernumber=o.customernumber
and o.ordernumber=d.ordernumber
and p.productcode=d.productcode
group by c.salesrepemployeenumber
order by profit desc;
-- 23. Compute the revenue generated by each product, sorted by product name.
select productname, sum(priceeach*quantityordered) as revenue
from orderdetails d, products p
where p.productcode=d.productcode
group by p.productcode
order by productname;
-- 24. Compute the profit generated by each product line, sorted by profit descending.
select productline, sum((priceeach-buyprice)*quantityordered) as profit
from orderdetails d, products p
where p.productcode=d.productcode
group by productline
order by profit desc;
-- 25. Same as Last Year (SALY) analysis: Compute the ratio for each product of sales for 2003 versus 2004.
select t2003.productcode, sales_2003, sales_2004, sales_2003/sales_2004 as ratio
from
(select productcode, sum(priceeach*quantityordered) as sales_2003 from orders o, orderdetails d
where o.ordernumber=d.ordernumber
and year(orderdate)=2003
group by productcode)t2003,
(select productcode, sum(priceeach*quantityordered) as sales_2004 from orders o, orderdetails d
where o.ordernumber=d.ordernumber
and year(orderdate)=2004
group by productcode)t2004
where t2003.productcode=t2004.productcode;
-- 26. Compute the ratio of payments for each customer for 2003 versus 2004.
select t2003.customername, payment_2003, payment_2004, payment_2003/payment_2004 as ratio
from
(select customername, c.customernumber, sum(amount) as payment_2003 from customers c, payments p
where c.customernumber=p.customernumber
and year(paymentdate)=2003
group by c.customernumber)t2003,
(select customername, c.customernumber, sum(amount) as payment_2004 from customers c, payments p
where c.customernumber=p.customernumber
and year(paymentdate)=2004
group by c.customernumber)t2004
where t2003.customernumber=t2004.customernumber;
-- 27. Find the products sold in 2003 but not 2004.
select distinct productname from products p, orderdetails d, orders o
where p.productcode=d.productcode
and o.ordernumber=d.ordernumber
and left(o.orderdate, 4)='2003'
and d.productcode not in (select distinct productcode from orderdetails d, orders o
where o.ordernumber=d.ordernumber
and left(o.orderdate, 4)='2004');
-- 28. Find the customers without payments in 2003.
select customername from customers c
where c.customernumber not in (select customernumber from payments where left(paymentdate, 4)='2003');
-- Correlated subqueries
-- 1. Who reports to Mary Patterson?
select firstname, lastname from employees
where reportsto=(select employeenumber from employees where firstname='Mary' and lastname='Patterson');
-- 2. Which payments in any month and year are more than twice the average for that month and year (i.e. compare all payments in Oct 2004 with the average payment for Oct 2004)? Order the results by the date of the payment. You will need to use the date functions.
select paymentdate, amount
from payments p, (select left(paymentdate, 7) as months, avg(amount) as avg_amount from payments group by months)t
where left(p.paymentdate, 7)=t.months
and amount>2*avg_amount
order by paymentdate;
-- 3. Report for each product, the percentage value of its stock on hand as a percentage of the stock on hand for product line to which it belongs. Order the report by product line and percentage value within product line descending. Show percentages with two decimal places.
select *, round(quantityInStock/line_quant*100, 2) as percentage
from
(select productLine, productCode, quantityInStock, sum(quantityinstock) over (partition by productline) as line_quant
from products
group by productLine, productCode
order by productLine, productCode)t
order by productLine, percentage desc;
-- 4. For orders containing more than two products, report those products that constitute more than 50% of the value of the order.
select t2.ordernumber, t2.productcode, product_value, order_value
from
(select ordernumber, sum(priceeach*quantityordered) as order_value from orderdetails
group by ordernumber
having count(distinct productcode)>2)t1,
(select ordernumber, productcode, sum(priceeach*quantityordered) as product_value
from orderdetails
group by ordernumber, productcode)t2
where t1.ordernumber=t2.ordernumber
and product_value>0.5*order_value;
-- Spatial data
-- The Offices and Customers tables contain the latitude and longitude of each office and customer in officeLocation and customerLocation, respectively, in POINT format. Conventionally, latitude and longitude and reported as a pair of points, with latitude first.
-- 1. Which customers are in the Southern Hemisphere?
select customername, country from customers
where ST_X(customerLocation)<0;
-- 2. Which US customers are south west of the New York office?
select customername, country, state, city from customers
where ST_X(customerlocation)<(select ST_X(officelocation) from offices where city='NYC')
and ST_Y(customerlocation) not between (select ST_X(officelocation) from offices where city='NYC') and (select ST_X(officelocation)+180 from offices where city='NYC');
-- 5. Who is the northernmost customer?
select customername, country from customers
order by ST_X(customerlocation) desc
limit 1;
| true |
10b02ccf63f181cd2a43fa378d33d64c2fea83d3 | SQL | tayduivn/training | /rdbms/update/.svn/text-base/sacwis_1154.sql.svn-base | UTF-8 | 542 | 2.578125 | 3 | [] | no_license | --STGAP00017435 - Release(5.0) Updating Other pages drop down for ECEM
-- updating dropdowns for Client chara and resource search page
Update CAPS.CODES_TABLES set DECODE = 'Family Hx of Mental Retardation'
where code_type = 'CLNCHAR2' and code = '302';
update CAPS.CODES_TABLES set DECODE = 'Infant Drug Addiction/Prenatal Drug Exposed'
where code_type = 'MED2' and code = '42';
insert into caps.schema_version(id_schema_version,application_version,comments)
values (1155, 'SacwisRev5', 'Release 5.0 - DBCR 17435');
commit;
| true |
7505b1694a54c365aadd136a9db0ae9af84fa012 | SQL | israaoliver/Senai-backend-inlock-IsraelO-MarinaS | /BD/InLock_BD_DQL_03.sql | UTF-8 | 2,028 | 3.921875 | 4 | [] | no_license | USE Inlock_Games_Tarde
SELECT * FROM Estudios;
SELECT * FROM Jogos;
SELECT * FROM TiposUsuarios;
SELECT * FROM Usuarios;
SELECT Estudios.NomeEstudio, Jogos.NomeJogo FROM Estudios
INNER JOIN Jogos ON Estudios.IdEstudio = Jogos.IdEstudio
SELECT Estudios.NomeEstudio, Jogos.NomeJogo FROM Estudios
LEFT JOIN Jogos ON Estudios.IdEstudio = Jogos.IdEstudio
-- Procedural para pegar o jogos de um determinado estudio passando o id do estudio
CREATE PROCEDURE PegarPorEstudio
@ID INT
AS
SELECT Jogos.IdJogos, Jogos.NomeJogo, Jogos.Descricao, Jogos.DataLancamento, Jogos.Valor, Jogos.IdEstudio, Estudios.NomeEstudio FROM Jogos
INNER JOIN Estudios ON Estudios.IdEstudio = Jogos.IdEstudio WHERE Estudios.IdEstudio = @ID
Execute PegarPorEstudio 3
--Procedural para buscar um estudio pelo nome dele
CREATE PROCEDURE BuscarEstudio
@NOME VARCHAR(55)
AS
SELECT IdEstudio, NomeEstudio FROM Estudios WHERE NomeEstudio LIKE '%'+ @NOME + '%';
EXECUTE BuscarEstudio rock
--Procedural que pega todos os jogos e o nome dos estudios
CREATE PROCEDURE ListarJogos
AS
SELECT Jogos.IdJogos, Jogos.NomeJogo, Jogos.Descricao, Jogos.DataLancamento, Jogos.Valor, Jogos.IdEstudio, Estudios.NomeEstudio FROM Jogos
INNER JOIN Estudios ON Estudios.IdEstudio = Jogos.IdEstudio
EXECUTE ListarJogos
--Buscar o jogo pelo Id
CREATE PROCEDURE JogoId
@ID INT
AS
SELECT Jogos.IdJogos, Jogos.NomeJogo, Jogos.Descricao, Jogos.DataLancamento, Jogos.Valor, Jogos.IdEstudio, Estudios.NomeEstudio FROM Jogos
INNER JOIN Estudios ON Estudios.IdEstudio = Jogos.IdEstudio WHERE Jogos.IdJogos = @ID
EXECUTE JogoId 2
-- Autentica se o usuario existe no bd recebendo a senha e o email
CREATE PROCEDURE Autentica
@EMAIL VARCHAR(255) ,
@SENHA VARCHAR(255)
AS
SELECT Usuarios.IdUsuario, Usuarios.Email,Usuarios.Senha, Usuarios.IdTipoUsuario, TiposUsuarios.Titulo FROM Usuarios
INNER JOIN TiposUsuarios ON Usuarios.IdTipoUsuario = TiposUsuarios.IdTipoUsuario WHERE Email = @EMAIL AND Senha= @SENHA
EXECUTE Autentica 'cliente@cliente.com','cliente'
Drop procedure Autentica
| true |
33a4b4c86f55bf2fab8f2c7ea93e89669e65535e | SQL | ManojKumarPatnaik/SQL | /LeetCode/175. Combine Two Tables.sql | UTF-8 | 528 | 4.0625 | 4 | [
"MIT"
] | permissive | # Task: Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people
# Problem Statement: https://leetcode.com/problems/combine-two-tables/
# Difficulty: Easy
- MySQL query:
# can also use abbr for each table or schema. e.g. Person as p, Address as a. Then it is simple for on p.PersonID = a.PersonID.
SELECT FirstName, LastName, City, State
FROM Person
LEFT JOIN Address
ON Person.PersonId = Address.PersonId;
| true |
d2764c42956adef989ddc588b789c9b9cca01574 | SQL | rumi55/smservice | /SMS_CreateDB_script.sql | UTF-8 | 2,997 | 3.59375 | 4 | [] | no_license | CREATE TABLE receiver (
UName varchar(50) not null ,
UPhone bigint unsigned ,
VKAccount varchar(20) not null ,
Password varchar(60) not null,
primary key ( UPhone )
);
-- Table that uses for specifications of all audiences such as : sex(male\female), age(<20 , 20-30 , ...), salary(...) etc.
CREATE TABLE audience_specification (
AS_Name varchar(30) unique ,
AS_Code tinyint unsigned auto_increment ,
primary key ( AS_Code )
);
-- Target audience tables
CREATE TABLE audience (
AName varchar(50) not null unique ,
ACode tinyint unsigned auto_increment ,
AS_Code tinyint unsigned ,
primary key ( ACode ) ,
foreign key ( AS_Code ) references audience_specification( AS_Code ) ON DELETE CASCADE
);
-- Receiver features
CREATE TABLE receiver_category (
UPhone bigint unsigned ,
ACode tinyint unsigned ,
primary key ( UPhone , ACode ) ,
foreign key ( UPhone ) references receiver( UPhone ) ON DELETE CASCADE,
foreign key ( ACode ) references audience( ACode ) ON DELETE CASCADE
);
-- Advertiser table
CREATE TABLE Client (
OrgName varchar(128) unique ,
EMail varchar(32) unique,
OrgActivity varchar(8) not null ,
OrgPhone bigint unsigned not null ,
ContactPerson varchar(32) ,
ContactPhone bigint unsigned not null ,
Address varchar(256) ,
CID integer unsigned auto_increment,
primary key ( CID )
);
CREATE TABLE Template (
TTotalReceivers bigint unsigned,
TConfirmedCount bigint unsigned,
TName varchar(128) not null ,
TText varchar(256) ,
CID integer unsigned not null ,
TID bigint unsigned auto_increment ,
Password varchar(60) not null,
primary key ( TID ) ,
foreign key ( CID ) references Client( CID ) ON DELETE CASCADE
);
CREATE TABLE TemplateAudience (
TID bigint unsigned ,
ACode tinyint unsigned ,
primary key ( TID , ACode ) ,
foreign key ( TID ) references Template( TID ) ON DELETE CASCADE,
foreign key ( ACode ) references audience( ACode ) ON DELETE CASCADE
);
CREATE TABLE UnconfirmedSMS (
UPhone bigint unsigned ,
TID bigint unsigned ,
ConformCode smallint unsigned ,
primary key ( TID , ConformCode ) ,
foreign key ( UPhone ) references receiver( UPhone ) ON DELETE CASCADE,
foreign key ( TID ) references Template( TID ) ON DELETE CASCADE
);
--########################################################
INSERT INTO audience_specification values('Пол',0);
INSERT INTO audience_specification values('Образование',0);
INSERT INTO audience_specification values('Возраст',0);
INSERT INTO audience values('Мужской',0,1);
INSERT INTO audience values('Женский',0,1);
INSERT INTO audience values('Высшее',0,2);
INSERT INTO audience values('Среднее',0,2);
INSERT INTO audience values('Школьное',0,2);
INSERT INTO audience values('Отсутствует',0,2);
INSERT INTO audience values('<20 лет',0,3);
INSERT INTO audience values('20 - 30 лет',0,3);
INSERT INTO audience values('30 - 40 лет',0,3);
INSERT INTO audience values('>40 лет',0,3);
| true |
c253275293ffe3d5df6310ce792405d8eccfe7d6 | SQL | angelsleung/walk-with-friends | /database/data.sql | UTF-8 | 4,375 | 2.609375 | 3 | [] | no_license | insert into "users" ("name", "weeklyDistance", "username", "hashedPassword")
values ('Ash', 5.2, 'ash', 'password'),
('Misty', 3.4, 'misty', 'password'),
('Brock', 2.8, 'brock', 'password'),
('Jenny', 1.2, 'jenny', 'password'),
('Joy', 1.1, 'joy', 'password'),
('Gary', 2.5, 'gary', 'password'),
('James', 0.7, 'james', 'password'),
('Jessie', 0.8, 'jessie', 'password'),
('Demo', 0, 'demo', '$argon2i$v=19$m=4096,t=3,p=1$g1u0nVBdf+nxbTS4/GLiHg$WzuRnCk6rs6NyaC0ApmXSUuEwooM55AVQ74zxTGQ0ZE');
insert into "routes" (
"userId",
"locationA",
"locationB",
"locationC",
"distance",
"duration",
"placeIds",
"lastWalked",
"nextWalk"
) values (
9,
'Pike Place Market, Pike Street, Seattle, WA, USA',
'Space Needle, Broad Street, Seattle, WA, USA',
'Gum Wall, Post Alley, Seattle, WA, USA',
2.3,
'48 minutes',
'["ChIJPcr187JrkFQRLApO8QKP8ZM","ChIJ-bfVTh8VkFQRDZLQnmioK9s","ChIJaYxSWbJqkFQRIx56JsKqNCA","ChIJPcr187JrkFQRLApO8QKP8ZM"]',
'Sat Apr 24 2021 14:00:00 GMT-0700 (Pacific Daylight Time)',
'Sun Jul 25 2021 12:00:00 GMT-0700 (Pacific Daylight Time)'
), (
9,
'Disneyland Park, Disneyland Drive, Anaheim, CA, USA',
'Anaheim Convention Center, West Katella Avenue, Anaheim, CA, USA',
'Stoddard Park, 9th Street, Anaheim, CA, USA',
3.7,
'1 hr 15 mins',
'["ChIJa147K9HX3IAR-lwiGIQv9i4","ChIJPSkYXt7X3IARFClnE7qisj4","ChIJdQM2fiMo3YARCMLPgLCm9XQ","ChIJa147K9HX3IAR-lwiGIQv9i4"]',
'Sun Apr 11 2021 13:00:00 GMT-0700 (Pacific Daylight Time)',
'Sat Jul 31 2021 11:00:00 GMT-0700 (Pacific Daylight Time)'
), (
9,
'Hollywood Walk of Fame, Vine Street, Los Angeles, CA, USA',
'World of Illusions, Hollywood Boulevard, Los Angeles, CA, USA',
'Sunset Las Palmas Studios, North Las Palmas Avenue, Los Angeles, CA, USA',
3.1,
'1 hr 3 mins',
'["ChIJXyC7WTu_woARPvVMCHBXd4U","ChIJD0CDniO_woARL4Y93Bw1yNw","ChIJF22Lwy2_woARMgHpFeoVNRQ","ChIJXyC7WTu_woARPvVMCHBXd4U"]',
'Sun Apr 18 2021 14:00:00 GMT-0700 (Pacific Daylight Time)',
'Sat Jul 24 2021 10:00:00 GMT-0700 (Pacific Daylight Time)'
), (
9,
'Fremont Troll, North 36th Street, Seattle, WA, USA',
'Woodland Park Zoo, Phinney Avenue North, Seattle, WA, USA',
'Fremont Peak Park, Palatine Avenue North, Seattle, WA, USA',
2.5,
'54 minutes',
'["ChIJl8b_mgAVkFQR9r1vmrKACpo","ChIJydSuSkkUkFQRsqhB-cEtYnw","ChIJHYrunbIVkFQR1jMy4kiywDE","ChIJ-Q_5sKkVkFQRdS8JqXmzaKc","ChIJW5Mq6gAVkFQRJMYLYydsJPE"]',
'Sat Apr 17 2021 11:00:00 GMT-0700 (Pacific Daylight Time)',
'Sun Jul 25 2021 15:00:00 GMT-0700 (Pacific Daylight Time)'
), (
1,
'Fremont Troll, North 36th Street, Seattle, WA, USA',
'Woodland Park Zoo, Phinney Avenue North, Seattle, WA, USA',
'Fremont Peak Park, Palatine Avenue North, Seattle, WA, USA',
2.4,
'51 minutes',
'["ChIJvYSnKAEVkFQR35lxzvEE250","ChIJydSuSkkUkFQRsqhB-cEtYnw","ChIJHYrunbIVkFQR1jMy4kiywDE","ChIJvYSnKAEVkFQR35lxzvEE250"]',
'',
'Sat Jun 26 2021 14:00:00 GMT-0700 (Pacific Daylight Time)'
), (
2,
'LearningFuze Coding',
'Irvine Spectrum Center, Spectrum Center Drive, Irvine, CA, USA',
'Los Olivos Community Park, Alfonso Dr, Irvine, CA, USA',
3.9,
'1 hr 18 mins',
'["ChIJKZcT2t_n3IARhA7AdKhMkuQ","ChIJR892-fvn3IARQnnqgTu-Phc","ChIJK1FF_m7n3IARfaMt7B-ljH0","ChIJKZcT2t_n3IARhA7AdKhMkuQ"]',
'',
'Sun Jun 27 2021 12:00:00 GMT-0700 (Pacific Daylight Time)'
), (
3,
'Downtown Park, Northeast 4th Street, Bellevue, WA, USA',
'Starbucks, Northeast 8th Street, Bellevue, WA, USA',
'Chipotle Mexican Grill, Northeast 4th Street, Bellevue, WA, USA',
1.4,
'29 minutes',
'["ChIJYVqRI4dskFQRVWnuu-Qjk0E","ChIJTdIWiYVskFQRGVoHhMIyhXg","ChIJW4VXzodskFQRseSBkOHh9Vg","ChIJYVqRI4dskFQRVWnuu-Qjk0E"]',
'',
'Sat Jul 03 2021 14:00:00 GMT-0700 (Pacific Daylight Time)'
), (
4,
'Wynn Las Vegas, South Las Vegas Boulevard, Las Vegas, NV, USA',
'Tacos El Gordo, South Las Vegas Boulevard, Las Vegas, NV, USA',
'Caesars Palace, South Las Vegas Boulevard, Las Vegas, NV, USA',
2.5,
'51 minutes',
'["ChIJlYYq3iLEyIAR7W-7y3M7wbE","ChIJuZ22zmzEyIARH1U2pl31Nes","ChIJleDKRDzEyIAR9z-vovLIyXc","ChIJlYYq3iLEyIAR7W-7y3M7wbE"]',
'',
'Sun Jul 04 2021 13:00:00 GMT-0700 (Pacific Daylight Time)'
), (
5,
'Hollywood Walk of Fame, Vine Street, Los Angeles, CA, USA',
'TCL Chinese Theatre, Hollywood Boulevard, Hollywood, CA, USA',
'Funko Hollywood, Hollywood Boulevard, Los Angeles, CA, USA',
2.7,
'54 minutes',
'["ChIJXyC7WTu_woARPvVMCHBXd4U","ChIJw4DCAdrX3IAR-1_GYNuCOfc","ChIJv1-IVVW_woAReuX1pRWmIdk","ChIJXyC7WTu_woARPvVMCHBXd4U"]',
'',
'Sat Jul 07 2021 11:00:00 GMT-0700 (Pacific Daylight Time)'
);
insert into "sharedRoutes" ("routeId", "userId")
values (1, 1),
(1, 2),
(1, 3),
(2, 3),
(2, 4),
(2, 5),
(3, 1),
(3, 2),
(3, 3),
(4, 3),
(4, 4),
(4, 5),
(5, 9),
(6, 9),
(7, 9),
(8, 9);
insert into "friends" ("userId", "friendUserId")
values (9, 1),
(9, 2),
(9, 3),
(9, 4),
(9, 5);
insert into "friendRequests" ("userId", "requesterUserId")
values (9, 6),
(9, 7),
(9, 8);
| true |
93072182bd39b189096c96de7eb1c89cf844dad9 | SQL | file3/tm_book | /setup.sql | UTF-8 | 908 | 3.484375 | 3 | [] | no_license | CREATE DATABASE transfermate WITH ENCODING='UTF8';
\c transfermate;
DROP TABLE books;
DROP TABLE authors;
CREATE TABLE authors
(
auid SERIAL NOT NULL PRIMARY KEY,
name TEXT NOT NULL UNIQUE
);
CREATE TABLE books
(
boid SERIAL NOT NULL PRIMARY KEY,
author INT NOT NULL REFERENCES authors ON DELETE CASCADE, -- auid
name TEXT NOT NULL,
path TEXT NOT NULL UNIQUE
);
-- SELECT NEXTVAL('authors_auid_seq');
INSERT INTO authors (name) VALUES ('3');
INSERT INTO books (author, name, path) VALUES (1, 'Standard', '/home/fattila/_projects/zz_work/transfermate/data/book2/index.xml');
-- SET @nextval = NEXTVAL('authors_auid_seq');
-- INSERT INTO authors (auid, name) VALUES (@nextval, '3');
-- INSERT INTO books (author, name, path) VALUES (@nextval, 'Standard', '/home/fattila/_projects/zz_work/transfermate/data/book2/index.xml');
| true |
2d32877d76b9f3ac16c069b233124c76eb0c7669 | SQL | augusticor/oodb-transporte | /tables_constraints/ctmantenimientos.sql | UTF-8 | 570 | 2.8125 | 3 | [] | no_license | /*==============================================================*/
/* Table: MANTENIMIENTOS */
/*==============================================================*/
create table MANTENIMIENTOS (
ID_MANTENIMIENTO NUMBER(4) not null,
PLACA VARCHAR2(6) not null,
FECHA DATE not null,
ESTADO VARCHAR2(1) default 'P' not null,
constraint mant_pk_id_mant primary key (ID_MANTENIMIENTO)
); | true |
a953982fd388fa97052ee4e08276860c5f04e7b6 | SQL | joaovitormo/ExerciciosSQL | /Exercicios18-06/exercicio03.sql | UTF-8 | 479 | 3.28125 | 3 | [] | no_license | create database db_escola;
use db_escola;
create table tb_alunos (
id bigint auto_increment,
nome varchar(200),
data_nascimento date,
turma varchar(4),
media_nota decimal(3,2),
primary key(id)
);
insert into tb_alunos(nome, data_nascimento, turma, media_nota) values("Marcos", '2005-05-06', "2ºB", 4.50);
select * from tb_alunos;
select * from tb_alunos where media_nota > 7;
select * from tb_alunos where media_nota < 7;
update tb_alunos set nome = "João Marcos" where id = 8;
| true |
b9fafbee4e25afcb6d9bbe990f84735e97f7bc63 | SQL | soltan2272/mk | /mm.sql | UTF-8 | 19,620 | 2.875 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 03, 2019 at 08:42 PM
-- Server version: 10.1.28-MariaDB
-- PHP Version: 7.1.10
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `mkhtof`
--
-- --------------------------------------------------------
--
-- Table structure for table `gmaps_geocache`
--
CREATE TABLE `gmaps_geocache` (
`id` int(10) UNSIGNED NOT NULL,
`address` text COLLATE utf8mb4_unicode_ci NOT NULL,
`latitude` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`longitude` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `homes`
--
CREATE TABLE `homes` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'admin',
`main_logo` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`small_logo` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`welcome_title` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`welcome_text` text COLLATE utf8mb4_unicode_ci,
`welcome_image` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_title1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_text1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_image1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_title2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_text2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_image2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_title3` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_text3` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_image3` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_title4` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_text4` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Animation_image4` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gallary_title1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gallary_text1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gallary_image1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gallary_title2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gallary_text2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gallary_image2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gallary_title3` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gallary_text3` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gallary_image3` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_phone` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_facebook` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_twiteer` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_linkedin` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_youtube` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`who_us` text COLLATE utf8mb4_unicode_ci,
`mission` text COLLATE utf8mb4_unicode_ci,
`Vision` text COLLATE utf8mb4_unicode_ci,
`about_title1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_text1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_image1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_title2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_text2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_image2` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_title3` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_text3` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_image3` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_title4` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_text4` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`about_image4` varchar(191) 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 `homes`
--
INSERT INTO `homes` (`id`, `name`, `main_logo`, `small_logo`, `welcome_title`, `welcome_text`, `welcome_image`, `Animation_title1`, `Animation_text1`, `Animation_image1`, `Animation_title2`, `Animation_text2`, `Animation_image2`, `Animation_title3`, `Animation_text3`, `Animation_image3`, `Animation_title4`, `Animation_text4`, `Animation_image4`, `gallary_title1`, `gallary_text1`, `gallary_image1`, `gallary_title2`, `gallary_text2`, `gallary_image2`, `gallary_title3`, `gallary_text3`, `gallary_image3`, `about_phone`, `about_email`, `about_facebook`, `about_twiteer`, `about_linkedin`, `about_youtube`, `who_us`, `mission`, `Vision`, `about_title1`, `about_text1`, `about_image1`, `about_title2`, `about_text2`, `about_image2`, `about_title3`, `about_text3`, `about_image3`, `about_title4`, `about_text4`, `about_image4`, `created_at`, `updated_at`) VALUES
(1, 'admin', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'aa', 'aaaaaaaaa', '1556707916.22090146_1864403800555644_8209692982063215560_n.jpg', 'ww', 'wwwwwwwwww', '1556707916.unnamed (1).jpg', 'qq', 'qqqqqqqqqqqq', '1556707916.50496116_529273624237161_2212115874943336448_n.jpg', 'ii', 'iiiiiiiiii', '1556707916.49380443_1515014085297300_6912265107133169664_n.jpg', '2019-05-01 08:51:56', '2019-05-01 08:51:56');
-- --------------------------------------------------------
--
-- Table structure for table `kid_posts`
--
CREATE TABLE `kid_posts` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`relative_relation` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`age` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`age_before` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`blood_type` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`gender` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`governate` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`city` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`street` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`detailed_address` text COLLATE utf8mb4_unicode_ci NOT NULL,
`other_info` text COLLATE utf8mb4_unicode_ci NOT NULL,
`url` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`category` int(11) NOT NULL,
`user_id` 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 `kid_posts`
--
INSERT INTO `kid_posts` (`id`, `name`, `relative_relation`, `age`, `age_before`, `blood_type`, `gender`, `governate`, `city`, `street`, `detailed_address`, `other_info`, `url`, `category`, `user_id`, `created_at`, `updated_at`) VALUES
(14, 'احمد', '...', '30-50', NULL, 'B-', 'ذكر', 'اسيوط', 'أبو تيج', 'مكتنتالبللا', 'ككمنتاالاى', 'سكمستكككككككك', '1556311993.58761631_2482689205115982_8051166442621501440_n.jpg', 1, 5, '2019-04-26 18:53:13', '2019-04-26 18:53:13'),
(15, NULL, NULL, '10-15', NULL, NULL, 'ذكر', 'اسيوط', 'أسيوط الجديدة', NULL, 'منتؤلر', 'كرالاتىنة', '1556312045.57602853_1593797347418973_3117907443829440512_n.jpg', 2, 5, '2019-04-26 18:54:05', '2019-04-26 18:54:05'),
(16, ';ol', NULL, '15-30', NULL, 'AB+', 'انثى', 'اسيوط', 'القوصيه', ';nlnkjhgfgcgv', ';mnfcgvb n', '.llkbjhgfc n', '1556312248.download.png', 3, 4, '2019-04-26 18:57:28', '2019-04-26 18:57:28'),
(17, 'احمد', '...', 'حديث الولادة', NULL, 'A-', 'ذكر', 'الدقهلية', 'اجا', 'الهلالى', 'كةمنىتلاالربرلا', 'مىنوتلاةارلؤبلؤشلرا لاة', '1556390168.58761631_2482689205115982_8051166442621501440_n.jpg', 1, 4, '2019-04-27 16:36:08', '2019-04-27 16:36:08'),
(18, 'سيد على', '...', '10-15', NULL, 'AB+', 'ذكر', 'اسيوط', 'الفتح', 'الفتح', 'طككمنتلاا', 'طكمنلااىسشي', '1556390297.58761631_2482689205115982_8051166442621501440_n.jpg', 1, 4, '2019-04-27 16:38:17', '2019-04-27 16:38:17'),
(19, NULL, NULL, '2-5', NULL, NULL, 'ذكر', 'اسيوط', 'أبو تيج', NULL, ';lkjbhvgcfxdzszxfcgvbhn', 'klnmbnvcxfdxfcvgbhnjmk', '1556391603.58441784_1347238222107723_547579970570944512_n.jpg', 2, 4, '2019-04-27 17:00:03', '2019-04-27 17:00:03'),
(20, 'er', '...', '2-5', NULL, 'A+', 'ذكر', 'الاقصر', 'اسنا', NULL, 'er', 'er', '1556624998.45.PNG', 1, 8, '2019-04-30 09:49:58', '2019-04-30 09:49:58'),
(21, 'er', '...', '2-5', NULL, 'A+', 'ذكر', 'الشرقية', 'ديرب نجم', NULL, 'er', 'er', '1556625048.88.PNG', 1, 8, '2019-04-30 09:50:48', '2019-04-30 09:50:48'),
(22, NULL, NULL, 'حديث الولادة', NULL, NULL, 'ذكر', 'اسوان', 'ابو سمبل', NULL, 'cv', 'df', '1556625547.56255386_2593498834004825_7683866848126828544_n.jpg', 2, 8, '2019-04-30 09:59:07', '2019-04-30 09:59:07');
-- --------------------------------------------------------
--
-- Table structure for table `maps`
--
CREATE TABLE `maps` (
`id` bigint(20) UNSIGNED NOT NULL,
`address` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`lat` double NOT NULL,
`lang` double 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 `maps`
--
INSERT INTO `maps` (`id`, `address`, `lat`, `lang`, `created_at`, `updated_at`) VALUES
(1, 'اسيوط', 27.377788, 31.098221, NULL, NULL),
(2, 'سوهاج', 26.661919, 31.682627, NULL, NULL),
(3, 'القاهرة', 30.254144, 31.161536, NULL, NULL),
(4, 'الاسكندرية', 31.215181, 29.873935, NULL, NULL),
(5, 'اسوان', 24.180067, 32.893095, NULL, NULL),
(6, 'الاقصر', 25.775971, 32.622017, NULL, NULL),
(7, 'الاسماعيلية', 30.599308, 32.270251, NULL, NULL),
(8, 'البحرالاحمر', 30.059333, 31.253485, NULL, NULL),
(9, 'البحيرة', 30.711533, 30.049667, NULL, NULL),
(10, 'االجيزة', 30.016443, 31.207154, NULL, NULL),
(11, 'الدقهلية', 31.03522, 31.632198, NULL, NULL),
(12, 'السويس', 29.972242, 32.549605, NULL, NULL),
(13, 'الشرقية', 30.669713, 31.705424, NULL, NULL),
(14, 'الغربية', 30.905071, 30.91183, NULL, NULL),
(15, 'الفيوم', 29.308574, 30.842544, NULL, NULL),
(16, 'القليوبية', 30.246112, 31.27861, NULL, NULL),
(17, 'المنوفية', 30.510905, 30.934109, NULL, NULL),
(18, 'المنيا', 28.089305, 30.761534, NULL, NULL),
(19, 'الواددى_الجديد', 25.499795, 30.0869, NULL, NULL),
(20, 'بنى_يوسف', 29.067013, 31.083372, NULL, NULL),
(21, 'بورسعيد', 31.267285, 32.302182, NULL, NULL),
(22, 'جنوب_سيناء', 29.170014, 33.67401, NULL, NULL),
(23, 'دمياط', 31.421848, 31.799043, NULL, NULL),
(24, 'شمال_سيناء', 30.477467, 33.600614, NULL, NULL),
(25, 'قنا', 25.493547, 32.494632, NULL, NULL),
(26, 'كفرالشيخ', 31.110493, 30.916456, NULL, NULL),
(27, 'مطروح', 31.36036, 27.237148, NULL, NULL);
-- --------------------------------------------------------
--
-- 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_100000_create_password_resets_table', 1),
(2, '2019_03_29_154149_create_users_table', 1),
(3, '2019_04_20_083158_create_roles_table', 1),
(4, '2019_04_20_084210_create_user_roles_table', 1),
(5, '2019_04_21_104128_create_kid_posts_table', 1),
(6, '2019_04_21_104812_create_seen_posts_table', 1),
(7, '2019_04_23_061858_create_gmaps_geocache_table', 2),
(8, '2019_04_25_154020_create_maps_table', 2),
(16, '2019_04_29_183318_create_homes_table', 3);
-- --------------------------------------------------------
--
-- 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 `roles`
--
CREATE TABLE `roles` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `roles`
--
INSERT INTO `roles` (`id`, `name`, `created_at`, `updated_at`) VALUES
(1, 'admin', NULL, NULL),
(2, 'user', NULL, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `seen_posts`
--
CREATE TABLE `seen_posts` (
`id` bigint(20) UNSIGNED NOT NULL,
`age` double NOT NULL,
`gender` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`governate` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`city` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`detailed_address` text COLLATE utf8mb4_unicode_ci NOT NULL,
`other_info` text COLLATE utf8mb4_unicode_ci NOT NULL,
`url` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`user_id` 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;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` bigint(20) UNSIGNED NOT NULL,
`firstName` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`lastName` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`governate` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`city` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone` int(11) NOT NULL,
`gender` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `firstName`, `lastName`, `password`, `email`, `governate`, `city`, `phone`, `gender`, `created_at`, `updated_at`) VALUES
(4, 'محمد', 'صلاح', '$2y$10$cO2phrGFDgK7k6kp8S1/EesvblFy/ba5ZnML7esC2GEVe9yHEQOqa', 'ssas2584@gmail.com', 'الاسكندرية', 'السيوف', 1060199043, 'ذكر', '2019-04-22 03:24:07', '2019-04-29 14:32:46'),
(5, 'مينا', 'ناجى', '$2y$10$1FXprnY4zupCZvwuzIJ2v.tT8efkeK4LH.4k4feoHHokc9rGNxze2', 'mina@yahoo.com', '...', '...', 1207174241, 'ذكر', '2019-04-22 05:50:53', '2019-04-22 05:50:53'),
(6, 'اسلام', 'منصور', '$2y$10$gGr4GNkIs3Ei1rCbEpzs7.hRcfEMYtkWAY/xs1iApwwjhEwX9aEJi', 'islam@yahoo.com', '...', '...', 1060199043, 'ذكر', '2019-04-24 17:07:04', '2019-04-24 17:07:04'),
(7, 'sadas', 'sadd', '$2y$10$KYeXr96OehceP2Tcpdf0JuZ2clF/b/Dwul/UhTuFEJl6EyExZMOIW', 'i@yahoo.com', 'الشرقية', 'الابراهيمية', 1060199044, 'ذكر', '2019-04-24 18:18:42', '2019-04-24 18:18:42'),
(8, 'fg', 'gf', '$2y$10$8E9qGu1CZqI8DaywtrLSIugBBHLoZUyDikOfckMyqubHq4oBlMyh.', 'sondoee@yahoo.com', 'الفيوم', 'اطسا', 1111111111, 'ذكر', '2019-04-30 09:42:42', '2019-04-30 09:42:42');
-- --------------------------------------------------------
--
-- Table structure for table `user_roles`
--
CREATE TABLE `user_roles` (
`id` bigint(20) UNSIGNED NOT NULL,
`user_id` int(11) NOT NULL,
`role_id` 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 `user_roles`
--
INSERT INTO `user_roles` (`id`, `user_id`, `role_id`, `created_at`, `updated_at`) VALUES
(1, 4, 1, NULL, NULL),
(2, 8, 2, NULL, NULL);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `gmaps_geocache`
--
ALTER TABLE `gmaps_geocache`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `homes`
--
ALTER TABLE `homes`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `kid_posts`
--
ALTER TABLE `kid_posts`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `maps`
--
ALTER TABLE `maps`
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 `roles`
--
ALTER TABLE `roles`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `seen_posts`
--
ALTER TABLE `seen_posts`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- Indexes for table `user_roles`
--
ALTER TABLE `user_roles`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `gmaps_geocache`
--
ALTER TABLE `gmaps_geocache`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `homes`
--
ALTER TABLE `homes`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `kid_posts`
--
ALTER TABLE `kid_posts`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
--
-- AUTO_INCREMENT for table `maps`
--
ALTER TABLE `maps`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;
--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `seen_posts`
--
ALTER TABLE `seen_posts`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `user_roles`
--
ALTER TABLE `user_roles`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
f37aa65ee9de2b73806d10d7c8873207fedc8fd3 | SQL | chardur/AdvancedDatabaseFinal | /spAddProduct.sql | UTF-8 | 445 | 2.625 | 3 | [] | no_license | Create PROC spAddProduct
@productName varchar(250),
@creationDate date,
@usage varchar(50),
@inventoryScanningID varchar(250),
@color varchar(50),
@encryptedData varBinary(max)
AS
insert into Products
(productName, creationDate, usage, inventoryScanningID, color, encryptedData)
values
(@productName, @creationDate, @usage, @inventoryScanningID, @color, @encryptedData)
exec spAddProduct 'test', '08/12/2018', 'test', 'test', 'test', 1234
| true |
813c42682bb416437c88d9b8959a41419d279596 | SQL | jasynecka/bst-currency | /db/datebase.sql | UTF-8 | 244 | 2.921875 | 3 | [] | no_license | CREATE DATABASE currencydb;
CREATE TABLE currency (
id int NOT NULL AUTO_INCREMENT UNIQUE,
name varchar(255) NOT NULL,
code varchar(3) NOT NULL,
middleRate decimal(8, 4) NOT NULL,
date date NOT NULL,
PRIMARY KEY (id)
); | true |
5e87b12d01403be34c6266c94079c79a35e3b776 | SQL | praveen-332/HOTEL-MANAGEMENT-DASHBOARD | /17075017.sql | UTF-8 | 3,796 | 3.765625 | 4 | [] | no_license | create table customers
(
cid int not null auto_increment,
cname varchar(20),
csex char(1),
cdob date,
cphone int(10) not null,
caddress varchar(75),
primary key(cid)
);
create table emps
(eid int primary key auto_increment,
e_firstname varchar(15),
e_lastname varchar(15),
birthday date,
strtdate date,
e_sex varchar(1),
e_email varchar(50),
ephone char(10),
eaddress varchar(50));
create table regis
(username varchar(20) primary key,
email varchar(50),
password varchar(20)
);
insert into regis values('admin','amin@gmail.com','password');
create table users
(
id int primary key auto_increment,
firstname varchar(20),
lastname varchar(20),
address varchar(50)
);
create table supplier
(
sid int not null auto_increment,
sname varchar(20),
ssex char(1),
sdob date,
sphone long,
location varchar(75),
primary key(sid)
);
create table feedback
(fid int not null auto_increment
,givenby int,
fdate date,
rate int(1),
remarks varchar(50),
primary key(fid),
foreign key(givenby) references customers(cid) on delete cascade
);
create table hotel
(
hid int not null auto_increment,
hname varchar(20),
haddress varchar(75),
hGSITN varchar(20),
primary key(hid)
);
create table expences
(
hid int,
expid int not null auto_increment,
expamount int,
expdate date,
foreign key(hid) references hotel(hid) on delete cascade,
primary key(expid)
);
create table htax
(
hid int,
returnid int not null auto_increment,
returnamount int,
returntype varchar(20),
returndate date,
foreign key(hid) references hotel(hid),
primary key(returnid)
);
create table item
(
iid int not null auto_increment,
iname varchar(20),
itype varchar(20),
iprice int,
istock BOOLEAN,
primary key(iid)
);
create table rawitem
(
rid int not null auto_increment,
suppliedby int,
rquantity varchar(20),
riprice int,
rstock BOOLEAN,
foreign key(suppliedby) references supplier(sid),
primary key(rid)
);
create table raw_item_invoice
(
rid int,rrid int not null auto_increment,
riprice int,
rindate date,
riquantity int,
tax_gst int default 5,
total_price int,
foreign key(rid) references rawitem(rid),
primary key(rrid)
);
create table ctbooking
(
cid int,
hid int,
tbid int not null auto_increment,
tnum int,
tbdate date,
time TIME,
datealloted date,
foreign key(cid) references customers(cid),
foreign key(hid) references hotel(hid),
primary key(tbid)
);
create table discount
(
did int not null auto_increment,
per int,
validtill date,
primary key(did)
);
create table bill
(
billid int not null auto_increment,
billdate date,
primary key(billid)
);
create table oitems
(
oid int not null auto_increment,
billid int,
iid int,
quantity int,
iprice int,
igross int,
primary key(oid),
foreign key(billid) references bill(billid)
);
create table fbill
(
id int not null auto_increment,
billid int,
fbilldate date,
totalgross int,
tax_gst int default 5,
totalamount int,
primary key(id),
foreign key(billid) references bill(billid)
);
create trigger t1 before insert on raw_item_invoice for each row set new.riprice= (select riprice from rawitem where rid=new.rid);
create trigger t2 before insert on raw_item_invoice for each row set new.total_price= (new.riprice*new.riquantity)+(new.riprice*new.riquantity*new.tax_gst/100);
create trigger t3 before insert on oitems for each row set new.iprice= (select iprice from item where iid=new.iid);
create trigger t4 before insert on oitems for each row set new.igross= (select iprice from item where iid=new.iid)*new.quantity;
create trigger t5 before insert on fbill for each row set new.totalgross=(select sum(igross) from oitems where billid=new.billid);
create trigger t6 before insert on fbill for each row set new.totalamount= new.totalgross+(new.totalgross*new.tax_gst/100);
| true |
39a3f9bbc36205885a34c5fba017e4863dc7e51e | SQL | itonkovski/DataBases-MSSQL-January-2021 | /01-DatabasesIntroduction/14.CarRentalDatabase.sql | UTF-8 | 3,271 | 3.78125 | 4 | [] | no_license | CREATE TABLE Categories
(
Id INT IDENTITY PRIMARY KEY,
CategoryName NVARCHAR(50) NOT NULL,
DailyRate DECIMAL(10,2),
WeeklyRate DECIMAL(10,2),
MonthlyRate DECIMAL(10,2),
WeekendRate DECIMAL(10,2)
)
CREATE TABLE Cars
(
Id INT IDENTITY PRIMARY KEY,
PlateNumber NVARCHAR(10) NOT NULL,
Manufacturer NVARCHAR(50) NOT NULL,
Model NVARCHAR(50) NOT NULL,
CarYear INT NOT NULL,
CategoryId INT,
CONSTRAINT FK_Cars_Categories FOREIGN KEY (CategoryId) REFERENCES Categories(Id),
Doors INT NOT NULL,
Picture VARBINARY(MAX),
Condition NVARCHAR(MAX),
Available BIT NOT NULL
)
CREATE TABLE Employees
(
Id INT IDENTITY PRIMARY KEY,
FirstName NVARCHAR(50) NOT NULL,
LastName NVARCHAR(50) NOT NULL,
Title NVARCHAR(100) NOT NULL,
Notes NVARCHAR(MAX)
)
CREATE TABLE Customers
(
Id INT IDENTITY PRIMARY KEY,
DriverLicenceNumber INT NOT NULL,
FullName NVARCHAR(100) NOT NULL,
Address NVARCHAR(200) NOT NULL,
City NVARCHAR(50) NOT NULL,
ZIPCode INT NOT NULL,
Notes NVARCHAR(MAX)
)
CREATE TABLE RentalOrders
(
Id INT IDENTITY PRIMARY KEY,
EmployeeId INT,
CONSTRAINT FK_RentalOrders_Employees FOREIGN KEY (EmployeeId) REFERENCES Employees(Id),
CustomerId INT,
CONSTRAINT FK_RentalOrders_Customers FOREIGN KEY (CustomerId) REFERENCES Customers(Id),
CarId INT,
CONSTRAINT FK_RentalOrders_Cars FOREIGN KEY (CarId) REFERENCES Cars(Id),
TankLevel INT NOT NULL,
KilometrageStart INT NOT NULL,
KilometrageEnd INT NOT NULL,
TotalKilometrage AS KilometrageEnd - KilometrageStart,
StartDate DATE NOT NULL,
EndDate DATE NOT NULL,
TotalDays AS DATEDIFF(DAY, StartDate, EndDate),
RateApplied DECIMAL(6,2),
TaxRate DECIMAL(6,2),
OrderStatus NVARCHAR(50),
Notes NVARCHAR(MAX)
)
INSERT INTO Categories (CategoryName, DailyRate, WeekLyRate, MonthlyRate, WeekendRate)
VALUES ('Car', 20, 120, 500, 42.50),
('Bus', 250, 1600, 6000, 489.99),
('Truck', 500, 3000, 11900, 949.90)
INSERT INTO Cars (PlateNumber, Manufacturer, Model, CarYear, CategoryId, Doors, Picture, Condition, Available)
VALUES ('123456ABCD', 'Mazda', 'CX-5', 2016, 1, 5, 123456, 'Perfect', 1),
('asdafof145', 'Mercedes', 'Tourismo', 2017, 2, 3, 99999, 'Perfect', 1),
('asdp230456', 'MAN', 'TGX', 2016, 3, 2, 123456, 'Perfect', 1)
INSERT INTO Employees (FirstName, LastName, Title, Notes)
VALUES ('Ivan', 'Ivanov', 'Seller', 'I am Ivan'),
('Georgi', 'Georgiev', 'Seller', 'I am Gosho'),
('Mitko', 'Mitkov', 'Manager', 'I am Mitko')
INSERT INTO Customers (DriverLicenceNumber, FullName, Address, City, ZIPCode, Notes)
VALUES (123456789, 'Gogo Gogov', 'óë. Ïèðîòñêà 5', 'Ñîôèÿ', 1233, 'Good driver'),
(347645231, 'Mara Mareva', 'óë. Èâàí Äðàñîâ 14', 'Âàðíà', 5678, 'Bad driver'),
(123574322, 'Strahil Strahilov', 'óë. Êåñòåí 4', 'Äóïíèöà', 5689, 'Good driver')
INSERT INTO RentalOrders (EmployeeId, CustomerId, CarId, TankLevel, KilometrageStart, KilometrageEnd, StartDate, EndDate)
VALUES (1, 1, 1, 54, 2189, 2456, '2017-11-05', '2017-11-08'),
(2, 2, 2, 22, 13565, 14258, '2017-11-06', '2017-11-11'),
(3, 3, 3, 180, 1202, 1964, '2017-11-09', '2017-11-12') | true |
5644d3226d89546c9b4436bdb9bd50e3306c99fb | SQL | Maddy1993/cs5200f18_whoophee | /Assignment-2/delete.sql | UTF-8 | 645 | 3.859375 | 4 | [] | no_license | use `assignment_2`;
-- Problem 1
DELETE address
FROM address JOIN person ON address.person_id = person.id
WHERE person.first_name = 'alice' AND address.primary = TRUE;
-- Problem 2
DELETE widget
FROM widget JOIN `page` ON widget.page_id = `page`.id
WHERE page.title = 'Contact' AND
widget.order = (SELECT MAX(`order`) FROM (SELECT * FROM widget) as a);
-- Problem 3
DELETE page
FROM `page` JOIN website ON `page`.website_id = website.id
WHERE website.name = 'Wikipedia' AND
`page`.updated = (SELECT MAX(updated) FROM (SELECT * FROM `page`) as a);
-- Problem 4
-- Cascading deletion.
DELETE website FROM website WHERE website.name = 'CNET';
| true |
6ed73a89c29f3db13321acef363b7959bb93a59b | SQL | Takiyo/WebDev | /OLD/projects/madlibstable.sql | UTF-8 | 1,307 | 2.515625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.6.6
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Nov 05, 2018 at 11:32 PM
-- Server version: 5.7.16-log
-- PHP Version: 7.0.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `tbrytowski`
--
-- --------------------------------------------------------
--
-- Table structure for table `madlibstable`
--
CREATE TABLE `madlibstable` (
`noun` char(20) COLLATE latin1_general_ci NOT NULL,
`verb` char(20) COLLATE latin1_general_ci NOT NULL,
`adjective` char(20) COLLATE latin1_general_ci NOT NULL,
`adverb` char(20) COLLATE latin1_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
--
-- Dumping data for table `madlibstable`
--
INSERT INTO `madlibstable` (`noun`, `verb`, `adjective`, `adverb`) VALUES
('guy', 'hop', 'blue', 'lightly');
/*!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 |
726ff6add31619f8a55754b911702816eced7b52 | SQL | CaseyQWood/Buckets | /server/src/db/schema/messages.sql | UTF-8 | 285 | 2.90625 | 3 | [
"MIT"
] | permissive | DROP TABLE IF EXISTS messages CASCADE;
CREATE TABLE messages (
id SERIAL PRIMARY KEY NOT NULL,
sender_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
budget_id INTEGER REFERENCES budgets(id) ON DELETE CASCADE,
message VARCHAR(255),
reciever_email VARCHAR(255) NOT NULL
); | true |
d73e2276cf41eec12c6568d6b0666c961c84c734 | SQL | vijaykiran/hopsworks | /sql/test_rows.sql | UTF-8 | 1,979 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | -- --------------------------------------------------------
--
-- Creating test users.
--
INSERT INTO `users` (`uid`, `username`, `password`, `email`, `fname`, `lname`, `activated`, `title`, `orcid`, `false_login`, `isonline`, `secret`, `validation_key`, `security_question`, `security_answer`, `mode`, `password_changed`, `notes`, `mobile`, `status`) VALUES
(10001, 'meb10001', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', 'john@domain.com', 'John', 'Williams', '2015-04-28 15:20:34', 'Mr', '1234-5678-1234-5678', -1, 0, 'V3WBPS4G2WMQ53VA', NULL, 'FRIEND', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', 12, '2015-04-28 15:19:07', NULL, '04672223200', 4),
(10002, 'meb10002', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', 'michael@domain.com', 'Michael', 'Jones', '2015-04-28 15:20:34', 'Mr', '1234-5678-1234-5678', -1, 0, 'V3WBPS4G2WMQ53VA', NULL, 'FRIEND', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', 12, '2015-04-28 15:19:07', NULL, '04672223200', 4),
(10003, 'meb10003', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', 'mary@domain.com', 'Mary', 'Brown', '2015-04-28 15:20:34', 'Mr', '1234-5678-1234-5678', -1, 0, 'V3WBPS4G2WMQ53VA', NULL, 'FRIEND', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', 12, '2015-04-28 15:19:07', NULL, '04672223200', 4);
-- --------------------------------------------------------
--
-- Creating test organizations
--
INSERT INTO `organization` (`id`, `uid`, `org_name`, `website`, `contact_person`, `contact_email`, `department`, `phone`, `fax`) VALUES
(2, 10001, 'KI', 'www.ki.se', 'Admin Admin', 'admin@kth.se', 'MEB', '+4670080010', '+4670080015'),
(3, 10002, 'KI', 'www.ki.se', 'Admin Admin', 'admin@kth.se', 'MEB', '+4670080010', '+4670080015'),
(4, 10003, 'KI', 'www.ki.se', 'Admin Admin', 'admin@kth.se', 'MEB', '+4670080010', '+4670080015');
-- --------------------------------------------------------
--
-- Adding test users to groups.
--
INSERT INTO `people_group` (`uid`, `gid`) VALUES
(10001, 1006),
(10002, 1006),
(10003, 1006);
-- --------------------------------------------------------
| true |
3f1d1e3020a0c0fc3864b12208fb7d0c9333e9fe | SQL | songzigw/webim-for-php5 | /webim/webim_conversations.sql | UTF-8 | 1,423 | 3.015625 | 3 | [
"MIT"
] | permissive | /*
Navicat MySQL Data Transfer
Source Server : 127.0.0.1
Source Server Version : 50151
Source Host : 127.0.0.1:3306
Source Database : webim5
Target Server Type : MYSQL
Target Server Version : 50151
File Encoding : 65001
Date: 2016-05-11 13:52:38
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `webim_conversations`
-- ----------------------------
DROP TABLE IF EXISTS `webim_conversations`;
CREATE TABLE `webim_conversations` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`oid` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`body` text COLLATE utf8_bin,
`created` datetime DEFAULT NULL,
`updated` datetime DEFAULT NULL,
`type` varchar(20) COLLATE utf8_bin DEFAULT NULL,
`direction` varchar(10) COLLATE utf8_bin DEFAULT NULL,
`name` varchar(20) COLLATE utf8_bin DEFAULT NULL,
`avatar` varchar(100) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of webim_conversations
-- ----------------------------
ALTER TABLE `webim_conversations`
CHANGE COLUMN `name` `oname` varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL AFTER `direction`,
CHANGE COLUMN `avatar` `oavatar` varchar(300) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL AFTER `oname`;
| true |
ce9df30c257f87f1eea2e63d93ed02df83c3e68f | SQL | eralmas7/MovieApplication | /src/main/resources/db/migration/V1__MoviesTableCreation.sql | UTF-8 | 218 | 3.09375 | 3 | [] | no_license | CREATE TABLE IF NOT EXISTS movies (
imdb_id VARCHAR NOT NULL,
screen_id VARCHAR NOT NULL,
movie_title VARCHAR,
available_seats INT NOT NULL,
reserved_seats INT DEFAULT 0,
PRIMARY KEY(imdb_id, screen_id)
); | true |
e9bc22419b0d6d0854c2d6d7c146e9a38a7b1caf | SQL | npandelakis/cs257 | /webapp/doc/database-schema.sql | UTF-8 | 1,207 | 3.359375 | 3 | [
"MIT"
] | permissive | --Written by Grace de Benedetti and Nick Pandelakis
CREATE TABLE countries (
id SERIAL,
country_name text
);
CREATE TABLE attack_types (
id SERIAL,
attack_type text
);
CREATE TABLE target_types (
id SERIAL,
target_type text
);
CREATE TABLE target_subtypes (
id SERIAL,
target_subtype text
);
CREATE TABLE weapon_types (
id SERIAL,
weapon_type text
);
CREATE TABLE weapon_subtypes (
id SERIAL,
weapon_subtype text
);
CREATE TABLE property_damage (
id SERIAL,
damage_extent text
);
CREATE TABLE attacks (
id BIGINT,
year INTEGER,
month INTEGER,
day INTEGER,
country_id INTEGER,
province text,
city text,
latitute NUMERIC,
longtitude NUMERIC,
location text,
summary text,
attack_type_id INTEGER,
success INTEGER,
suicide INTEGER,
target_type_id INTEGER,
target_subtype_id INTEGER,
target text,
perp text,
motive text,
weapon_type_id INTEGER,
weapon_subtype_id INTEGER,
weapon_detail text,
number_killed NUMERIC,
number_wounded NUMERIC,
property_damage_id INTEGER
);
CREATE TABLE country_attacks_per_year (
country_id INTEGER,
year INTEGER,
number_of_attacks INTEGER
);
CREATE TABLE province_attacks_per_year (
province_id INTEGER,
year INTEGER,
number_of_attacks INTEGER
);
| true |
7747b499ec14eb07279941ed5455054c1ec8dd45 | SQL | RussellRiesJr/chinook--RussellRiesJr | /sales_agent_customer_count.sql | UTF-8 | 191 | 3.671875 | 4 | [] | no_license |
select
e.FirstName || ' ' || e.LastName as EmployeeName,
count(c.SupportRepId) as CustomerCount
from Employee e, Customer c
where e.EmployeeId = c.SupportRepId
group by EmployeeName
| true |
75420bb122e4486ed74e825715fa32b5b7e512db | SQL | Jelonek94/Szkolenia | /Bazy_danych/Pierwszy.sql | UTF-8 | 915 | 3.640625 | 4 | [] | no_license | DROP TABLE IF EXISTS sq_has_teams;
DROP TABLE IF EXISTS study_groups;
DROP TABLE IF EXISTS faculty;
DROP TABLE IF EXISTS teams;
CREATE TABLE faculty (
name varchar(16),
CONSTRAINT fac_pkey PRIMARY KEY(name)
);
CREATE TABLE teams (
name varchar(16),
cash integer,
CONSTRAINT teams_pkey PRIMARY KEY(name)
);
CREATE TABLE study_groups(
name varchar(64),
members_num integer,
faculty_name varchar(16),
CONSTRAINT sg_pkey PRIMARY KEY(name)
);
ALTER TABLE study_groups ADD CONSTRAINT sg_fac_fkey FOREIGN KEY (faculty_name) REFERENCES faculty(name);
CREATE TABLE sg_has_teams(
team_name varchar(64),
sg_name varchar(64),
CONSTRAINT sght_pkey PRIMARY KEY (team_name,sg_name)
);
ALTER TABLE sg_has_teams ADD CONSTRAINT t_name_fkey FOREIGN KEY (team_name) REFERENCES teams(name);
ALTER TABLE sg_has_teams ADD CONSTRAINT sg_name_fkey FOREIGN KEY (sg_name) REFERENCES study_groups(name);
| true |
81c2627c8041960867ee3a338c3950e3a7cc7219 | SQL | prasanth260295/mysql | /coresoft-product-database/src/main/resources/oracle/1.0.2/Deposits_Cycle_Group_Scripts_2.sql | UTF-8 | 4,294 | 3.671875 | 4 | [] | no_license | -- renaming the column DATE_LAST_KITING_CURR_PERIOD to DATE_LAST_KITING
ALTER TABLE DEPOSIT_ACCOUNT rename column DATE_LAST_KITING_CURR_PERIOD to DATE_LAST_KITING;
CREATE OR REPLACE VIEW DEPOSIT_ACCOUNT_VW AS
select A.ACCOUNT_NO,A.INSTITUTION_ID,A.PRODUCT_ID,A.ACCOUNT_CATEGORY, A.ACCOUNT_TYPE_ID,A.BUSINESS_DATE,
DA.* from ACCOUNT A,DEPOSIT_ACCOUNT DA where A.ACCOUNT_ID=DA.ACCOUNT_ID ;
-- auto transfer
ALTER TABLE AUTOMATIC_TRANSFER_INSTRUCTION ADD ( INSTRUCTION_STATUS VARCHAR2(2) ,
COMMENTS VARCHAR2(25) ,
ALLOW_ACCOUNT_TO_OVERDRAFT NUMBER ,
INSTRUCTION_DATE DATE ,
ENTERED_BY VARCHAR2(25) );
ALTER TABLE AUTOMATIC_TRANSFER_INSTRUCTION ADD ( CLOSED_DATE DATE NULL );
CREATE OR REPLACE VIEW DEPOSIT_ACCOUNT_VW AS
select A.ACCOUNT_NO,A.INSTITUTION_ID,A.PRODUCT_ID,A.ACCOUNT_CATEGORY,
A.ACCOUNT_TYPE_ID,A.BUSINESS_DATE,A.LAST_PROCESSED_DATE,
DA.* from ACCOUNT A,DEPOSIT_ACCOUNT DA where A.ACCOUNT_ID=DA.ACCOUNT_ID ;
-- cycle group scripts
-- structure of cycle group
CREATE TABLE CYCLE_GROUP_CONFIG(
CYCLE_GROUP_CONFIG_UID NUMBER(15),
CUSTOMER_ID VARCHAR2(30),
INSTITUTION_ID VARCHAR2(30),
CYCLED_DATE DATE,
IS_COMBINED NUMBER(1),
CYCLE_CODE VARCHAR2(30),
ASG_UNIQUE_ID NUMBER(15),
main_account_id VARCHAR2(30)
);
CREATE TABLE CYCLE_GROUP_ACCTS_CONFIG(
CYCLE_GROUP_CONFIG_UID NUMBER(15),
ACCOUNT_ID VARCHAR2(30),
IS_ENABLED NUMBER(1),
IS_CYCLING_ENABLED NUMBER(1)
);
-- creating sequence for cycle group
CREATE SEQUENCE CYCLE_GRP_CONFG_UID_SEQ MINVALUE 1 NOMAXVALUE INCREMENT BY 1 START WITH 1 CACHE 20 ORDER NOCYCLE;
ALTER TABLE CYCLE_GROUP_CONFIG ADD CONSTRAINT CYC_GR_CFG_PK PRIMARY KEY (CYCLE_GROUP_CONFIG_UID);
ALTER TABLE CYCLE_GROUP_CONFIG ADD CONSTRAINT CYC_GR_CFG_ASG_UID_FK FOREIGN KEY (ASG_UNIQUE_ID) REFERENCES ACCOUNT_STATEMENT_GENERATOR (UNIQUE_ID) ON DELETE SET NULL;
ALTER TABLE CYCLE_GROUP_CONFIG ADD CONSTRAINT CYC_GR_CFG_MAID_FK FOREIGN KEY (main_account_id) REFERENCES ACCOUNT (account_id) ON DELETE SET NULL;
ALTER TABLE CYCLE_GROUP_ACCTS_CONFIG ADD CONSTRAINT CYC_GR_ACCT_CFG_IID_FK FOREIGN KEY(CYCLE_GROUP_CONFIG_UID) REFERENCES CYCLE_GROUP_CONFIG (CYCLE_GROUP_CONFIG_UID);
ALTER TABLE CYCLE_GROUP_ACCTS_CONFIG ADD CONSTRAINT CYC_GR_ACCT_CFG_AID_FK FOREIGN KEY(ACCOUNT_ID) REFERENCES ACCOUNT (ACCOUNT_ID);
ALTER TABLE CYCLE_GROUP_ACCTS_CONFIG ADD CONSTRAINT CYC_GR_ACCT_AID_UK UNIQUE(ACCOUNT_ID);
-- index creation
CREATE INDEX CYCLE_GROUP_CFG_ISCOMB_IDX ON CYCLE_GROUP_CONFIG(IS_COMBINED);
CREATE INDEX CYCLE_GROUP_CFG_CID_IID_IDX ON CYCLE_GROUP_CONFIG(CUSTOMER_ID,INSTITUTION_ID);
CREATE INDEX CYCLE_GRP_ACCT_CFG_CGCID_IDX ON CYCLE_GROUP_ACCTS_CONFIG(CYCLE_GROUP_CONFIG_UID);
CREATE OR REPLACE VIEW DEPOSIT_ACCOUNT_VW AS
select A.ACCOUNT_NO,A.INSTITUTION_ID,A.PRODUCT_ID,A.ACCOUNT_CATEGORY, A.ACCOUNT_TYPE_ID,A.BUSINESS_DATE,
A.DATE_OPENED ACCOUNT_DATE_OPENED,A.CREATION_DATE,A.PRODUCT_INSTANCE_UID,A.STATUS ACCOUNT_STATUS,A.CONTRACT_ID,A.LAST_PROCESSED_DATE,
DA.* from ACCOUNT A,DEPOSIT_ACCOUNT DA where A.ACCOUNT_ID=DA.ACCOUNT_ID ;
ALTER TABLE INSTITUTION_TRANSCODE_LOOKUP ADD POSTING_SEQUENCE NUMBER(10);
create index int_cd_hist_uid on INTEREST_CODES(INTEREST_CODE_HIST_UID);
alter table DEPOSIT_ACCOUNT rename column NO_DEBIT_ENCL_CURRENT_PERIOD
to NO_ENCLOSURE_CURRENT_PERIOD;
CREATE OR REPLACE VIEW DEPOSIT_ACCOUNT_VW AS
select A.ACCOUNT_NO,A.INSTITUTION_ID,A.PRODUCT_ID,A.ACCOUNT_CATEGORY, A.ACCOUNT_TYPE_ID,A.BUSINESS_DATE,
A.DATE_OPENED ACCOUNT_DATE_OPENED,A.CREATION_DATE,A.PRODUCT_INSTANCE_UID,A.STATUS ACCOUNT_STATUS,A.CONTRACT_ID,A.LAST_PROCESSED_DATE,
DA.* from ACCOUNT A,DEPOSIT_ACCOUNT DA where A.ACCOUNT_ID=DA.ACCOUNT_ID ;
CREATE TABLE GL_OFFSET_RECORD
(
UNIQUE_ID NUMBER(20,0) NOT NULL ,
ACCOUNT_NUMBER VARCHAR2(30) NULL,
INSTITUTION_ID VARCHAR2(30) NOT NULL,
ACCOUNT_TYPE_ID VARCHAR2(25) NULL,
CREATION_DATE DATE NOT NULL,
EFFECTIVE_DATE DATE NOT NULL,
ACCOUNT_CATEGORY NUMBER(5,0) NULL,
PRODUCT_TYPE_ID VARCHAR2(30) NULL,
BRANCH_ID VARCHAR2(30) NULL,
TRANSACTION_AMOUNT NUMBER(30,5) NULL,
SOURCE_TYPE NUMBER(5,0) NULL ,
TRANS_CODE VARCHAR2(30) NULL
);
CREATE SEQUENCE GL_OFFSET_UNIQUE_SEQ INCREMENT BY 1 START WITH 1;
alter table PERSON add (MOTHERS_MAIDEN_NAME VARCHAR2(100) NULL); | true |
8c2adb01fe85e8754498626f3b5fd7e95f61c901 | SQL | rohitsingh186/question-bank | /db/dump.sql | UTF-8 | 6,334 | 3.265625 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 5.6.24, for Win64 (x86_64)
--
-- Host: localhost Database: question_bank
-- ------------------------------------------------------
-- Server version 5.6.24
/*!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 */;
--
-- Current Database: `question_bank`
--
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `question_bank` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `question_bank`;
--
-- Table structure for table `qb_level`
--
DROP TABLE IF EXISTS `qb_level`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `qb_level` (
`id` varchar(255) NOT NULL,
`added_date` datetime DEFAULT NULL,
`code` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `qb_level`
--
LOCK TABLES `qb_level` WRITE;
/*!40000 ALTER TABLE `qb_level` DISABLE KEYS */;
INSERT INTO `qb_level` VALUES ('5ccdc296-f6ed-44d8-98a4-853c406a2b6b','2018-08-04 16:29:24','Easy');
/*!40000 ALTER TABLE `qb_level` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `qb_option`
--
DROP TABLE IF EXISTS `qb_option`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `qb_option` (
`id` varchar(255) NOT NULL,
`added_date` datetime DEFAULT NULL,
`correct_option` bit(1) NOT NULL,
`last_updated_date` datetime DEFAULT NULL,
`text` varchar(255) DEFAULT NULL,
`question_id` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK5gymee17vnx062xgba9uqn2a0` (`question_id`),
CONSTRAINT `FK5gymee17vnx062xgba9uqn2a0` FOREIGN KEY (`question_id`) REFERENCES `qb_question` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `qb_option`
--
LOCK TABLES `qb_option` WRITE;
/*!40000 ALTER TABLE `qb_option` DISABLE KEYS */;
INSERT INTO `qb_option` VALUES ('2f876f69-d75c-4d05-ad25-412674d7dbb0','2018-08-04 16:34:23','','2018-08-04 16:34:23','No','79d13a61-7e64-4d2a-a65d-08d86becdb09'),('7c5da41e-29f2-4784-b884-bea202d26a8a','2018-08-04 16:34:23','\0','2018-08-04 16:34:23','Yes','79d13a61-7e64-4d2a-a65d-08d86becdb09');
/*!40000 ALTER TABLE `qb_option` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `qb_question`
--
DROP TABLE IF EXISTS `qb_question`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `qb_question` (
`id` varchar(255) NOT NULL,
`added_date` datetime DEFAULT NULL,
`last_updated_date` datetime DEFAULT NULL,
`text` varchar(255) DEFAULT NULL,
`level_id` varchar(255) NOT NULL,
`topic_id` varchar(255) NOT NULL,
`submitter_id` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK7o7yx6et9eu8a3x54wg7c27v6` (`level_id`),
KEY `FK42dafurwqr69h0u4rtehjutd6` (`topic_id`),
KEY `FKtegtgt8g5xbs5qexnuhfjriye` (`submitter_id`),
CONSTRAINT `FK42dafurwqr69h0u4rtehjutd6` FOREIGN KEY (`topic_id`) REFERENCES `qb_topic` (`id`),
CONSTRAINT `FK7o7yx6et9eu8a3x54wg7c27v6` FOREIGN KEY (`level_id`) REFERENCES `qb_level` (`id`),
CONSTRAINT `FKtegtgt8g5xbs5qexnuhfjriye` FOREIGN KEY (`submitter_id`) REFERENCES `qb_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `qb_question`
--
LOCK TABLES `qb_question` WRITE;
/*!40000 ALTER TABLE `qb_question` DISABLE KEYS */;
INSERT INTO `qb_question` VALUES ('79d13a61-7e64-4d2a-a65d-08d86becdb09','2018-08-04 16:34:23','2018-08-04 16:34:23','Is Map a part of collections framework ?','5ccdc296-f6ed-44d8-98a4-853c406a2b6b','1272f321-ebe4-461c-8d80-98fada7b1271','423d5d55-4148-4523-a00b-296574e16ec6');
/*!40000 ALTER TABLE `qb_question` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `qb_topic`
--
DROP TABLE IF EXISTS `qb_topic`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `qb_topic` (
`id` varchar(255) NOT NULL,
`added_date` datetime DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `qb_topic`
--
LOCK TABLES `qb_topic` WRITE;
/*!40000 ALTER TABLE `qb_topic` DISABLE KEYS */;
INSERT INTO `qb_topic` VALUES ('1272f321-ebe4-461c-8d80-98fada7b1271','2018-08-04 16:29:59','Collections Framework');
/*!40000 ALTER TABLE `qb_topic` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `qb_user`
--
DROP TABLE IF EXISTS `qb_user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `qb_user` (
`id` varchar(255) NOT NULL,
`full_name` varchar(255) DEFAULT NULL,
`user_name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `qb_user`
--
LOCK TABLES `qb_user` WRITE;
/*!40000 ALTER TABLE `qb_user` DISABLE KEYS */;
INSERT INTO `qb_user` VALUES ('423d5d55-4148-4523-a00b-296574e16ec6','Rohit Kumar Singh','rkumarsingh');
/*!40000 ALTER TABLE `qb_user` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-08-04 16:44:47
| true |
4ce744c264472c981a68fac5862cb98a6c98d26f | SQL | samklr/amazon-redshift-utils | /src/AdminViews/v_generate_external_tbl_ddl.sql | UTF-8 | 5,208 | 3.296875 | 3 | [
"Apache-2.0"
] | permissive | --DROP VIEW admin.v_generate_external_tbl_ddl;
/**********************************************************************************************
Purpose: View to get the DDL for an external table.
History:
2019-07-10 styerp Created
**********************************************************************************************/
CREATE OR REPLACE VIEW admin.v_generate_external_tbl_ddl AS
SELECT schemaname
, tablename
, seq
, ddl
FROM (
SELECT 'CREATE EXTERNAL TABLE ' + quote_ident(schemaname) + '.' + quote_ident(tablename) + '('
+ quote_ident(columnname) + ' ' + external_type AS ddl
, 0 AS seq
, schemaname
, tablename
FROM svv_external_columns
WHERE columnnum = 1
UNION ALL
SELECT ', ' + quote_ident(columnname) + ' '
+ decode(external_type, 'double', 'double precision', external_type) AS ddl
, columnnum AS seq
, schemaname
, tablename
FROM svv_external_columns
WHERE columnnum > 1
AND part_key = 0
UNION ALL
SELECT ')' AS ddl
, 100 + max_col AS seq
, schemaname
, tablename
FROM (
SELECT schemaname
, tablename
, max(columnnum) AS max_col
FROM svv_external_columns
WHERE part_key = 0
GROUP BY 1
, 2
) sub
UNION ALL
SELECT 'PARTITIONED BY (' + quote_ident(columnname) + ' ' + external_type AS ddl
, 100000 + part_key + columnnum AS seq
, schemaname
, tablename
FROM svv_external_columns
WHERE part_key = 1
UNION ALL
SELECT ',' + quote_ident(columnname) + ' ' + external_type AS ddl
, 100000 + part_key + columnnum AS seq
, schemaname
, tablename
FROM svv_external_columns
WHERE part_key > 1
UNION ALL
SELECT ')' AS ddl
, 999999 AS seq
, schemaname
, tablename
FROM svv_external_columns
WHERE part_key = 1
UNION ALL
SELECT 'ROW FORMAT SERDE ' + quote_literal(serialization_lib)
, 1000000 AS seq
, schemaname
, tablename
FROM svv_external_tables
UNION ALL
SELECT 'WITH SERDEPROPERTIES ( ' + regexp_replace(
regexp_replace(regexp_replace(serde_parameters, '\\{|\\}', ''), '"', '\''), ':', '=') + ')' AS ddl
, 1000001 AS seq
, schemaname
, tablename
FROM svv_external_tables
WHERE serde_parameters IS NOT NULL
UNION ALL
SELECT 'STORED AS INPUTFORMAT ' + quote_literal(input_format) + ' OUTPUTFORMAT '
+ quote_literal(output_format)
, 1000001 AS seq
, schemaname
, tablename
FROM svv_external_tables
WHERE input_format IS NOT NULL
AND output_format IS NOT NULL
UNION ALL
SELECT 'LOCATION ' + quote_literal(location)
, 1000002 AS seq
, schemaname
, tablename
FROM svv_external_tables
UNION ALL
SELECT 'TABLE PROPERTIES (' + quote_literal(
regexp_replace(params, $$'EXTERNAL'='TRUE',|'transient_lastDdlTime'='[::digit::]*',$$, NULL))
+ ')' AS ddl
, 1000004 AS seq
, schemaname
, tablename
FROM (
SELECT schemaname
, tablename
, regexp_replace(regexp_replace(regexp_replace(parameters, '\\{|\\}', ''), '"', '\''), ':',
'=') AS params
FROM svv_external_tables
) tbl_params
WHERE params IS NOT NULL
UNION ALL
SELECT ';' AS ddl
, 9999999999 AS seq
, schemaname
, tablename
FROM svv_external_tables
) gen
WHERE ddl IS NOT NULL
ORDER BY 1 DESC
, 2 DESC
, 3;
| true |
e4e79a9e5581d68a73689f796b57cd7610c9f886 | SQL | marioz22/cafeteria-system | /fosdb.sql | UTF-8 | 4,889 | 3.0625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 04, 2019 at 06:58 AM
-- Server version: 10.1.36-MariaDB
-- PHP Version: 7.2.10
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `fosdb`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_admin`
--
CREATE TABLE `tbl_admin` (
`ID` int(2) NOT NULL,
`username` varchar(25) NOT NULL,
`password` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_admin`
--
INSERT INTO `tbl_admin` (`ID`, `username`, `password`) VALUES
(0, 'admin', 'password');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_menu`
--
CREATE TABLE `tbl_menu` (
`menuID` int(11) NOT NULL,
`menuName` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_menu`
--
INSERT INTO `tbl_menu` (`menuID`, `menuName`) VALUES
(1, 'Nasi Goreng');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_menuitem`
--
CREATE TABLE `tbl_menuitem` (
`itemID` int(11) NOT NULL,
`menuID` int(11) NOT NULL,
`menuItemName` text NOT NULL,
`price` decimal(15,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_menuitem`
--
INSERT INTO `tbl_menuitem` (`itemID`, `menuID`, `menuItemName`, `price`) VALUES
(1, 1, 'Ayam', '3.00'),
(2, 1, 'Cina', '4.00');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_order`
--
CREATE TABLE `tbl_order` (
`orderID` int(11) NOT NULL,
`status` text NOT NULL,
`total` decimal(15,2) NOT NULL,
`order_date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_orderdetail`
--
CREATE TABLE `tbl_orderdetail` (
`orderID` int(11) NOT NULL,
`orderDetailID` int(11) NOT NULL,
`itemID` int(11) NOT NULL,
`quantity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_role`
--
CREATE TABLE `tbl_role` (
`role` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_role`
--
INSERT INTO `tbl_role` (`role`) VALUES
('waiter'),
('chef');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_staff`
--
CREATE TABLE `tbl_staff` (
`staffID` int(2) NOT NULL,
`username` varchar(25) NOT NULL,
`password` varchar(100) NOT NULL,
`status` text NOT NULL,
`role` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_staff`
--
INSERT INTO `tbl_staff` (`staffID`, `username`, `password`, `status`, `role`) VALUES
(1, 'Abu', 'abc123', 'Offline', 'waiter'),
(4, 'Anjir', 'abc123', 'Online', 'chef'),
(5, 'Fuad', 'abc123', 'Online', 'chef'),
(6, 'Ali', 'abc123', 'Online', 'chef');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tbl_admin`
--
ALTER TABLE `tbl_admin`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `tbl_menu`
--
ALTER TABLE `tbl_menu`
ADD PRIMARY KEY (`menuID`);
--
-- Indexes for table `tbl_menuitem`
--
ALTER TABLE `tbl_menuitem`
ADD PRIMARY KEY (`itemID`),
ADD KEY `menuID` (`menuID`);
--
-- Indexes for table `tbl_order`
--
ALTER TABLE `tbl_order`
ADD PRIMARY KEY (`orderID`);
--
-- Indexes for table `tbl_orderdetail`
--
ALTER TABLE `tbl_orderdetail`
ADD PRIMARY KEY (`orderDetailID`),
ADD KEY `itemID` (`itemID`),
ADD KEY `orderID` (`orderID`);
--
-- Indexes for table `tbl_staff`
--
ALTER TABLE `tbl_staff`
ADD PRIMARY KEY (`staffID`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `tbl_menu`
--
ALTER TABLE `tbl_menu`
MODIFY `menuID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `tbl_menuitem`
--
ALTER TABLE `tbl_menuitem`
MODIFY `itemID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `tbl_orderdetail`
--
ALTER TABLE `tbl_orderdetail`
MODIFY `orderDetailID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `tbl_staff`
--
ALTER TABLE `tbl_staff`
MODIFY `staffID` int(2) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
1855b0ab44e37ac740413e53af42078718886cfa | SQL | elrik428/atom_Warehouse | /DCC_Reports/DCC_ReportMonthly_Attica_ToRun.sql | UTF-8 | 8,261 | 3.0625 | 3 | [] | no_license |
-- Attica
-- 1.YTD
-- 1a.
select substring(LEFT(datum,10),1,4)+substring(LEFT(datum,10),6,2)+ substring(LEFT(datum,10),9,2),
replace((convert(varchar,(convert(money,(CAST((count(*)) as dec(10,0))/1),0)),1)),'.00','') as ALL_TRN,
replace((convert(varchar,(convert(money,(CAST((sum(case when right(DCCCHOSEN_DCCELIGIBLE,2)='EG' then 1 else 0 end)) as dec(10,0))/1),0)),1)),'.00','') as Eligible,
replace((convert(varchar,(convert(money,(CAST((sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='Y' then 1 else 0 end)) as dec(10,0))/1),0)),1)),'.00','') as DCC_Accepted,
replace((convert(varchar,(convert(money,(CAST((sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='N' then 1 else 0 end)) as dec(10,0))/1),0)),1)),'.00','') as DCC_Not_Accepted,
(replace((replace((replace((convert(nvarchar(15),(cast((sum(cast((merchant_amount/100) as dec(15,2))))as money)),1)),',' ,'_' )),'.',',')),'_','.')) + '€' as ALL_AMNT,
(replace((replace((replace((convert(nvarchar(15),(cast((sum(case when right(DCCCHOSEN_DCCELIGIBLE,2)='EG' then (Cast(merchant_amount as dec(15,2))/100) else 0 end))as money)),1)),',' ,'_' )),'.',',')),'_','.')) + '€' as Eligible,
(replace((replace((replace((convert(nvarchar(15),(cast((sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='Y' then (Cast(merchant_amount as dec(15,2))/100) else 0 end))as money)),1)),',' ,'_' )),'.',',')),'_','.')) + '€' as DCC_Accepted,
(replace((replace((replace((convert(nvarchar(15),(cast((sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='N' then (Cast(merchant_amount as dec(15,2))/100) else 0 end))as money)),1)),',' ,'_' )),'.',',')),'_','.')) + '€' as DCC_Not_Accepted
from attikaw
where
(
(TID in ('GR73000005','GR73000038') and datum>='2017-10-13 00:00:01')
or
(TID in ('GR73000022','GR73000093','GR73000097','GR73000171','GR73000217','GR73002538','GR73007520','GR73007521') and datum>='2017-11-20 00:00:01')
OR
(a.TID in ('GR73000070','GR73000031','GR73000090','GR73000071','GR73000003','GR73000162','GR73000018','GR73000135','GR73000019','GR73000222','GR73000224') and datum>='2018-10-30 00:00:01')
OR
(a.TID in ('GR73000088') and datum>='2019-10-21 00:00:01')
OR
(a.TID in ('GR73000029','GR73000030','GR73000034','GR73000036','GR73000066','GR73007798','GR73007805','GR73007943','GR73007944','GR73007945','GR73007946') and datum>='2019-11-15 00:00:01')
)
group by left(datum,10)
order by left(datum,10)
-- 2. PerTID
select right(tid,8),substring(LEFT(datum,10),9,2) + '/' +substring(LEFT(datum,10),6,2)+ '/' +substring(LEFT(datum,10),1,4),dcc_currency,
count(*) as ALL_TRN,
sum(case when right(DCCCHOSEN_DCCELIGIBLE,2)='EG' then 1 else 0 end) as Eligible,
sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='Y' then 1 else 0 end) as DCC_Accepted,
sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='N' then 1 else 0 end) as DCC_Not_Accepted,
(replace((replace((replace((replace((convert(nvarchar(15),(cast((sum(cast((merchant_amount/100) as dec(15,2))))as money)),1)),'.00',' ')),',' ,'_' )),'.',',')),'_','.')) as ALL_AMNT,
(replace((replace((replace((convert(nvarchar(15),(cast((sum(case when right(DCCCHOSEN_DCCELIGIBLE,2)='EG' then (Cast(merchant_amount as dec(15,2))/100) else 0 end))as money)),1)),',' ,'_' )),'.',',')),'_','.')) as Eligible,
(replace((replace((replace((convert(nvarchar(15),(cast((sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='Y' then (Cast(merchant_amount as dec(15,2))/100) else 0 end))as money)),1)),',' ,'_' )),'.',',')),'_','.')) as DCC_Accepted,
(replace((replace((replace((convert(nvarchar(15),(cast((sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='N' then (Cast(merchant_amount as dec(15,2))/100) else 0 end))as money)),1)),',' ,'_' )),'.',',')),'_','.')) as DCC_Not_Accepted
from attikaw
where
datum > '2018-" + file_Arr[2] + "-01 00:00:00' and
(
(TID in ('GR73000005','GR73000038') and datum>='2017-10-13 00:00:01')
or
(TID in ('GR73000022','GR73000093','GR73000097','GR73000171','GR73000217','GR73002538','GR73007520','GR73007521') and datum>='2017-11-20 00:00:01')
OR
(a.TID in ('GR73000070','GR73000031','GR73000090','GR73000071','GR73000003','GR73000162','GR73000018','GR73000135','GR73000019','GR73000222','GR73000224') and datum>='2018-10-30 00:00:01')
OR
(a.TID in ('GR73000088') and datum>='2019-10-21 00:00:01')
OR
(a.TID in ('GR73000029','GR73000030','GR73000034','GR73000036','GR73000066','GR73007798','GR73007805','GR73007943','GR73007944','GR73007945','GR73007946') and datum>='2019-11-15 00:00:01')
)
group by right(tid,8),left(datum,10),dcc_currency
order by right(tid,8),left(datum,10),dcc_currency
-- 3. Details
select right(tid,8),substring(LEFT(datum,10),9,2) + '/' +substring(LEFT(datum,10),6,2)+ '/' +substring(LEFT(datum,10),1,4),dcc_currency,
count(*) as ALL_TRN,
sum(case when right(DCCCHOSEN_DCCELIGIBLE,2)='EG' then 1 else 0 end) as Eligible,
sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='Y' then 1 else 0 end) as DCC_Accepted,
sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='N' then 1 else 0 end) as DCC_Not_Accepted,
(replace((replace((replace((replace((convert(nvarchar(15),(cast((sum(cast((merchant_amount/100) as dec(15,2))))as money)),1)),'.00',' ')),',' ,'_' )),'.',',')),'_','.')) as ALL_AMNT,
(replace((replace((replace((convert(nvarchar(15),(cast((sum(case when right(DCCCHOSEN_DCCELIGIBLE,2)='EG' then (Cast(merchant_amount as dec(15,2))/100) else 0 end))as money)),1)),',' ,'_' )),'.',',')),'_','.')) as Eligible,
(replace((replace((replace((convert(nvarchar(15),(cast((sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='Y' then (Cast(merchant_amount as dec(15,2))/100) else 0 end))as money)),1)),',' ,'_' )),'.',',')),'_','.')) as DCC_Accepted,
(replace((replace((replace((convert(nvarchar(15),(cast((sum(case when left(DCCCHOSEN_DCCELIGIBLE,1)='N' then (Cast(merchant_amount as dec(15,2))/100) else 0 end))as money)),1)),',' ,'_' )),'.',',')),'_','.')) as DCC_Not_Accepted
from attikaw
where
datum > '2018-" + file_Arr[2] + "-01 00:00:00' and
(
(TID in ('GR73000005','GR73000038') and datum>='2017-10-13 00:00:01')
or
(TID in ('GR73000022','GR73000093','GR73000097','GR73000171','GR73000217','GR73002538','GR73007520','GR73007521') and datum>='2017-11-20 00:00:01')
OR
(a.TID in ('GR73000070','GR73000031','GR73000090','GR73000071','GR73000003','GR73000162','GR73000018','GR73000135','GR73000019','GR73000222','GR73000224') and datum>='2018-10-30 00:00:01')
OR
(a.TID in ('GR73000088') and datum>='2019-10-21 00:00:01')
OR
(a.TID in ('GR73000029','GR73000030','GR73000034','GR73000036','GR73000066','GR73007798','GR73007805','GR73007943','GR73007944','GR73007945','GR73007946') and datum>='2019-11-15 00:00:01')
)
group by right(tid,8),left(datum,10),dcc_currency
order by right(tid,8),left(datum,10),dcc_currency
-- 4. PerArea
select substring(LEFT(datum,10),9,2) + '/' +substring(LEFT(datum,10),6,2)+ '/' +substring(LEFT(datum,10),1,4) as Transaction_Date,
substring(LEFT(datum,10),9,2) + '/' +substring(LEFT(datum,10),6,2)+ '/' +substring(LEFT(datum,10),1,4) +' ' + substring(RIGHT(datum,8),1,5) As Transaction_TimeStamp,
right(TID,8) as TID_, vispan as PAN,
(replace((cast((Cast(merchant_amount as dec(15,0))/100) as dec(15,2))),'.',',')) as Original_Amount,
(case when right(DCCCHOSEN_DCCELIGIBLE,2)='EG' then dcc_currency else ' ' end) dcc__currency ,
(replace((case when right(DCCCHOSEN_DCCELIGIBLE,2)='EG' then cast((Cast(dcc_amount as dec(15,0))/100) as dec(15,2)) else 0 end),'.',',')) as DCC_AMOUNT,
(case when right(DCCCHOSEN_DCCELIGIBLE,2)='EG' then 'Y' else 'N' end) as Eligible_YN,
left(DCCCHOSEN_DCCELIGIBLE,1) DCC_Accepted_YN
from attikaw
where
datum > '2018-" + file_Arr[2] + "-01 00:00:00' and
(
(TID in ('GR73000005','GR73000038') and datum>='2017-10-13 00:00:01')
or
(TID in ('GR73000022','GR73000093','GR73000097','GR73000171','GR73000217','GR73002538','GR73007520','GR73007521') and datum>='2017-11-20 00:00:01')
OR
(a.TID in ('GR73000070','GR73000031','GR73000090','GR73000071','GR73000003','GR73000162','GR73000018','GR73000135','GR73000019','GR73000222','GR73000224') and datum>='2018-10-30 00:00:01')
OR
(a.TID in ('GR73000088') and datum>='2019-10-21 00:00:01')
OR
(a.TID in ('GR73000029','GR73000030','GR73000034','GR73000036','GR73000066','GR73007798','GR73007805','GR73007943','GR73007944','GR73007945','GR73007946') and datum>='2019-11-15 00:00:01')
)
order by left(datum,10),Datum,TID
| true |
d95e1cc4b6b50e3a7f1e7f27f789eb6ac8d1d3dc | SQL | hxnky/SQL | /2020.11.10.sql | UTF-8 | 6,853 | 3.609375 | 4 | [] | no_license | -- 2020.11.10
-- 함수
-- 단일행, 집합 함수
-- 단일행 함수 : 숫자, 문자, 날짜, 변환함수
desc dual;
-- 숫자 함수
select ABS(-15.5) from dual; -- 절댓값
select FLOOR(15.7) from dual; -- 소수점 절사
select ROUND(15.693) from dual; -- 반올림
select ROUND(15.693,1) from dual; -- 소수점 둘째자리에서 반올림
select LOG(10,100) from dual; -- 로그(지수 구하기)
select POWER(3,2) from dual; --제곱 구하기 / (x,y) -> x의 y승
-- 문자 함수
select concat('나는', ' 손흥민 입니다.') from dual; -- 문자열 두개를 붙인다.
select concat('저의 이름은 ',ename) from emp where job='MANAGER';
select LOWER('MR. SCOTT MCMILLAN') "Lowercase" from dual; -- 대문자를 소문자로 변경
select lower(ename) from emp;
select LPAD('Page 1',15,'*.') FROM DUAL; -- 특정 패턴 만들기 / 전체가 15자리이고 왼쪽으로 *이 채워진다.
select RPAD('00112-3',14,'*') FROM DUAL; -- 특정 패턴 만들기 / 전체가 15자리이고 오른쪽으로 *이 채워진다.
select SUBSTR('ABCDEFG',3,4) FROM DUAL; -- 지정된 문자열 자르기 / 3번째 자리(C)부터 4개(CDEF)
select RPAD(substr('001212-3001247',1,8),14,'*') FROM DUAL; -- 특정 패턴 만들기 / 8번째 숫자까지만 보여주고 그 뒤는 *로 채워진다 / 숫자 자리에 컬럼을 넣어도 됨
select ltrim('===from===', '=') from dual; -- 왼쪽에 있는 문자가 일치하면 지운다.
select rtrim('===from===', '=') from dual; -- 오른쪽에 있는 문자가 일치하면 지운다.
select trim('=' from '===from===' ) as "from" from dual; -- 일치하는 문자를 지운다
select REPLACE('J ACK and JUE','J','BL') from dual; -- 문자 치환하기 (x, y, z) / x에 있는 y를 z로 바꿔라
select REPLACE('000000-0000000', '-', '') from dual; -- 문자 치환하기 (x, y, z) / x에 있는 y를 z로 바꿔라
-- 날짜 함수
select sysdate from dual; -- 현재 날짜 출력
select sysdate+14 from dual; -- 현재 날짜 + x일 출력
select sysdate-14 from dual; -- 현재 날짜 - x일 출력
select add_months(sysdate, 2) from dual; -- 현재 날짜 ±x월 출력
select last_day(sysdate) from dual; -- 현재 월의 마지막 날짜 출력
-- 변환 함수
-- TO_CHAR
-- 날짜 -> 문자
select sysdate, to_char(sysdate, 'YYYY.MM.DD DAY AM HH24:MI:SS') from dual; -- 날짜를 특정 형태로 바꿔 출력
select to_char(sysdate, 'YYYY.MM.DD. HH24:MI') from dual;
-- 숫자 -> 문자
select to_char(10000.123, '000,000.00') from dual; -- 해당 자리까지 출력 / 출력 범위 넘어갈경우 #으로 출력됨 / 출력 범위보다 작을경우 부족한 자릿수만큼 앞에 0을 붙인다.
select to_char(10000, 'L999,999.99') from dual; -- 해당 지역의 통화 출력 / 출력 범위보다 작을 경우 그대로 출력함
select sal,to_char(sal*1100,'L99,999,999.99') from emp;
select ename, job, sal, to_char(sal*1100*12+nvl(comm,0)*1100,'L99,999,999.99') as "연봉" from emp order by sal desc; -- 누가 가장 급여를 많이 받는지
-- 문자 -> 날짜
SELECT to_date ('2009/09/05','YYYY/MM/DD') from dual;
SELECT to_date ('2020.11.01','YYYY.MM.DD') from dual;
select trunc(sysdate - to_date('20-01-01', 'YY-MM-DD')) from dual; -- 오늘이 2020년에서 며칠이 지났는지 확인
select trunc(sysdate - to_date('1998-10-26', 'YYYY-MM-DD')) from dual; -- 내가 며칠 살았는지 확인
-- 문자 -> 숫자
select to_number('100.00', '999.99')/to_number('10.00', '999.99') from dual;
-- decode 함수 : switch문과 비슷하다.
-- 사원이름, 부서번호, 부서 이름을 출력
select ename, deptno, decode(deptno, 10, 'ACCOUNTING', 20, 'RESEARCH', 30, 'SALES', 40, 'OPERATIONS')
as "부서" from emp order by deptno; -- deptno가 n이면 해당 부서이름 출력
-- 직급에 따라 급여 인상
-- 'ANALYST' -> 5%
-- 'SALESMAN' -> 10%
--'MANAGER' -> 15%
-- 'CLERK' -> 20%
select ename, sal, decode(job, 'ANALYST', sal*1.05, 'SALESMAN', sal*1.1, 'MANAGER', sal*1.15, 'CLERK', sal*1.20)
as upsal from emp order by sal;
select emp.ename as name, deptno as dno,
case when deptno = 10 then 'ACCOUNTING' when deptno = 20 then 'RESEARCH'
when deptno = 30 then 'SALES' when deptno = 40 then 'OPERAION' end
as dname from emp order by dname;
-- 그룹함수 : 하나의 행의 컬럼이 대상이 아닌 행의 그룹의 컬럼들을 묶어 그룹화하고 연산 --> 단일함수와 같이 쓸 수 없음
-- : SUM, AVG, COUNT, MAX, MIN
select to_char(sum(sal)*1100, 'L999,999,999') as "월급 총액",
round(avg(sal)) as "월급 평균",
count(*) as "전체 사원(명)", count(comm) as "커미션 받는 사원(명)",
max(sal)*1100 as "가장 높은 월급(원)",
min(sal)*1100 as "가장 낮은 월급(원)"
from emp;
select sum(comm), avg(comm), count(nvl(comm,0)), max(comm), min(comm) from emp; -- null은 빼고 연산한다.
-- 전체 행 구하기
select count(sal) as "MANAGER의 수(명)", avg(sal) as "매니저의 평균 월급", max(sal), min(sal) from emp where job = 'MANAGER';
-- 직무의 개수 구하기
select count(distinct job) as "직무의 개수(개)" from emp order by job;
-- 특정 컬럼 기준으로 그룹핑 : group by 컬럼 이름
-- 각 부서의 소속 인원 구하기
select deptno, count(*) as "부서 소속 인원(명)"
from emp
group by deptno
order by count(*) desc;
-- 각 부서별 총 급여 구하기
select deptno, sum(sal) as "부서 별 총 급여(원)"
from emp
group by deptno
order by deptno;
-- 부서별 급여 평균 구하기
select deptno, round(avg(sal)) as "부서 별 급여 평균(원)"
from emp
group by deptno
order by deptno;
-- 부서별 급여 최고 금액과 최저 금액 출력
select deptno, max(sal) as "급여 최고 금액(원)", min(sal) as "급여 최저 금액(원)", max(sal)-min(sal) as "급여 차이(원)"
from emp
group by deptno
order by deptno;
-- 부서별로 그룹지은 후(GROUP BY)
-- 그룹 지어진 부서별 평균 급여
-- 평균 급여가 2000 이상인 (HAVING)
-- 부서 번호와 부서별 평균 급여를 출력
select deptno, round(avg(sal))
from emp
group by deptno
having avg(sal) >= 2000
order by deptno;
-- 부서별 급여의 최대값과 최소값을 구하되
-- 최대 급여가 2900 이상인 부서만 출력
select deptno, max(sal), min(sal)
from emp
group by deptno
having max(sal)>=2900
order by deptno;
-- 직무별 지표 : 사원의 수, 급여의 총 합, 평균 급여, 최대 급여, 최소 급여
select job as "직업",
count(*) || '명' as "사원의 수",
to_char(sum(sal)*1100, 'L999,999,999') as "급여의 총 합",
to_char(avg(sal)*1100, 'L999,999,999.99') as "평균 급여",
to_char(max(sal)*1100, 'L999,999,999') as "최대 급여",
to_char(min(sal)*1100, 'L999,999,999') as "최소 급여"
from emp
where job != 'PRESIDENT'
group by job
order by job;
| true |
34df349aec84f80dc780c2f05a0c0458b62caa72 | SQL | danielhndz/DB-FL-CLAN | /sql/DisparadoresNoOk.sql | ISO-8859-1 | 1,863 | 2.984375 | 3 | [] | no_license | --UP_FICHAMEDICA
--No debera dejar actualizar una ficha medica
UPDATE FichaMedica SET descripcion = null WHERE codigo = 1;
--UP_TESTFISICO
--No debera dejar actualizar un test fisico
UPDATE TestFisico SET imc = null WHERE codigo = 1;
--UP_ENCARGADOA
--No deberia dejar actualizar encargadoA
UPDATE EncargadoA SET cantidadInicial = 0 WHERE cantidadInicial > 1;
--UP_UTILIZADOPOR
--No deberia dejar actualizar utilizadopor
UPDATE UtilizadoPor SET estadoFinal = 'Excelente' WHERE implemento = 'Baln';
--AD_TELEFONOSJUGADOR
INSERT INTO TelefonosJugador VALUES (50086783529, 5432345);
--UP_JUGADOR_TID
--No debera dejar actualizar el tipo de documento de TI a CE
UPDATE Jugador SET tipoDocumento = 'CE', edad = 18 WHERE noDocumento = 90543234567;
--No debera dejar actualizar el tipo de documento a CC si no se actualiza la edad a 18
UPDATE Jugador SET tipoDocumento = 'CC', edad = 17 WHERE noDocumento = 45678765432;
--UP_JUGADOR_DOCUMENTO : CASCADE NO DEFINIDA
--No debra dejar actualizar el documento si no se actualiza la edad a 18 aos y el documento a CC
--INSERT INTO Jugador VALUES ('TI', 4567654323, 'Luis Perez', 15, 'luchitoperez2@theglobeandmail.com', '246 Arrowood Plaza', 'Julienne Perez', '5976345366', 'FL CLAN Infantil Norte', 'AT', 'M');
--UPDATE Jugador SET tipoDocumento = 'CC', edad = 17, noDocumento = 23456432 WHERE noDocumento = 4567654323;
--UP_JUIGADOR_EDAD
UPDATE Jugador SET edad = 18 WHERE noDocumento = 43452324543;
--UP_EMPLEADO_VALIDO
UPDATE Empleado SET fechaRetiro = NULL WHERE documento = 9400084145;
--DEL_ASISTENCIA
--No debera dejar eliminar los registros de Asistencia
DELETE FROM Asistencia;
--DEL_ENCARGADOA
--No debera dejer eleminar los registros de EncargadoA
DELETE FROM EncargadoA;
--DEL_UTILIZADO_POR
--No debera dejar eliminar los registros de utilizadoPor
DELETE FROM UtilizadoPor | true |
1827db0731238a438214dddf79444ba76b113520 | SQL | shreyasnisal/DBMS_VideoSeries | /tutorialdb.sql | UTF-8 | 6,615 | 3.3125 | 3 | [
"MIT"
] | permissive | -- MySQL dump 10.13 Distrib 8.0.15, for Win64 (x86_64)
--
-- Host: localhost Database: tutorialdb
-- ------------------------------------------------------
-- Server version 8.0.15
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
SET NAMES utf8mb4 ;
/*!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 `capitals`
--
DROP TABLE IF EXISTS `capitals`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `capitals` (
`country_code` varchar(2) NOT NULL,
`capital` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `capitals`
--
LOCK TABLES `capitals` WRITE;
/*!40000 ALTER TABLE `capitals` DISABLE KEYS */;
INSERT INTO `capitals` VALUES ('BT','Thimphu'),('US','Washington DC'),('CA','Ottawa'),('AU','Canberra'),('ES','Madrid'),('IT','Rome'),('DE','Berlin'),('BR','Brasilia'),('UY','Montevideo'),('IN','Delhi'),('PK','Islamabad'),('CN','Beijing');
/*!40000 ALTER TABLE `capitals` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `countries`
--
DROP TABLE IF EXISTS `countries`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `countries` (
`country_code` varchar(2) NOT NULL,
`country_name` varchar(100) NOT NULL,
`region_id` int(11) NOT NULL,
PRIMARY KEY (`country_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `countries`
--
LOCK TABLES `countries` WRITE;
/*!40000 ALTER TABLE `countries` DISABLE KEYS */;
INSERT INTO `countries` VALUES ('AU','Australia',5),('BR','Brazil',4),('BT','Bhutan',1),('CA','Canada',3),('CN','China',1),('DE','Germany',2),('ES','Spain',2),('GB','Great Britain',2),('IN','India',1),('IT','Italy',2),('PK','Pakistan',1),('US','United States of America',3),('UY','Uruguay',4);
/*!40000 ALTER TABLE `countries` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `currencies`
--
DROP TABLE IF EXISTS `currencies`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `currencies` (
`country_code` varchar(2) DEFAULT NULL,
`currency_code` varchar(3) DEFAULT NULL,
`value_usd` decimal(5,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `currencies`
--
LOCK TABLES `currencies` WRITE;
/*!40000 ALTER TABLE `currencies` DISABLE KEYS */;
INSERT INTO `currencies` VALUES ('US','USD',1.00),('GB','GBP',0.81),('IN','INR',75.84),('PK','PKR',167.50),('US','USD',7.07);
/*!40000 ALTER TABLE `currencies` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `european_union`
--
DROP TABLE IF EXISTS `european_union`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `european_union` (
`country_code` varchar(2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `european_union`
--
LOCK TABLES `european_union` WRITE;
/*!40000 ALTER TABLE `european_union` DISABLE KEYS */;
INSERT INTO `european_union` VALUES ('ES'),('IT'),('DE');
/*!40000 ALTER TABLE `european_union` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `major_cities`
--
DROP TABLE IF EXISTS `major_cities`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `major_cities` (
`country_code` varchar(2) NOT NULL,
`city` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `major_cities`
--
LOCK TABLES `major_cities` WRITE;
/*!40000 ALTER TABLE `major_cities` DISABLE KEYS */;
INSERT INTO `major_cities` VALUES ('IN','Delhi'),('IN','Mumbai'),('IN','Kolkata'),('IN','Chennai'),('PK','Islamabad'),('PK','Karachi'),('PK','Lahore'),('CN','Beijing'),('BT','Thimphu'),('US','Washington DC'),('US','Boston'),('US','New York'),('US','Baltimore'),('CA','Ottawa'),('CA','Toronto'),('AU','Canberra'),('AU','Sydney'),('AU','Melbourne'),('AU','Perth'),('AU','Brisbane'),('ES','Madrid'),('ES','Barcelona'),('ES','Valencia'),('IT','Rome'),('IT','Milan'),('IT','Venice'),('IT','Florence'),('DE','Berlin'),('DE','Munich'),('DE','Frankfurt'),('DE','Cologne'),('BR','Brasilia'),('UY','Montevideo'),('BR','Rio de Janeiro');
/*!40000 ALTER TABLE `major_cities` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `regions`
--
DROP TABLE IF EXISTS `regions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `regions` (
`region_id` int(11) NOT NULL,
`region_name` varchar(20) NOT NULL,
PRIMARY KEY (`region_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `regions`
--
LOCK TABLES `regions` WRITE;
/*!40000 ALTER TABLE `regions` DISABLE KEYS */;
INSERT INTO `regions` VALUES (1,'Asia'),(2,'Europe'),(3,'North America'),(4,'South America'),(5,'Australia');
/*!40000 ALTER TABLE `regions` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-04-16 4:07:26
| true |
dfbf10b881772dc5863ba20b06474ba7270f5d3e | SQL | Anijia/app-config | /mysql.sql | UTF-8 | 705 | 3.46875 | 3 | [] | no_license | CREATE DATABASE `app_config`;
use `app_config`;
CREATE TABLE `app` (
`id` VARCHAR(255) NOT NULL,
`name` VARCHAR(566) NOT NULL,
`platform` VARCHAR(255) NOT NULL,
`device` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `recommended_app` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`appId` VARCHAR(255) NOT NULL,
`displayName` VARCHAR(566) NOT NULL,
`lIconUrl` TEXT NOT NULL,
`hIconUrl` TEXT NOT NULL,
`downloadUrl` TEXT NOT NULL,
`_schema` VARCHAR(255),
INDEX(lIconUrl(500)),
INDEX(hIconUrl(500)),
FOREIGN KEY(appId) references app(id) on delete cascade on update cascade,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
| true |
bcf79ec392063ea6ef357a065f1012f333f44e64 | SQL | Hinsteny/short-url-service | /src/main/resources/liquibase/changelog.mysql.sql | UTF-8 | 906 | 3.4375 | 3 | [] | no_license | --liquibase formatted sql
--changeset short-url-service:1
CREATE TABLE `s_short_url` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`short_id` varchar(40) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '短链ID',
`source_url_hash` char(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '原始链接的MD5 HASH',
`source_url` varchar(500) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '跳转的原始链接',
`is_delete` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除(0否,1是)',
`gmt_modify` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_shortid` (`short_id`) USING BTREE,
KEY `idx_urlhash` (`source_url_hash`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='短链接数据表'; | true |
0130f950c6a5d051291ae88f5ecbe80554900aa9 | SQL | gn0mesort/forum-project | /sql/init.sql | UTF-8 | 3,976 | 4.625 | 5 | [] | no_license | create database if not exists forum;
use forum;
create table if not exists users(
user_id binary(16) not null default (UUID_TO_BIN(UUID())),
name varchar(64) not null,
password text not null,
join_date datetime not null default (CURRENT_TIMESTAMP),
avatar varchar(1024), -- 1024 is PATH_MAX?
primary key (user_id),
unique (name)
);
create table if not exists topics(
topic_id binary(16) not null default (UUID_TO_BIN(UUID())),
author_id binary(16) not null references users(user_id),
title varchar(256) not null,
creation_date datetime not null default (CURRENT_TIMESTAMP),
primary key (topic_id),
unique (title)
);
create table if not exists messages(
message_id binary(16) not null default (UUID_TO_BIN(UUID())),
topic_id binary(16) not null references topics(topic_id),
author_id binary(16) not null references users(user_id),
text text not null,
creation_date datetime not null default (CURRENT_TIMESTAMP),
primary key (message_id)
);
delimiter $$
drop procedure if exists register_user$$
create procedure register_user(input_name text, input_password text)
begin
insert into users (name, password) values (input_name, input_password);
select BIN_TO_UUID(user_id) from users where name = input_name;
end$$
drop procedure if exists fetch_login$$
create procedure fetch_login(input_name text)
begin
select BIN_TO_UUID(user_id), password from users where name = input_name;
end$$
drop procedure if exists create_topic$$
create procedure create_topic(input_title text, input_author text, input_message text)
begin
set @input_author_id = UUID_TO_BIN(input_author);
insert into topics (title, author_id) values (input_title, @input_author_id);
set @id = (select topic_id from topics where title = input_title);
insert into messages (topic_id, author_id, text) values (@id, @input_author_id, input_message);
select BIN_TO_UUID(@id);
end$$
drop procedure if exists create_message$$
create procedure create_message(input_topic text, input_author text, input_message text)
begin
set @input_topic_id = UUID_TO_BIN(input_topic);
set @input_author_id = UUID_TO_BIN(input_author);
insert into messages (topic_id, author_id, text) values (@input_topic_id, @input_author_id, input_message);
select BIN_TO_UUID(message_id) from messages where topic_id = @input_topic_id and author_id = @input_author_id order by creation_date;
end$$
drop procedure if exists get_topics$$
create procedure get_topics()
begin
select BIN_TO_UUID(topics.topic_id), BIN_TO_UUID(topics.author_id), topics.title, users.name as author, topics.creation_date
from topics
inner join users on (topics.author_id = users.user_id)
order by topics.creation_date desc;
end$$
drop procedure if exists get_topic$$
create procedure get_topic(input_topic text)
begin
set @input_topic_id = UUID_TO_BIN(input_topic);
select BIN_TO_UUID(topics.author_id), topics.title, users.name as author, topics.creation_date
from topics
inner join users on (topics.author_id = users.user_id)
where topics.topic_id = @input_topic_id;
end$$
drop procedure if exists get_messages$$
create procedure get_messages(input_topic text)
begin
set @input_topic_id = UUID_TO_BIN(input_topic);
select BIN_TO_UUID(messages.message_id), BIN_TO_UUID(messages.author_id), users.name as author, messages.text, messages.creation_date
from messages
inner join users on (messages.author_id = users.user_id)
where messages.topic_id = @input_topic_id
order by messages.creation_date;
end$$
drop procedure if exists get_user$$
create procedure get_user(input_user text)
begin
set @input_user_id = UUID_TO_BIN(input_user);
select user_id, name, join_date, avatar from users where user_id = @input_user_id;
end$$
drop procedure if exists get_post_count$$
create procedure get_post_count(input_user text)
begin
set @input_user_id = UUID_TO_BIN(input_user);
set @result = (select count(*) from messages where author_id = @input_user_id);
select @result;
end$$
delimiter ;
| true |
4051c6eb452e44c61d047d492b648abf2d2989a8 | SQL | mauricejenkins-00/TeamSpark | /shark_queries.sql | UTF-8 | 1,385 | 4.15625 | 4 | [] | no_license | --Dropping shark_attack table if it already exists
DROP TABLE shark_attacks
--Creates shark_attacks table
CREATE TABLE shark_attacks (
case_num varchar(100),
attack_date varchar(65),
attack_year decimal,
attack_type varchar(100),
attack_country varchar(100),
attack_state varchar(100),
attack_location varchar(100),
activity varchar(100)
)
--Showing shark_attacks table
select * from shark_attacks
--Creating a new table containing values from the original table
create table occurence_table
as
select attack_state, count (attack_state) as occurences
from shark_attacks
group by attack_state
--Showing occurence table
select * from occurence_table
--Dropping ice_cream table if it already exists
DROP TABLE ice_cream
CREATE TABLE ice_cream (
attack_location varchar(100),
number_of_attacks int,
latitude decimal,
longitude decimal,
ice_cream int,
temperature decimal
)
select * from ice_cream
DROP TABLE ice_cream_shark_attack
create table ice_cream_shark_attack
as
SELECT shark_attacks.attack_date, shark_attacks.attack_year, shark_attacks.attack_type, shark_attacks.attack_state, shark_attacks.attack_location, shark_attacks.activity, ice_cream.number_of_attacks, ice_cream.latitude, ice_cream.longitude, ice_cream.ice_cream, ice_cream.temperature
FROM shark_attacks
LEFT JOIN ice_cream ON
shark_attacks.attack_location = ice_cream.attack_location;
| true |
0e95253d3c22f9987e9ce7532cdae10e89eb4bb9 | SQL | pcamposaugusto/CTD-2021-Bimestre1 | /CTD-BancoDeDados/Ex-Aula13-Endpoints.sql | UTF-8 | 3,580 | 4.375 | 4 | [] | no_license | USE musimundos_V2;
-- 1. Listar todos os nomes de todos artistas ordenados de forma crescente
SELECT nome FROM artistas
ORDER BY nome;
-- 2. Quais são os generos musicais existentes?
SELECT nome FROM generos;
-- 3. Mostre todos os compositores que criaram alguma cancao;
SELECT DISTINCT(compositor) FROM cancoes
WHERE compositor != ""
ORDER BY compositor;
-- 4. Mostre a lista dos empregados que foram contratados a partir de 2005
SELECT nome, sobrenome, data_contratacao FROM empregados
WHERE YEAR (data_contratacao) >= "2005";
-- 5. Liste todos os paises que têm faturas com valor superior a 1.000
SELECT DISTINCT(pais_cobranca), valor_total FROM faturas
WHERE valor_total > 1;
SELECT pais_cobranca, SUM(valor_total) AS soma_faturas
FROM faturas
GROUP BY pais_cobranca;
-- 6. Quantas cancoes foram compostas por AC/DC ?
SELECT COUNT(nome) FROM cancoes
WHERE compositor LIKE "AC/DC";
-- 7. Mostre as 10 primeiras cidades que tem faturas com valor superior a 100 reias.
SELECT cidade_cobranca FROM faturas
WHERE valor_total > 1
LIMIT 10;
-- Exercícios Aula 13 - Endpoints
-- 1. Na tabela clientes selecione os campos nome e sobrenome e concatene(função concat) eles para que formem o nome completo do cliente. Relacione cada cliente com a cidade de cobrança que consta na tabela faturas. Precisamos apenas uma ocorrência distinta de cada cliente.
SELECT DISTINCT CONCAT(c.nome, " ", c.sobrenome) AS nome_completo, f.cidade_cobranca
FROM clientes c
INNER JOIN faturas f
ON c.id = f.id_cliente;
-- 2. Na tabela cancoes selecione o nome da canção e relacionado com a tabela tipos_de_arquivos, selecione também o nome do tipo do arquivo. Inclua na sua seleção também as canções que não tem tipo de arquivo. Ordene pelo id da canção de forma decrescente limitado a 4000 registros.
SELECT t.nome AS nome_arquivo, c.nome AS nome_cancoes
FROM tipos_de_arquivo t
RIGHT JOIN cancoes c
ON t.id = c.id_tipo_de_arquivo
ORDER BY c.id DESC
LIMIT 4000;
-- 3. Em nosso banco de dados, cada fatura é composta por várias músicas adquiridas pelos clientes. Selecione da tabela faturas o id do cliente e a data da fatura. Usando também a tabela intermediária itens_da_faturas selecione também o nome de cada musica adquirida ou seja, na tabela canções o campo nome. Ordene tudo pelo id do cliente de forma decrescente.
SELECT f.id_cliente, f.data_fatura, c.nome AS nome_cancao
FROM faturas f
INNER JOIN itens_da_faturas it ON f.id = it.id_fatura
INNER JOIN cancoes c ON it.id_cancao = c.id
ORDER BY f.id_cliente DESC;
-- 4. Um artista tem albuns, que por sua vez tem cancões. Selecione o nome do artista da tabela artistas, selecione os nomes dos albuns deste artista (tabela intermediária albuns) e também o nome das canções deste artista contidas nos albuns (tabela cancoes). Ordene os resultados pelo nome do artista de forma decrescente.
SELECT art.nome AS artista, alb.titulo AS titulo_album, c.nome AS nome_cancao
FROM artistas art
INNER JOIN albuns alb ON art.id = alb.id_artista
INNER JOIN cancoes c ON alb.id = c.id_album
ORDER BY artista DESC;
-- 5. Selecione o nome dos gêneros(table generos), o nome das canções deste gênero (table cancoes) e o tipo de arquivo de cada canção (tipos_de_arquivo). Selecione inclusive as musicas que o tipo de arquivo é nulo. Ordene tudo isso pelo nome do gênero de forma decrescente.
SELECT g.nome AS genero, c.nome AS cancao, t.nome AS tipo_de_arquivo
FROM generos g
INNER JOIN cancoes c ON g.id = c.id_genero
LEFT JOIN tipos_de_arquivo t ON c.id_tipo_de_arquivo = t.id
ORDER BY genero DESC;
| true |
ba66ccf44a8828b03bda520c7aa1a65a05297661 | SQL | dpitkevics/MD-labosanas-sistema | /sql-history/md-009(clean).sql | UTF-8 | 7,174 | 3.359375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.0.0-rc4
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: May 28, 2013 at 05:19 PM
-- Server version: 5.6.11
-- PHP Version: 5.4.14
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Database: `md`
--
-- --------------------------------------------------------
--
-- Table structure for table `criterias`
--
DROP TABLE IF EXISTS `criterias`;
CREATE TABLE IF NOT EXISTS `criterias` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`public_name` varchar(256) NOT NULL,
`weight` float NOT NULL,
`type` int(1) NOT NULL,
`criteria_sentence` blob NOT NULL,
`timestamp` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
-- --------------------------------------------------------
--
-- Table structure for table `criteria_types`
--
DROP TABLE IF EXISTS `criteria_types`;
CREATE TABLE IF NOT EXISTS `criteria_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`criterion_type` int(1) NOT NULL,
`type_name` varchar(128) NOT NULL,
`timestamp` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `criterion_type` (`criterion_type`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `criteria_types`
--
INSERT INTO `criteria_types` (`id`, `criterion_type`, `type_name`, `timestamp`) VALUES
(1, 1, 'Basic Function', 1369471458),
(2, 2, 'Validation through Validator', 1369471458),
(3, 3, 'User defined Javascript validation', 1369471458),
(4, 4, 'User defined validation class', 1369471458);
-- --------------------------------------------------------
--
-- Table structure for table `hometasks`
--
DROP TABLE IF EXISTS `hometasks`;
CREATE TABLE IF NOT EXISTS `hometasks` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Mājas darba ID',
`zipID` int(11) NOT NULL COMMENT 'ID iegūts no paša zip faila',
`title` varchar(128) NOT NULL COMMENT 'Mājas darba nosaukums',
`isImported` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Vai zip faili ir ieimportēti vai nav.',
`indexFile` varchar(128) NOT NULL,
`term` int(11) NOT NULL COMMENT 'Izpildes termiņš',
`timestamp` int(11) NOT NULL COMMENT 'Kad darbs izveidots',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Satur vispārīgus datus par mājas darbiem' AUTO_INCREMENT=13 ;
-- --------------------------------------------------------
--
-- Table structure for table `hometask_criterias`
--
DROP TABLE IF EXISTS `hometask_criterias`;
CREATE TABLE IF NOT EXISTS `hometask_criterias` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`hometask_id` int(11) NOT NULL,
`criteria_id` int(11) NOT NULL,
`timestamp` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `hometask_id` (`hometask_id`),
KEY `criteria_id` (`criteria_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
-- --------------------------------------------------------
--
-- Table structure for table `received_homeworks`
--
DROP TABLE IF EXISTS `received_homeworks`;
CREATE TABLE IF NOT EXISTS `received_homeworks` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Ieraksta ID',
`homestaskID` int(11) NOT NULL COMMENT 'Mājas darba ID',
`studentIDNumber` varchar(10) NOT NULL COMMENT 'Studenta ID',
`sourcePath` varchar(128) NOT NULL COMMENT 'Fiziskā koda atrašanās vieta',
`timestamp` int(11) NOT NULL COMMENT 'Kad ieraksts veikts',
PRIMARY KEY (`id`),
KEY `homestaskID` (`homestaskID`,`studentIDNumber`),
KEY `studentID` (`studentIDNumber`),
KEY `studentIDNumber` (`studentIDNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Satur datus par iesūtītajiem mājas darbiem' AUTO_INCREMENT=94 ;
-- --------------------------------------------------------
--
-- Table structure for table `received_homework_grades`
--
DROP TABLE IF EXISTS `received_homework_grades`;
CREATE TABLE IF NOT EXISTS `received_homework_grades` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`received_homework_id` int(11) NOT NULL,
`grade` int(1) NOT NULL,
`timestamp` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `received_homework_id` (`received_homework_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
-- --------------------------------------------------------
--
-- Table structure for table `students`
--
DROP TABLE IF EXISTS `students`;
CREATE TABLE IF NOT EXISTS `students` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Ieraksta ID',
`name` varchar(128) NOT NULL COMMENT 'Studenta vārds',
`surname` varchar(128) NOT NULL COMMENT 'Studenta uzvārds',
`studentIDNumber` varchar(10) NOT NULL COMMENT 'Studenta apliecības numurs',
`timestamp` int(11) NOT NULL COMMENT 'Timestamp, kad ieraksts veikts',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Satur vispārīgus datus par studentiem' AUTO_INCREMENT=94 ;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(128) NOT NULL,
`password` varchar(128) NOT NULL,
`verifyPassword` varchar(128) NOT NULL,
`name` varchar(32) NOT NULL,
`lastname` varchar(64) NOT NULL,
`email` varchar(128) NOT NULL,
`timestamp` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
-- --------------------------------------------------------
--
-- Table structure for table `user_hometasks`
--
DROP TABLE IF EXISTS `user_hometasks`;
CREATE TABLE IF NOT EXISTS `user_hometasks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`hometask_id` int(11) NOT NULL,
`timestamp` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`,`hometask_id`),
KEY `hometask_id` (`hometask_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `criterias`
--
ALTER TABLE `criterias`
ADD CONSTRAINT `criterias_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
ADD CONSTRAINT `criterias_ibfk_2` FOREIGN KEY (`type`) REFERENCES `criteria_types` (`criterion_type`);
--
-- Constraints for table `hometask_criterias`
--
ALTER TABLE `hometask_criterias`
ADD CONSTRAINT `hometask_criterias_ibfk_1` FOREIGN KEY (`hometask_id`) REFERENCES `hometasks` (`id`),
ADD CONSTRAINT `hometask_criterias_ibfk_2` FOREIGN KEY (`criteria_id`) REFERENCES `criterias` (`id`);
--
-- Constraints for table `received_homeworks`
--
ALTER TABLE `received_homeworks`
ADD CONSTRAINT `received_homeworks_ibfk_1` FOREIGN KEY (`homestaskID`) REFERENCES `hometasks` (`id`);
--
-- Constraints for table `received_homework_grades`
--
ALTER TABLE `received_homework_grades`
ADD CONSTRAINT `received_homework_grades_ibfk_1` FOREIGN KEY (`received_homework_id`) REFERENCES `received_homeworks` (`id`);
--
-- Constraints for table `user_hometasks`
--
ALTER TABLE `user_hometasks`
ADD CONSTRAINT `user_hometasks_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
ADD CONSTRAINT `user_hometasks_ibfk_2` FOREIGN KEY (`hometask_id`) REFERENCES `hometasks` (`id`);
| true |
88f27e67e3b824a47e4f59eecbb9043add5607a2 | SQL | sasor/db2_project_scp | /database/hospital_model.sql | UTF-8 | 1,826 | 2.90625 | 3 | [] | no_license | CREATE TABLE Persona(
ci integer NOT null,
nombre text,
apelloPaterno text,
apellidoMaterno text,
tipoSangre varchar(4),
sexo char,
telefomo integer,
direccion text,
);
CREATE TABLE Doctor(
ci integer NOT null,
nombre text,
apellidoPaterno text,
apellidoMaterno text,
sexo char,
telefono integer,
direccion text,
especialidad text,
),
CREATE TABLE Enfermero(
ci integer NOT null,
nombre text,
apellidoPaterno text,
apellidoMaterno text,
sexo char,
telefono integer,
direccion text,
);
CREATE TABLE Laboratorista(
ci integer NOT null,
nombre text,
apellidoPaterno text,
apelidoMaterno text,
telefono integer,
direccion text,
);
CREATE TABLE Cama(
id integer NOT null,
numero interger,
ocupado boolean,
);
CREATE TABLE Medicamento(
id integer NOT null,
nombre text,
dtosificaion text,
);
CREATE TABLE Laborartorio(
nit integer NOT null,
nombre text,
telefono integer,
direccion text,
);
CREATE TABLE tipoExamen(
id integer NOT null,
nombre text,
precio float,
);
CREATE TABLE Receta(
id int4 NOT null,
cantidad int4;
);
CREATE TABLE CitaMedica(
id integer NOT null,
fecha timestamp,
hora time,
disponible char,
);
CREATE TABLE Consulta(
id integer NOT null,
fecha timestamp,
hora time,
sintoma text,t
);
CREATE TABLE DetalleConsulta(
id integer NOT null,
estado text,
diagnostico text,
Orden text,
);
CREATE TABLE DetalleLaboratorio(
id integer NOT null,
fecha timestamp,
hora time,
detalle text,
);
CREATE TABLE Internacion(
id integer internacion NOT null,
alta char,
fechaIngreso timestamp,
);
CREATE TABLE Analisis(
id integer NOT null,
fecha timestamp,
);
| true |
27abc65d593b1fe7049d6e347246f27fca9be472 | SQL | proshantokuet/bahmni-config | /openmrs/apps/reports/sql/labReport.sql | UTF-8 | 950 | 3.78125 | 4 | [] | no_license |
select pi.identifier as Patient_id,
pn.given_name, pn.family_name Patient_name,
cv.concept_full_name as Test_Name,
o.obs_datetime as Test_Date,
concat(coalesce(o.value_text,''),coalesce(o.value_numeric,''),coalesce(cv2.concept_full_name,'')) as Test_Result
from obs o
inner join concept_view cv on cv.concept_id = o.concept_id and cv.concept_class_name='LabTest'
and o.voided =0 and cast(o.obs_datetime as DATE) between '#startDate#' and '#endDate#'
and concat(coalesce(o.value_text,''),coalesce(o.value_numeric,''),coalesce(o.value_coded,'')) != ''
inner join person p on p.person_id = o.person_id
inner join person_name pn on pn.person_id = o.person_id
inner join patient_identifier pi on pi.patient_id = o.person_id and pi.preferred = 1
left join concept_view cv2 on cv2.concept_id = o.value_coded
group by Patient_Id,Test_Name,Test_Result
order by Test_Date;
| true |
a0a198d301fd58cff5fffc66430525897e1cff28 | SQL | BielinskiLukasz/sqlTasks | /SBD/c01/lab/create.sql | UTF-8 | 3,091 | 3.59375 | 4 | [] | no_license | -- Created by Vertabelo (http://vertabelo.com)
-- Last modification date: 2019-03-17 13:20:29.768
-- tables
-- Table: Pierwiastek
CREATE TABLE Pierwiastek (
IdPierwiastek integer NOT NULL,
Nazwa varchar2(30) NOT NULL,
Symbol varchar2(3) NOT NULL,
Opis varchar2(500) NOT NULL,
Ilosc number(7,2) NOT NULL,
CONSTRAINT Pierwiastek_pk PRIMARY KEY (IdPierwiastek)
) ;
-- Table: Reakcja
CREATE TABLE Reakcja (
IdReakcja integer NOT NULL,
Nazwa varchar2(200) NOT NULL,
Data date NOT NULL,
CONSTRAINT Reakcja_pk PRIMARY KEY (IdReakcja)
) ;
-- Table: Reakcja_Pierwiastek
CREATE TABLE Reakcja_Pierwiastek (
IdReakcjaPierwiastek integer NOT NULL,
Ilosc number(7,2) NOT NULL,
IdPierwiastek integer NOT NULL,
IdReakcja integer NOT NULL,
SkladnikDictKey varchar2(2) NOT NULL,
CONSTRAINT Reakcja_Pierwiastek_pk PRIMARY KEY (IdReakcjaPierwiastek)
) ;
-- Table: Reakcja_ZwiazekChemiczny
CREATE TABLE Reakcja_ZwiazekChemiczny (
IdReakcjaZwiazekChemiczny integer NOT NULL,
Ilosc number(7,2) NOT NULL,
IdZwiazekChemiczny integer NOT NULL,
IdReakcja integer NOT NULL,
SkladnikDictKey varchar2(2) NOT NULL,
CONSTRAINT Reakcja_ZwiazekChemiczny_pk PRIMARY KEY (IdReakcjaZwiazekChemiczny)
) ;
-- Table: SkladnikDict
CREATE TABLE SkladnikDict (
Key varchar2(2) NOT NULL,
Value varchar2(20) NOT NULL,
CONSTRAINT SkladnikDict_pk PRIMARY KEY (Key)
) ;
-- Table: ZwiazekChemiczny
CREATE TABLE ZwiazekChemiczny (
IdZwiazekChemiczny integer NOT NULL,
Nazwa varchar2(200) NOT NULL,
Symbol varchar2(20) NOT NULL,
Opis varchar2(500) NOT NULL,
Ilosc number(7,2) NOT NULL,
CONSTRAINT ZwiazekChemiczny_pk PRIMARY KEY (IdZwiazekChemiczny)
) ;
-- foreign keys
-- Reference: Pierwiastek_Reakcja (table: Reakcja_Pierwiastek)
ALTER TABLE Reakcja_Pierwiastek ADD CONSTRAINT Pierwiastek_Reakcja
FOREIGN KEY (IdReakcja)
REFERENCES Reakcja (IdReakcja);
-- Reference: Pierwiastek_SkladnikDict (table: Reakcja_Pierwiastek)
ALTER TABLE Reakcja_Pierwiastek ADD CONSTRAINT Pierwiastek_SkladnikDict
FOREIGN KEY (SkladnikDictKey)
REFERENCES SkladnikDict (Key);
-- Reference: Reakcja_Pierwiastek (table: Reakcja_Pierwiastek)
ALTER TABLE Reakcja_Pierwiastek ADD CONSTRAINT Reakcja_Pierwiastek
FOREIGN KEY (IdPierwiastek)
REFERENCES Pierwiastek (IdPierwiastek);
-- Reference: Reakcja_ZwiazekChemiczny (table: Reakcja_ZwiazekChemiczny)
ALTER TABLE Reakcja_ZwiazekChemiczny ADD CONSTRAINT Reakcja_ZwiazekChemiczny
FOREIGN KEY (IdZwiazekChemiczny)
REFERENCES ZwiazekChemiczny (IdZwiazekChemiczny);
-- Reference: ZwiazekChemiczny_Reakcja (table: Reakcja_ZwiazekChemiczny)
ALTER TABLE Reakcja_ZwiazekChemiczny ADD CONSTRAINT ZwiazekChemiczny_Reakcja
FOREIGN KEY (IdReakcja)
REFERENCES Reakcja (IdReakcja);
-- Reference: ZwiazekChemiczny_SkladnikDict (table: Reakcja_ZwiazekChemiczny)
ALTER TABLE Reakcja_ZwiazekChemiczny ADD CONSTRAINT ZwiazekChemiczny_SkladnikDict
FOREIGN KEY (SkladnikDictKey)
REFERENCES SkladnikDict (Key);
-- End of file.
| true |
9c4d3d328df9eea9c707f2860765f6471ab031a8 | SQL | zaucker/agrammon | /db/schema.sql | UTF-8 | 19,569 | 3.734375 | 4 | [] | no_license | --
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
CREATE EXTENSION IF NOT EXISTS pgcrypto;
--
-- Name: dataset_name2id(text, text); Type: FUNCTION; Schema: public; Owner: agrammon
--
CREATE FUNCTION public.dataset_name2id(username text, name text) RETURNS integer
LANGUAGE sql IMMUTABLE
AS $_$SELECT dataset_id FROM dataset WHERE dataset_name = $2 AND dataset_pers = pers_email2id($1)$_$;
ALTER FUNCTION public.dataset_name2id(username text, name text) OWNER TO agrammon;
--
-- Name: pers_email2id(text); Type: FUNCTION; Schema: public; Owner: agrammon
--
CREATE FUNCTION public.pers_email2id(name text) RETURNS integer
LANGUAGE sql IMMUTABLE
AS $_$SELECT pers_id FROM pers WHERE pers_email = $1 $_$;
ALTER FUNCTION public.pers_email2id(name text) OWNER TO agrammon;
--
-- Name: tag_name2id(text, text); Type: FUNCTION; Schema: public; Owner: agrammon
--
CREATE FUNCTION public.tag_name2id(username text, name text) RETURNS integer
LANGUAGE sql STABLE
AS $_$SELECT tag_id FROM tag WHERE tag_name = $2 AND tag_pers = pers_email2id($1)$_$;
ALTER FUNCTION public.tag_name2id(username text, name text) OWNER TO agrammon;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: data_new; Type: TABLE; Schema: public; Owner: agrammon
--
CREATE TABLE public.data_new (
data_id integer NOT NULL,
data_dataset integer NOT NULL,
data_var text NOT NULL,
data_instance text,
data_val text,
data_instance_order integer,
data_comment text
);
ALTER TABLE public.data_new OWNER TO agrammon;
--
-- Name: dataset; Type: TABLE; Schema: public; Owner: agrammon
--
CREATE TABLE public.dataset (
dataset_id integer NOT NULL,
dataset_name text NOT NULL,
dataset_pers integer NOT NULL,
dataset_mod_date timestamp without time zone DEFAULT now(),
dataset_version text DEFAULT '2.0'::text,
dataset_comment text,
dataset_model text,
dataset_readonly boolean DEFAULT false,
CONSTRAINT dataset_name_empty CHECK ((dataset_name !~ '^\s*$'::text))
);
ALTER TABLE public.dataset OWNER TO agrammon;
--
-- Name: pers; Type: TABLE; Schema: public; Owner: agrammon
--
CREATE TABLE public.pers (
pers_id integer NOT NULL,
pers_email text NOT NULL,
pers_first text,
pers_last text,
pers_password text NOT NULL,
pers_org text,
pers_last_login timestamp without time zone,
pers_created timestamp without time zone DEFAULT now(),
pers_role integer DEFAULT 1 NOT NULL
);
ALTER TABLE public.pers OWNER TO agrammon;
--
-- Name: all_data; Type: VIEW; Schema: public; Owner: agrammon
--
CREATE VIEW public.all_data AS
SELECT pers.pers_email,
dataset.dataset_name,
data_new.data_var,
data_new.data_val
FROM ((public.pers
JOIN public.dataset ON ((dataset.dataset_pers = pers.pers_id)))
JOIN public.data_new ON ((data_new.data_dataset = dataset.dataset_id)))
ORDER BY pers.pers_email, dataset.dataset_name, data_new.data_var;
ALTER TABLE public.all_data OWNER TO agrammon;
--
-- Name: all_datasets; Type: VIEW; Schema: public; Owner: agrammon
--
CREATE VIEW public.all_datasets AS
SELECT pers.pers_email,
dataset.dataset_id,
dataset.dataset_name,
dataset.dataset_mod_date,
dataset.dataset_version
FROM (public.pers
JOIN public.dataset ON ((dataset.dataset_pers = pers.pers_id)))
ORDER BY pers.pers_email, dataset.dataset_name;
ALTER TABLE public.all_datasets OWNER TO agrammon;
--
-- Name: branches; Type: TABLE; Schema: public; Owner: agrammon
--
CREATE TABLE public.branches (
branches_id integer NOT NULL,
branches_var integer NOT NULL,
branches_data numeric[],
branches_options text[]
);
ALTER TABLE public.branches OWNER TO agrammon;
--
-- Name: branches_branches_id_seq; Type: SEQUENCE; Schema: public; Owner: agrammon
--
CREATE SEQUENCE public.branches_branches_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.branches_branches_id_seq OWNER TO agrammon;
--
-- Name: branches_branches_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: agrammon
--
ALTER SEQUENCE public.branches_branches_id_seq OWNED BY public.branches.branches_id;
--
-- Name: data_new_data_id_seq; Type: SEQUENCE; Schema: public; Owner: agrammon
--
CREATE SEQUENCE public.data_new_data_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.data_new_data_id_seq OWNER TO agrammon;
--
-- Name: data_new_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: agrammon
--
ALTER SEQUENCE public.data_new_data_id_seq OWNED BY public.data_new.data_id;
--
-- Name: data_view; Type: VIEW; Schema: public; Owner: agrammon
--
CREATE VIEW public.data_view AS
SELECT data.data_id,
data.data_dataset,
COALESCE(replace(data.data_var, '[]'::text, (('['::text || data.data_instance) || ']'::text)), data.data_var) AS data_var,
data.data_val,
data.data_instance_order,
data.data_comment
FROM public.data_new data
ORDER BY data.data_dataset, COALESCE(replace(data.data_var, '[]'::text, (('['::text || data.data_instance) || ']'::text)), data.data_var);
ALTER TABLE public.data_view OWNER TO agrammon;
--
-- Name: dataset_dataset_id_seq; Type: SEQUENCE; Schema: public; Owner: agrammon
--
CREATE SEQUENCE public.dataset_dataset_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.dataset_dataset_id_seq OWNER TO agrammon;
--
-- Name: dataset_dataset_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: agrammon
--
ALTER SEQUENCE public.dataset_dataset_id_seq OWNED BY public.dataset.dataset_id;
--
-- Name: news; Type: TABLE; Schema: public; Owner: agrammon
--
CREATE TABLE public.news (
news_id integer NOT NULL,
news_newsty integer NOT NULL,
news_date date DEFAULT now(),
news_text text
);
ALTER TABLE public.news OWNER TO agrammon;
--
-- Name: news_news_id_seq; Type: SEQUENCE; Schema: public; Owner: agrammon
--
CREATE SEQUENCE public.news_news_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.news_news_id_seq OWNER TO agrammon;
--
-- Name: news_news_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: agrammon
--
ALTER SEQUENCE public.news_news_id_seq OWNED BY public.news.news_id;
--
-- Name: newsty; Type: TABLE; Schema: public; Owner: agrammon
--
CREATE TABLE public.newsty (
newsty_id integer NOT NULL,
newsty_name text
);
ALTER TABLE public.newsty OWNER TO agrammon;
--
-- Name: newsty_newsty_id_seq; Type: SEQUENCE; Schema: public; Owner: agrammon
--
CREATE SEQUENCE public.newsty_newsty_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.newsty_newsty_id_seq OWNER TO agrammon;
--
-- Name: newsty_newsty_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: agrammon
--
ALTER SEQUENCE public.newsty_newsty_id_seq OWNED BY public.newsty.newsty_id;
--
-- Name: pers_pers_id_seq; Type: SEQUENCE; Schema: public; Owner: agrammon
--
CREATE SEQUENCE public.pers_pers_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.pers_pers_id_seq OWNER TO agrammon;
--
-- Name: pers_pers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: agrammon
--
ALTER SEQUENCE public.pers_pers_id_seq OWNED BY public.pers.pers_id;
--
-- Name: role; Type: TABLE; Schema: public; Owner: agrammon
--
CREATE TABLE public.role (
role_id integer NOT NULL,
role_name text NOT NULL
);
ALTER TABLE public.role OWNER TO agrammon;
--
-- Name: role_role_id_seq; Type: SEQUENCE; Schema: public; Owner: agrammon
--
CREATE SEQUENCE public.role_role_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.role_role_id_seq OWNER TO agrammon;
--
-- Name: role_role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: agrammon
--
ALTER SEQUENCE public.role_role_id_seq OWNED BY public.role.role_id;
--
-- Name: tag; Type: TABLE; Schema: public; Owner: agrammon
--
CREATE TABLE public.tag (
tag_id integer NOT NULL,
tag_name text NOT NULL,
tag_pers integer NOT NULL
);
ALTER TABLE public.tag OWNER TO agrammon;
--
-- Name: tag_tag_id_seq; Type: SEQUENCE; Schema: public; Owner: agrammon
--
CREATE SEQUENCE public.tag_tag_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.tag_tag_id_seq OWNER TO agrammon;
--
-- Name: tag_tag_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: agrammon
--
ALTER SEQUENCE public.tag_tag_id_seq OWNED BY public.tag.tag_id;
--
-- Name: tagds; Type: TABLE; Schema: public; Owner: agrammon
--
CREATE TABLE public.tagds (
tagds_id integer NOT NULL,
tagds_tag integer NOT NULL,
tagds_dataset integer NOT NULL
);
ALTER TABLE public.tagds OWNER TO agrammon;
--
-- Name: tagds_tagds_id_seq; Type: SEQUENCE; Schema: public; Owner: agrammon
--
CREATE SEQUENCE public.tagds_tagds_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.tagds_tagds_id_seq OWNER TO agrammon;
--
-- Name: tagds_tagds_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: agrammon
--
ALTER SEQUENCE public.tagds_tagds_id_seq OWNED BY public.tagds.tagds_id;
--
-- Name: branches branches_id; Type: DEFAULT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.branches ALTER COLUMN branches_id SET DEFAULT nextval('public.branches_branches_id_seq'::regclass);
--
-- Name: data_new data_id; Type: DEFAULT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.data_new ALTER COLUMN data_id SET DEFAULT nextval('public.data_new_data_id_seq'::regclass);
--
-- Name: dataset dataset_id; Type: DEFAULT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.dataset ALTER COLUMN dataset_id SET DEFAULT nextval('public.dataset_dataset_id_seq'::regclass);
--
-- Name: news news_id; Type: DEFAULT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.news ALTER COLUMN news_id SET DEFAULT nextval('public.news_news_id_seq'::regclass);
--
-- Name: newsty newsty_id; Type: DEFAULT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.newsty ALTER COLUMN newsty_id SET DEFAULT nextval('public.newsty_newsty_id_seq'::regclass);
--
-- Name: pers pers_id; Type: DEFAULT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.pers ALTER COLUMN pers_id SET DEFAULT nextval('public.pers_pers_id_seq'::regclass);
--
-- Name: role role_id; Type: DEFAULT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.role ALTER COLUMN role_id SET DEFAULT nextval('public.role_role_id_seq'::regclass);
--
-- Name: tag tag_id; Type: DEFAULT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.tag ALTER COLUMN tag_id SET DEFAULT nextval('public.tag_tag_id_seq'::regclass);
--
-- Name: tagds tagds_id; Type: DEFAULT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.tagds ALTER COLUMN tagds_id SET DEFAULT nextval('public.tagds_tagds_id_seq'::regclass);
--
-- Name: branches branches_branches_var_key; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.branches
ADD CONSTRAINT branches_branches_var_key UNIQUE (branches_var);
--
-- Name: branches branches_pkey; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.branches
ADD CONSTRAINT branches_pkey PRIMARY KEY (branches_id);
--
-- Name: data_new data_new_data_var_key; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.data_new
ADD CONSTRAINT data_new_data_var_key UNIQUE (data_var, data_instance, data_dataset);
--
-- Name: data_new data_new_pkey; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.data_new
ADD CONSTRAINT data_new_pkey PRIMARY KEY (data_id);
--
-- Name: dataset dataset_dataset_name_key; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.dataset
ADD CONSTRAINT dataset_dataset_name_key UNIQUE (dataset_name, dataset_pers, dataset_model);
--
-- Name: dataset dataset_pkey; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.dataset
ADD CONSTRAINT dataset_pkey PRIMARY KEY (dataset_id);
--
-- Name: news news_pkey; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.news
ADD CONSTRAINT news_pkey PRIMARY KEY (news_id);
--
-- Name: newsty newsty_pkey; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.newsty
ADD CONSTRAINT newsty_pkey PRIMARY KEY (newsty_id);
--
-- Name: pers pers_pers_email_key; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.pers
ADD CONSTRAINT pers_pers_email_key UNIQUE (pers_email);
--
-- Name: pers pers_pkey; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.pers
ADD CONSTRAINT pers_pkey PRIMARY KEY (pers_id);
--
-- Name: role role_pkey; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.role
ADD CONSTRAINT role_pkey PRIMARY KEY (role_id);
--
-- Name: tag tag_pkey; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.tag
ADD CONSTRAINT tag_pkey PRIMARY KEY (tag_id);
--
-- Name: tag tag_tag_name_key; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.tag
ADD CONSTRAINT tag_tag_name_key UNIQUE (tag_name, tag_pers);
--
-- Name: tagds tagds_pkey; Type: CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.tagds
ADD CONSTRAINT tagds_pkey PRIMARY KEY (tagds_id);
--
-- Name: data_new_data_dataset; Type: INDEX; Schema: public; Owner: agrammon
--
CREATE INDEX data_new_data_dataset ON public.data_new USING btree (data_dataset);
--
-- Name: data_new_data_id_data_dataset; Type: INDEX; Schema: public; Owner: agrammon
--
CREATE INDEX data_new_data_id_data_dataset ON public.data_new USING btree (data_id, data_dataset);
--
-- Name: dataset_dataset_pers; Type: INDEX; Schema: public; Owner: agrammon
--
CREATE INDEX dataset_dataset_pers ON public.dataset USING btree (dataset_pers);
--
-- Name: tagds_tagds_dataset; Type: INDEX; Schema: public; Owner: agrammon
--
CREATE INDEX tagds_tagds_dataset ON public.tagds USING btree (tagds_dataset);
--
-- Name: branches branches_branches_var_fkey; Type: FK CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.branches
ADD CONSTRAINT branches_branches_var_fkey FOREIGN KEY (branches_var) REFERENCES public.data_new(data_id) ON DELETE CASCADE;
--
-- Name: data_new data_new_data_dataset_fkey; Type: FK CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.data_new
ADD CONSTRAINT data_new_data_dataset_fkey FOREIGN KEY (data_dataset) REFERENCES public.dataset(dataset_id) ON DELETE CASCADE;
--
-- Name: dataset dataset_dataset_pers_fkey; Type: FK CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.dataset
ADD CONSTRAINT dataset_dataset_pers_fkey FOREIGN KEY (dataset_pers) REFERENCES public.pers(pers_id);
--
-- Name: news news_news_newsty_fkey; Type: FK CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.news
ADD CONSTRAINT news_news_newsty_fkey FOREIGN KEY (news_newsty) REFERENCES public.newsty(newsty_id);
--
-- Name: pers pers_pers_role_fkey; Type: FK CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.pers
ADD CONSTRAINT pers_pers_role_fkey FOREIGN KEY (pers_role) REFERENCES public.role(role_id);
--
-- Name: tag tag_tag_pers_fkey; Type: FK CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.tag
ADD CONSTRAINT tag_tag_pers_fkey FOREIGN KEY (tag_pers) REFERENCES public.pers(pers_id);
--
-- Name: tagds tagds_tagds_dataset_fkey; Type: FK CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.tagds
ADD CONSTRAINT tagds_tagds_dataset_fkey FOREIGN KEY (tagds_dataset) REFERENCES public.dataset(dataset_id) ON DELETE CASCADE;
--
-- Name: tagds tagds_tagds_tag_fkey; Type: FK CONSTRAINT; Schema: public; Owner: agrammon
--
ALTER TABLE ONLY public.tagds
ADD CONSTRAINT tagds_tagds_tag_fkey FOREIGN KEY (tagds_tag) REFERENCES public.tag(tag_id) ON DELETE CASCADE;
--
-- Name: data_new; Type: TABLE; Schema: public; Owner: agrammon
--
CREATE TABLE public.session (
session_id TEXT PRIMARY KEY,
session_state TEXT,
session_expiration TIMESTAMP
);
ALTER TABLE public.session OWNER TO agrammon;
--
-- Name: FUNCTION tag_name2id(username text, name text); Type: ACL; Schema: public; Owner: agrammon
--
GRANT ALL ON FUNCTION public.tag_name2id(username text, name text) TO agrammon_user;
--
-- Name: TABLE data_new; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.data_new TO agrammon_user;
--
-- Name: TABLE dataset; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.dataset TO agrammon_user;
--
-- Name: TABLE pers; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,INSERT,UPDATE ON TABLE public.pers TO agrammon_user;
--
-- Name: TABLE branches; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.branches TO agrammon_user;
--
-- Name: SEQUENCE branches_branches_id_seq; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,UPDATE ON SEQUENCE public.branches_branches_id_seq TO agrammon_user;
--
-- Name: SEQUENCE data_new_data_id_seq; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,UPDATE ON SEQUENCE public.data_new_data_id_seq TO agrammon_user;
--
-- Name: TABLE data_view; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT ON TABLE public.data_view TO agrammon_user;
--
-- Name: SEQUENCE dataset_dataset_id_seq; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,UPDATE ON SEQUENCE public.dataset_dataset_id_seq TO agrammon_user;
--
-- Name: TABLE news; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT ON TABLE public.news TO agrammon_user;
--
-- Name: TABLE newsty; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT ON TABLE public.newsty TO agrammon_user;
--
-- Name: SEQUENCE pers_pers_id_seq; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,UPDATE ON SEQUENCE public.pers_pers_id_seq TO agrammon_user;
--
-- Name: TABLE role; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT ON TABLE public.role TO agrammon_user;
--
-- Name: TABLE tag; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tag TO agrammon_user;
--
-- Name: SEQUENCE tag_tag_id_seq; Type: ACL; Schema: public; Owner: agrammon
--
GRANT ALL ON SEQUENCE public.tag_tag_id_seq TO agrammon_user;
--
-- Name: TABLE tagds; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.tagds TO agrammon_user;
--
-- Name: SEQUENCE tagds_tagds_id_seq; Type: ACL; Schema: public; Owner: agrammon
--
GRANT ALL ON SEQUENCE public.tagds_tagds_id_seq TO agrammon_user;
--
-- Name: TABLE session; Type: ACL; Schema: public; Owner: agrammon
--
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.session TO agrammon_user;
--
-- PostgreSQL database dump complete
-- | true |
5df082bbf32c30cded326cee2f19c417390e5ca8 | SQL | hohenzollerns/whatevermusic | /whatever.sql | UTF-8 | 1,482 | 3.421875 | 3 | [] | no_license | CREATE DATABASE whatever;
USE whatever;
create table tb_usuario(
codf int primary key auto_increment,
nome varchar(1000) not null,
email varchar(100) not null,
telefone varchar(11) not null,
cpf char(11) not null,
rg char(9) not null,
sexo varchar(20) not null,
dia varchar(2) not null,
mes varchar(10) not null,
ano char(4) not null,
tipo varchar (12) not null,
cep char(8) not null,
uf char(2) not null,
rua varchar(100) not null,
numero varchar(10) not null,
bairro varchar(50) not null,
cidade varchar(100) not null,
comp varchar(1000),
usuariof varchar (100) not null,
senhaf varchar (50) not null);
CREATE TABLE tb_produtos (
codp Int PRIMARY KEY auto_increment,
preço Varchar(10) not null,
barras Varchar(50) not null);
CREATE TABLE tb_venda (
total Varchar(15) not null,
codv Int PRIMARY KEY auto_increment,
codf Int,
FOREIGN KEY(codf) REFERENCES tb_usuario (codf));
CREATE TABLE tb_vendaXprodutos (
data_venda Varchar(10) not null,
preco_atual Varchar(10) not null,
codp Int,
codv Int,
FOREIGN KEY(codp) REFERENCES tb_produtos (codp),
FOREIGN KEY(codv) REFERENCES tb_venda (codv));
Insert into tb_usuario (nome, email, telefone, cpf, rg, sexo, dia, mes, ano, tipo, cep, uf, rua, numero, bairro, cidade, comp, usuariof, senhaf)
Values ('Pedro Henrique do Carmo Pires', 'pedro.carmo200247@gmail.com', '11961798213', '46344267810', '570525147', 'Masculino', '6', 'Fevereiro', '2002', 'ADM', '06172220', 'SP', 'José Timóteo da Silva',
'120', 'São Pedro', 'Osasco', 'Bloco 3, Ap 65', 'adm', '123' );
select * from tb_usuario; | true |
7bbc801653446e2f3c9ed670ac1f398305572e85 | SQL | DIBYA03/TF-code | /WISE/core-platform/migrations/core/00014_user_device.sql | UTF-8 | 1,155 | 3.421875 | 3 | [] | no_license | -- +goose Up
/* User Device table */
CREATE TABLE user_device (
id UUID PRIMARY KEY NOT NULL DEFAULT Uuid_generate_v4(),
user_id UUID NOT NULL REFERENCES wise_user (id),
device_type TEXT NOT NULL,
token_type TEXT NOT NULL,
token TEXT NOT NULL,
device_key TEXT NOT NULL,
language TEXT NOT NULL DEFAULT 'en-US',
created TIMESTAMP WITH time zone DEFAULT CURRENT_TIMESTAMP,
modified TIMESTAMP WITH time zone DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX user_device_user_id_fkey ON user_device(user_id);
CREATE INDEX user_device_token_idx ON user_device(token);
CREATE INDEX user_device_user_id_token_idx ON user_device(user_id, token);
CREATE INDEX user_device_device_key_idx ON user_device(device_key);
CREATE TRIGGER update_user_device_modified BEFORE UPDATE ON user_device FOR EACH ROW EXECUTE PROCEDURE update_modified_column();
-- +goose Down
DROP TRIGGER IF EXISTS update_user_device_modified on user_device;
DROP INDEX user_device_user_id_fkey;
DROP INDEX user_device_token_idx;
DROP INDEX user_device_user_id_token_idx;
DROP INDEX user_device_device_key_idx;
DROP TABLE user_device;
| true |
bc6dcab14a6296c6b1b24f1a9762d6e0878297bc | SQL | surenius/datasci_course_materials | /assignment2/part_g.sql | UTF-8 | 615 | 4.125 | 4 | [] | no_license | select row_num, col_num, sum(x.value) value
from (
select
a.row_num row_num,
b.col_num col_num,
a.value * b.value value
from A a, B b
where a.col_num = b.row_num
) x
group by x.row_num, x.col_num;
select *
from (
select row_doc, col_doc, sum(x.value) simvalue
from (
select
a.docid row_doc,
b.docid col_doc,
a.count * b.count value
from Frequency a, Frequency b
where a.term = b.term
and a.docid < b.docid
) x
group by x.row_doc, x.col_doc
) y
where
(row_doc = '10080_txt_crude' and col_doc = '17035_txt_earn')
or
(row_doc = '17035_txt_earn' and col_doc = '10080_txt_crude');
| true |
840c09885a9159a6e629f6da9e50b8fe39255120 | SQL | OHDSI/WebAPI | /src/main/resources/resources/cdmresults/sql/report/datadensity/totalrecords.sql | UTF-8 | 1,877 | 3.375 | 3 | [
"Apache-2.0"
] | permissive | SELECT
table_name AS series_name,
stratum_1 AS x_Calendar_Month,
count_value AS y_Record_Count
FROM
(
SELECT
'Visit occurrence' AS table_name,
stratum_1,
count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 220
UNION ALL
SELECT
'Condition occurrence' AS table_name,
stratum_1,
count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 420
UNION ALL
SELECT
'Death' AS table_name,
stratum_1,
count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 502
UNION ALL
SELECT
'Procedure occurrence' AS table_name,
stratum_1,
count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 620
UNION ALL
SELECT
'Drug exposure' AS table_name,
stratum_1,
count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 720
UNION ALL
SELECT
'Observation' AS table_name,
stratum_1,
count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 820
UNION ALL
SELECT
'Drug era' AS table_name,
stratum_1,
count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 920
UNION ALL
SELECT
'Condition era' AS table_name,
stratum_1,
count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 1020
UNION ALL
SELECT
'Observation period' AS table_name,
stratum_1,
count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 111
UNION ALL
SELECT
'Measurement' AS table_name,
stratum_1,
count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 1820
) t1
ORDER BY series_Name, CAST(stratum_1 AS INT) | true |
8d61e71c2893be7bd5c50bf0f7cc2b8a1174557d | SQL | izerui/lemon | /src/main/resources/dbmigrate/h2/cms/V0_0_1__cms_article.sql | UTF-8 | 465 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive |
-------------------------------------------------------------------------------
-- cms article
-------------------------------------------------------------------------------
CREATE TABLE CMS_ARTICLE(
ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL,
NAME VARCHAR(200),
CONTENT VARCHAR(200),
TYPE INTEGER,
CREATE_TIME TIMESTAMP,
USER_ID BIGINT,
STATUS INTEGER,
CONSTRAINT PK_CMS_ARTICLE PRIMARY KEY(ID)
);
| true |
021a1a6315309e7453b3d483624e2d4ea0abdbe1 | SQL | JinYuan8/wuhan_plague | /version2.0/SQL_mysql/china_total_info.sql | UTF-8 | 1,515 | 3.015625 | 3 | [] | no_license | /*
Navicat Premium Data Transfer
Source Server : yyw
Source Server Type : MySQL
Source Server Version : 80016
Source Host : localhost:3306
Source Schema : plague_info
Target Server Type : MySQL
Target Server Version : 80016
File Encoding : 65001
Date: 19/02/2020 22:53:19
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for china_total_info
-- ----------------------------
DROP TABLE IF EXISTS `china_total_info`;
CREATE TABLE `china_total_info` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`diagnosis_num` int(11) NOT NULL COMMENT '确诊人数',
`suspect_num` int(11) NOT NULL COMMENT '疑似人数',
`cure_num` int(11) NOT NULL COMMENT '治愈人数',
`death_num` int(11) NOT NULL COMMENT '死亡人数',
`recording_time` timestamp(0) NOT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '记录时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 685 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of china_total_info
-- ----------------------------
INSERT INTO `china_total_info` VALUES (12, 321, 162, 25, 6, '2020-01-22 00:53:20');
INSERT INTO `china_total_info` VALUES (13, 321, 163, 25, 6, '2020-01-22 01:53:26');
INSERT INTO `china_total_info` VALUES (14, 321, 163, 25, 6, '2020-01-22 02:53:30');
INSERT INTO `china_total_info` VALUES (15, 321, 163, 25, 6, '2020-01-22 03:53:34'); | true |
3bdff090aa9aab59234ee4d5a88961d0b858897b | SQL | jonasmu/Actos | /Actos.BaseDatos/dbo/Stored Procedures/TiposRedesSociales_DevolverTodos.sql | UTF-8 | 148 | 2.578125 | 3 | [] | no_license | CREATE PROCEDURE TiposRedesSociales_DevolverTodos
AS
SELECT
tr.IdTipoRedSocial,
tr.Nombre
FROM TiposRedesSociales tr
ORDER BY tr.Nombre ASC | true |
7b1b46a8ad03be8eec1be7aed53a323ad20ae208 | SQL | mabr3/HackerRank | /SQL/BasicJoin/TheReport.sql | UTF-8 | 175 | 3.234375 | 3 | [] | no_license | SELECT CASE WHEN Grade >7 THEN Name ELSE NULL END as Name, Grade, Marks
FROM Students join Grades
ON Marks BETWEEN Min_Mark AND Max_Mark
ORDER BY Grade desc, Name, Marks asc
| true |
858db32e2afdbfca3515977ea28fc8d4a88cdbfe | SQL | bogdanovmn/ncuxywka-original | /install/db/tables/bans.sql | UTF-8 | 608 | 3.453125 | 3 | [] | no_license | CREATE TABLE ban (
id int unsigned NOT NULL AUTO_INCREMENT,
ip char(15) NOT NULL,
user_id smallint unsigned DEFAULT NULL,
begin timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
end timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment` varchar(255) NOT NULL,
type tinyint NOT NULL,
PRIMARY KEY (id),
KEY i_ban_ip (ip),
KEY i_ban_user_id (user_id),
KEY i_ban_begin_end (begin,end),
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8
| true |
e65481e3149946380c2f153e1ae3075010c11cd7 | SQL | DmitriyPavliut/store | /store.sql | UTF-8 | 7,765 | 3.28125 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- Хост: localhost
-- Время создания: Июл 03 2021 г., 23:00
-- Версия сервера: 10.4.19-MariaDB
-- Версия PHP: 7.3.28
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 */;
--
-- База данных: `store`
--
CREATE DATABASE IF NOT EXISTS `store` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
USE `store`;
-- --------------------------------------------------------
--
-- Структура таблицы `categories`
--
CREATE TABLE IF NOT EXISTS `categories` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`titleID` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`parent_id` bigint(20) UNSIGNED DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `categories_parent_id_foreign` (`parent_id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- ССЫЛКИ ТАБЛИЦЫ `categories`:
-- `parent_id`
-- `categories` -> `id`
--
--
-- Дамп данных таблицы `categories`
--
INSERT INTO `categories` (`id`, `title`, `titleID`, `created_at`, `updated_at`, `parent_id`) VALUES
(1, 'Мужское', 'muzskoe', '2021-06-23 09:49:37', '2021-06-25 08:43:13', NULL),
(2, 'Женское', 'zenskoe', '2021-06-23 09:51:04', '2021-06-25 08:43:16', NULL),
(3, 'Куртки', 'kurtki', '2021-06-23 10:22:57', '2021-06-25 08:43:26', 1),
(7, 'Обувь', 'obuv', '2021-06-23 13:58:54', '2021-06-25 08:43:39', 1),
(11, 'Майки', 'maiki', '2021-07-02 15:33:21', '2021-07-02 15:33:21', 1),
(12, 'Брюки', 'bryuki', '2021-07-02 15:37:34', '2021-07-02 15:37:34', 2),
(13, 'Верхняя одежда', 'verxnyaya-odezda', '2021-07-02 15:43:23', '2021-07-02 15:43:23', 2),
(14, 'Пальто', 'palto', '2021-07-02 15:43:30', '2021-07-02 15:43:30', 13),
(15, 'Плащи', 'plashhi', '2021-07-02 15:46:03', '2021-07-02 15:46:03', 13),
(16, 'Свитшоты', 'svitsoty', '2021-07-02 15:50:52', '2021-07-02 15:50:52', 2),
(17, 'Мантии', 'mantii', '2021-07-02 15:57:13', '2021-07-02 15:57:13', 2),
(18, 'Костюмы', 'kostyumy', '2021-07-02 16:06:48', '2021-07-02 16:06:48', 2);
-- --------------------------------------------------------
--
-- Структура таблицы `failed_jobs`
--
CREATE TABLE IF NOT EXISTS `failed_jobs` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
`queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
`payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`failed_at` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- ССЫЛКИ ТАБЛИЦЫ `failed_jobs`:
--
-- --------------------------------------------------------
--
-- Структура таблицы `migrations`
--
CREATE TABLE IF NOT EXISTS `migrations` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`batch` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- ССЫЛКИ ТАБЛИЦЫ `migrations`:
--
--
-- Дамп данных таблицы `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, '2014_10_12_200000_add_two_factor_columns_to_users_table', 1),
(4, '2019_08_19_000000_create_failed_jobs_table', 1),
(5, '2021_06_21_110016_create_permission_tables', 2),
(6, '2021_06_22_115131_create_categories_table', 3),
(7, '2021_06_23_114900_create_products_table', 4),
(8, '2021_06_23_120551_create_product_images_table', 5),
(9, '2021_06_24_162138_create_product_properties_table', 6),
(10, '2021_06_24_163809_create_properties_values_table', 7),
(11, '2021_06_24_164232_create_products_has_properties_table', 8),
(12, '2021_06_24_133443_create_orders_table', 9),
(13, '2021_06_25_184434_create_carts_table', 10),
(14, '2021_06_30_085827_create_category_has_property_table', 11),
(15, '2018_08_08_100000_create_telescope_entries_table', 12);
-- --------------------------------------------------------
--
-- Структура таблицы `password_resets`
--
CREATE TABLE IF NOT EXISTS `password_resets` (
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
KEY `password_resets_email_index` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- ССЫЛКИ ТАБЛИЦЫ `password_resets`:
--
--
-- Дамп данных таблицы `password_resets`
--
INSERT INTO `password_resets` (`email`, `token`, `created_at`) VALUES
('admin@admin.ru', '$2y$10$MBSb2yTn8BcbPPL/eUrtOO7Kt5u6RNRVZWEg92NdbWwTV5kTksVSG', '2021-06-22 13:10:54');
-- --------------------------------------------------------
--
-- Структура таблицы `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`two_factor_secret` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`two_factor_recovery_codes` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`accepted` tinyint(1) DEFAULT 1,
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- ССЫЛКИ ТАБЛИЦЫ `users`:
--
--
-- Дамп данных таблицы `users`
--
INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `two_factor_secret`, `two_factor_recovery_codes`, `remember_token`, `created_at`, `updated_at`, `accepted`) VALUES
(1, 'admin', 'admin@admin.ru', NULL, '$2y$10$C7wPsjOefvo/j3Xo.blujuL3/MMN4rNVB2jrt4mW72HzSWBeJJJ4O', NULL, NULL, NULL, '2021-06-21 08:07:06', '2021-06-21 08:07:06', 0),
(8, 'afasdf', 'asdsa@asd.ru', NULL, '$2y$10$nCFWZdWDh4E0nGCqPrQ4mesxMSeZRnbiw84cDD8jQrWd42JO9uDCW', NULL, NULL, NULL, '2021-06-23 11:22:42', '2021-06-23 11:22:42', 1),
(9, 'qwerty', 'qwertg@mail.ru', NULL, '$2y$10$ks32z2nuQWkurzUD1t/seOvhlHpttmVvtaiVW0eGoEkBlsQyBJ5ZW', NULL, NULL, NULL, '2021-06-29 03:28:28', '2021-06-29 03:28:28', 1);
--
-- Ограничения внешнего ключа сохраненных таблиц
--
--
-- Ограничения внешнего ключа таблицы `categories`
--
ALTER TABLE `categories`
ADD CONSTRAINT `categories_parent_id_foreign` FOREIGN KEY (`parent_id`) REFERENCES `categories` (`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 |
b136edf1c8b3e0b9b70a9d48379e688bd3c367dd | SQL | euberdeveloper/unitn-db-assignment-2 | /SQL_201514/query_8.sql | UTF-8 | 293 | 3.78125 | 4 | [
"MIT"
] | permissive | SELECT DISTINCT S.name
FROM "Stadium" S
WHERE (
(
'Europe' = ALL (
SELECT continent
FROM "Nationality" N, "Match" M
WHERE M.stadium = S.name AND (N.country = M.home OR N.country = M.GUEST)
)
)
AND (
EXISTS (
SELECT *
FROM "Match" M
WHERE M.stadium = S.name
)
)
); | true |
b580bbc3249e538c3fbb9b04900a34ba0d487384 | SQL | wantonbe/mojolicious-wp_sample | /ddl/service_request_history.sql | UTF-8 | 326 | 3 | 3 | [] | no_license | CREATE TABLE service_request_history (
service_request_id INT UNSIGNED NOT NULL,
update_datetime TIMESTAMP NOT NULL,
new_status ENUM('Open', 'Waiting Customer', 'In Progress', 'Closed') NOT NULL,
PRIMARY KEY (service_request_id, new_status, update_datetime),
INDEX(update_datetime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
| true |
def3eb64f60bc54996cc5526b01f8b3678146f7c | SQL | ericLavachery/COGIP-app | /db/cogip_db.sql | UTF-8 | 3,035 | 3.40625 | 3 | [] | no_license | -- MySQL Script generated by MySQL Workbench
-- di 28 aug 2018 12:04:39 CEST
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Table `id6935654_cogip`.`type_soc`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `id6935654_cogip`.`type_soc` (
`id` INT NOT NULL AUTO_INCREMENT,
`type` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `id6935654_cogip`.`societe`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `id6935654_cogip`.`societe` (
`id` INT NOT NULL AUTO_INCREMENT,
`nom` VARCHAR(45) NULL,
`adresse` VARCHAR(45) NULL,
`pays` VARCHAR(45) NULL,
`tva` VARCHAR(20) NULL,
`telephone` INT NULL,
`type_soc_id` INT NOT NULL,
PRIMARY KEY (`id`, `type_soc_id`),
INDEX `fk_societe_type_soc1_idx` (`type_soc_id` ASC),
CONSTRAINT `fk_societe_type_soc1`
FOREIGN KEY (`type_soc_id`)
REFERENCES `id6935654_cogip`.`type_soc` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `id6935654_cogip`.`personne`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `id6935654_cogip`.`personne` (
`id` INT NOT NULL AUTO_INCREMENT,
`nom` VARCHAR(45) NULL,
`prenom` VARCHAR(45) NULL,
`telephone` INT NULL,
`email` VARCHAR(45) NULL,
`societe_id` INT NOT NULL,
PRIMARY KEY (`id`, `societe_id`),
INDEX `fk_personne_societe1_idx` (`societe_id` ASC),
CONSTRAINT `fk_personne_societe1`
FOREIGN KEY (`societe_id`)
REFERENCES `id6935654_cogip`.`societe` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `id6935654_cogip`.`facture`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `id6935654_cogip`.`facture` (
`id` INT NOT NULL AUTO_INCREMENT,
`numero` INT NULL,
`date_facturation` DATE NULL,
`motif_prestation` MEDIUMTEXT NULL,
`personne_id` INT NOT NULL,
`societe_id` INT NOT NULL,
PRIMARY KEY (`id`, `personne_id`, `societe_id`),
INDEX `fk_facture_personne_idx` (`personne_id` ASC),
INDEX `fk_facture_societe1_idx` (`societe_id` ASC),
CONSTRAINT `fk_facture_personne`
FOREIGN KEY (`personne_id`)
REFERENCES `id6935654_cogip`.`personne` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_facture_societe1`
FOREIGN KEY (`societe_id`)
REFERENCES `id6935654_cogip`.`societe` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
| true |
8594b19116bc1ec17b9f12bbcb7e7fa835e510e3 | SQL | arvi9/sqlserver-kit | /Scripts/Estimate_When_Long_Running_SQL_Processes_Will_Finish.sql | UTF-8 | 910 | 3.765625 | 4 | [
"MIT"
] | permissive | /*
Author: Tim Ford
Original link: http://sqlmag.com/database-administration/estimate-when-long-running-sql-processes-will-finish
*/
SET NOCOUNT ON;
SELECT R.session_id
, R.percent_complete
, R.total_elapsed_time/1000 AS elapsed_seconds
, R.wait_type
, R.wait_time
, R.last_wait_type
, DATEADD(s,100/((R.percent_complete)/ (R.total_elapsed_time/1000)), R.start_time) AS est_complete_time
, ST.text AS batch_text
, CAST(SUBSTRING(ST.text, R.statement_start_offset / 2,
(
CASE WHEN R.statement_end_offset = -1 THEN DATALENGTH(ST.text)
ELSE R.statement_end_offset
END - R.statement_start_offset
) / 2
) AS varchar(1024)) AS statement_executing
FROM sys.dm_exec_requests AS R
CROSS APPLY sys.dm_exec_sql_text(R.sql_handle) AS ST
WHERE R.percent_complete > 0
AND R.session_id <> @@spid;
| true |
1554c5283bf01275a200f7d15f31043ccf690a1d | SQL | yesh13/todo | /sql/dev.sql | UTF-8 | 337 | 3.0625 | 3 | [] | no_license |
create table taglist(
id int not null auto_increment primary key,
uid int,
name varchar(16),
schedule_type int,
foreign key(uid) references account(uid)
);
create table act_tag(
id int not null auto_increment primary key,
aid int unsigned,
tid int,
foreign key(tid) references taglist(id),
foreign key(aid) references activity(aid)
) | true |
19a558729a394752b7732de876e902c8f8eea79d | SQL | KylinHuang7/Account | /doc/accounts.sql | UTF-8 | 1,698 | 3.390625 | 3 | [] | no_license | USE `accounts`;
CREATE TABLE `user` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(32) NOT NULL,
`pass` varbinary(64) NOT NULL,
`family_id` int(10) unsigned NOT NULL,
`last_login` TIMESTAMP NOT NULL,
`settle_day` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
CREATE TABLE `account` (
`id` int(10) unsigned NOT NULL auto_increment,
`user_id` int(10) unsigned NOT NULL,
`title` varchar(32) NOT NULL,
`delete_flag` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
CREATE TABLE `type` (
`id` int(10) unsigned NOT NULL auto_increment,
`title` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
CREATE TABLE `bill` (
`id` int(10) unsigned NOT NULL auto_increment,
`account_from_id` int(10) unsigned NOT NULL,
`account_to_id` int(10) unsigned NOT NULL,
`date` DATE NOT NULL,
`type_id` int(10) unsigned NOT NULL,
`amount` decimal(9,2) unsigned NOT NULL,
`claim_flag` tinyint(3) unsigned NOT NULL default '0',
`description` varchar(32) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
CREATE TABLE `summary` (
`user_id` int(10) unsigned NOT NULL,
`date` DATE NOT NULL,
`type_id` int(10) unsigned NOT NULL,
`income` decimal(9,2) unsigned NOT NULL,
`outgo` decimal(9,2) unsigned NOT NULL,
`budget` decimal(9,2) unsigned NOT NULL,
`balance` decimal(9,2) unsigned NOT NULL,
PRIMARY KEY (`user_id`, `date`, `type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
| true |
ec2f89bac4b456f198777ac6fa0962392969a975 | SQL | iyaso/bank-transfer-demo | /src/test/resources/demo.sql | UTF-8 | 686 | 2.84375 | 3 | [] | no_license | DROP TABLE IF EXISTS Account;
CREATE TABLE Account (AccountId LONG PRIMARY KEY AUTO_INCREMENT NOT NULL,
UserName VARCHAR(30),
Balance DECIMAL(19,4),
CurrencyCode VARCHAR(30)
);
INSERT INTO Account (UserName,Balance,CurrencyCode) VALUES ('iyas',100.0000,'USD');
INSERT INTO Account (UserName,Balance,CurrencyCode) VALUES ('test1',200.0000,'USD');
INSERT INTO Account (UserName,Balance,CurrencyCode) VALUES ('iyas',500.0000,'EUR');
INSERT INTO Account (UserName,Balance,CurrencyCode) VALUES ('test1',500.0000,'EUR');
INSERT INTO Account (UserName,Balance,CurrencyCode) VALUES ('iyas',500.0000,'GBP');
INSERT INTO Account (UserName,Balance,CurrencyCode) VALUES ('test1',500.0000,'GBP');
| true |
91a65eb88dd200c5e9de5283030b40b09a62c79c | SQL | tunji86/SQL | /Aggregate Functions.sql | UTF-8 | 2,195 | 4.03125 | 4 | [] | no_license | --WINDOW FUNCTIONS TUTORIAL
--https://www.postgresql.org/docs/8.4/static/tutorial-window.html
select BusinessEntityID, TerritoryID, SUM(BONUS)
over (partition by BusinessEntityID order by TerritoryID)
from Sales.SalesPerson;
--MIN & MAX
select Max(bONUS) from Sales.SalesPerson
select Min(Bonus) from Sales.SalesPerson
SELECT COUNT(*) FROM Sales.SalesPerson
select * from Sales.SalesOrderHeader
select SalesPersonID, SalesOrderNUmber, sum(SubTotal) over(partition by SalesPersonID order by SalesOrderNumber DESC)
from Sales.SalesOrderHeader
where DueDate between '1/1/2012' and '12/31/2012'
select * from Production.Product
select Name, AVG(SafetyStockLevel) as [Avergae Stock],
count(*) as [Number of Products]
from Production.Product
Group by Name
Select ST.Name,P.LastName +''+ P.FirstName as [Sales Person], sum(TotalDue) as[Total Sales]
from Sales.SalesOrderHeader SOH
inner join Sales.SalesPerson SP
on SP.BusinessEntityID = SOH.SalesPersonID
inner join Person.Person P
on P.BusinessEntityID = SP.BusinessEntityID
inner join Sales.SalesTerritory ST
on SOH.TerritoryID = ST.TerritoryID
where SOH.OrderDate between '1/1/2012' and '12/31/2012'
Group by ST.Name, P.LastName +''+ P.FirstName
--order by P.LastName
select ST.Name, SOH.ModifiedDate,count(ST.Name) as [Territory Count], sum(SOH.Subtotal) as [Total Sales]
from Sales.SalesTerritory ST
inner join Sales.SalesOrderHeader SOH
on ST.TerritoryID = SOH.TerritoryID
where SOH.ModifiedDate between '1/1/2011' and '12/31/2012'
Group by ST.Name, SOH.ModifiedDate
having sum(SOH.Subtotal) > 4000 and count(ST.Name) >20
order by ST.Name, SOH.ModifiedDate
select sum(RevisionNumber)
from Sales.SalesOrderHeader
group by SalesOrderID
select Department, count(*) as [No of Department]
from HumanResources.vEmployeeDepartment
group by Department
Having count(*) > 1
order by [No of Department]
select SalesPersonID, count(SalesOrderID) as [No of Sales], sum(TotalDue) as [Total]
from Sales.SalesOrderHeader
where OrderDate between '1/1/2012' and '12/31/2012' and SalesPersonID is not null
group by SalesPersonID
having sum(TotalDue) >= 20000
order by [No of Sales]
| true |
597f1004b5a00cd3964f316683c9d8abf4cb84eb | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/high/day17/select2032.sql | UTF-8 | 498 | 3.6875 | 4 | [] | no_license |
SELECT obs.sensor_id, avg(counts)
FROM (SELECT sensor_id, date_trunc('day', timestamp), count(*) as counts
FROM WeMoObservation WHERE timestamp>'2017-11-16T20:32:00Z' AND timestamp<'2017-11-17T20:32:00Z' AND SENSOR_ID = ANY(array['8b20c416_ec01_4567_9dda_999371e0f0fb','fdd5bea7_91fd_4094_b44d_c41f9aa78fc7','ee4c8b5f_b46f_407e_947b_38ee0e13a738','1b6be25e_93c1_4e70_b3ba_1e8efbcd9416','3143_clwa_3051'])
GROUP BY sensor_id, date_trunc('day', timestamp)) AS obs
GROUP BY sensor_id
| true |
6c10d83a1c010e1306bb014b099978037b053b7a | SQL | hdblocal/authorityDemo | /sql.sql | UTF-8 | 6,477 | 3.28125 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : taotao
Source Server Version : 50711
Source Host : localhost:3306
Source Database : mooc_quanxian
Target Server Type : MYSQL
Target Server Version : 50711
File Encoding : 65001
Date: 2017-06-07 18:11:48
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `access`
-- ----------------------------
DROP TABLE IF EXISTS `access`;
CREATE TABLE `access` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(50) COLLATE utf8_unicode_520_ci NOT NULL,
`urls` varchar(1000) COLLATE utf8_unicode_520_ci NOT NULL,
`status` tinyint(4) NOT NULL,
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_520_ci;
-- ----------------------------
-- Records of access
-- ----------------------------
INSERT INTO `access` VALUES ('1', '测试页面1', 'test/page1', '1', '2017-06-07 10:44:44', '2017-06-07 10:44:44');
INSERT INTO `access` VALUES ('3', '测试页面2', 'test/page2', '1', '2017-06-07 10:44:46', '2017-06-07 10:44:46');
INSERT INTO `access` VALUES ('4', '测试页面3', 'test/page3', '1', '2017-06-07 10:44:48', '2017-06-07 10:44:48');
INSERT INTO `access` VALUES ('5', '测试页面4', 'test/page4', '1', '2017-06-07 10:44:50', '2017-06-07 10:44:50');
INSERT INTO `access` VALUES ('6', '测试页面5', 'test/page5', '1', '2017-06-07 10:44:53', '2017-06-07 10:44:53');
-- ----------------------------
-- Table structure for `app_access_log`
-- ----------------------------
DROP TABLE IF EXISTS `app_access_log`;
CREATE TABLE `app_access_log` (
`id` int(11) NOT NULL,
`uid` bigint(20) NOT NULL,
`target_url` varchar(255) COLLATE utf8_unicode_520_ci NOT NULL,
`query_params` longtext COLLATE utf8_unicode_520_ci NOT NULL,
`ua` varchar(255) COLLATE utf8_unicode_520_ci NOT NULL,
`ip` varchar(32) COLLATE utf8_unicode_520_ci NOT NULL,
`note` varchar(1000) COLLATE utf8_unicode_520_ci NOT NULL,
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_520_ci;
-- ----------------------------
-- Records of app_access_log
-- ----------------------------
-- ----------------------------
-- Table structure for `role`
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_520_ci NOT NULL COMMENT '角色名称',
`status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '''状态 1:有效 0:无效'',',
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of role
-- ----------------------------
INSERT INTO `role` VALUES ('5', '普通用户', '1', '2017-06-05 00:00:00', '2017-06-05 00:00:00');
INSERT INTO `role` VALUES ('6', '系统管理员 ', '1', '2017-06-05 00:00:00', '2017-06-05 00:00:00');
INSERT INTO `role` VALUES ('7', '超级VIP', '1', '2017-06-05 00:00:00', '2017-06-05 00:00:00');
INSERT INTO `role` VALUES ('8', '黄金VIP', '1', '2017-06-06 10:22:20', '2017-06-06 10:22:20');
INSERT INTO `role` VALUES ('9', '游客', '1', '2017-06-06 11:12:05', '2017-06-06 11:12:05');
-- ----------------------------
-- Table structure for `role_access`
-- ----------------------------
DROP TABLE IF EXISTS `role_access`;
CREATE TABLE `role_access` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`role_id` int(11) NOT NULL,
`access_id` int(11) NOT NULL,
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_520_ci;
-- ----------------------------
-- Records of role_access
-- ----------------------------
INSERT INTO `role_access` VALUES ('1', '5', '1', '2017-06-06 23:04:57');
INSERT INTO `role_access` VALUES ('2', '5', '3', '2017-06-06 23:04:57');
-- ----------------------------
-- Table structure for `user`
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL DEFAULT '' COMMENT '姓名',
`email` varchar(30) NOT NULL DEFAULT '' COMMENT '邮箱',
`is_admin` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否是超级管理员 1表示是 0 表示不是',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态 1:有效 0:无效',
`updated_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后一次更新时间',
`created_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COMMENT='用户表';
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES ('11', '系统管理员', 'xtgly@163.com', '0', '1', null, null);
INSERT INTO `user` VALUES ('12', '张三', 'zhangsan@163.com', '0', '1', null, null);
INSERT INTO `user` VALUES ('13', '李四', 'lisi@163.com', '0', '1', null, null);
INSERT INTO `user` VALUES ('15', '王五', 'wangwu@163.com', '0', '1', null, null);
-- ----------------------------
-- Table structure for `user_role`
-- ----------------------------
DROP TABLE IF EXISTS `user_role`;
CREATE TABLE `user_role` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(11) unsigned NOT NULL,
`role_id` int(12) unsigned NOT NULL,
`created_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `role_id` (`role_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user_role
-- ----------------------------
INSERT INTO `user_role` VALUES ('3', '11', '6', '2017-06-06 20:56:56');
INSERT INTO `user_role` VALUES ('4', '12', '5', '2017-06-06 20:57:10');
INSERT INTO `user_role` VALUES ('5', '13', '5', '2017-06-06 20:57:23');
INSERT INTO `user_role` VALUES ('6', '14', '7', '2017-06-06 20:57:34');
INSERT INTO `user_role` VALUES ('7', '15', '7', '2017-06-06 20:58:31');
| true |
7d68d4728682b0349fc097596772776918897bfa | SQL | enimateK/database-tp | /TP3/TP3.sql | UTF-8 | 5,039 | 3.96875 | 4 | [] | no_license | /* Script de création des tables et des tuples */
/* Par Dan Monunu et Benjamin Dutriaux */
/* Création de la table clients qui a comme clé primaire l'attribut "idcl" */
CREATE TABLE clients(
idcl INTEGER PRIMARY KEY,
nom VARCHAR2(20),
prenom VARCHAR2(15),
adr VARCHAR2(30),
tel VARCHAR2(12)
);
/* Création de la table livres qui a comme clé primaire l'attribut "refl" */
CREATE TABLE livres(
refl VARCHAR2(10) PRIMARY KEY,
titre VARCHAR2(20),
auteur VARCHAR2(20),
genre VARCHAR2(15))
;
-- Question du TP 2
ALTER TABLE livres ADD note_moy NUMBER;
/* Création de la table achats qui a comme clé primaire les attributs "idcl, relf, dateachats" */
/* L'attribut "idcl" est une clé étrangère de la table clients, "refl", une clé étrangère de la table livres */
CREATE TABLE achats(
idcl INTEGER REFERENCES clients(idcl) ON DELETE CASCADE ,
refl VARCHAR2(10) REFERENCES livres(refl) ON DELETE CASCADE ,
dateachat date ,
PRIMARY KEY (idcl, refl, dateachat)
);
/* Détermination des contraintes de date sur la table achats (du 1er Janvier 2008 au 31 Décembre 2013) */
ALTER TABLE achats ADD CONSTRAINT contrainteachat CHECK (dateachat IS NOT NULL AND dateachat >= to_date('01-JAN-2008', 'DD-MON-YYYY') AND dateachat <= to_date('31-DEC-2013', 'DD-MON-YYYY') );
/* Création de la table avis qui a comme clé primaire les attributs "idcl, relf" */
/* L'attribut "idcl" est une clé étrangère de la table clients, "refl", une clé étrangère de la table livres */
CREATE TABLE avis(
idcl INTEGER REFERENCES clients(idcl) ON DELETE CASCADE ,
refl VARCHAR2(10) REFERENCES livres(refl) ON DELETE CASCADE ,
note INTEGER,
commentaire VARCHAR2(50),
PRIMARY KEY (idcl, refl)
);
/* Détermination des contraintes de notes sur la table avis (entre 1 et 20) */
ALTER TABLE avis ADD CONSTRAINT contrainteavis CHECK ( note IS NOT NULL AND note >= 1 AND note <= 20 );
/* Script d'insertion d'un jeu d'essai dans la base de données */
/* Par Dan Monunu et Benjamin Dutriaux */
/* Insertion de clients */
INSERT INTO clients VALUES(01, 'Dupont', 'Pierre', '2 chemin de la houssinière ', '054154541514');
INSERT INTO clients VALUES(02, 'francois', 'Georges', '3 chemin de la houssinière ', '054154541515');
INSERT INTO clients VALUES(03, 'Jean', 'Armand', '4 chemin de la houssinière ', '054154541516');
INSERT INTO clients VALUES(04, 'Mercier', 'Christophe', '5 chemin de la houssinière ', '054154541517');
INSERT INTO clients VALUES(05, 'Paloma', 'Johanna', '6 chemin de la houssinière ', '054154541518');
/* Insertion de livres */
INSERT INTO livres VALUES('94DD78FD12','La licence MIAGE', 'Dan MONUNU', 'Harlequin');
INSERT INTO livres VALUES('94DD78FD13','La licence chimie', 'Dan MONUNU', 'Aventure');
INSERT INTO livres VALUES('94DD78FD14','La licence INFO', 'Jerome ALPHONSE', 'Science fiction');
INSERT INTO livres VALUES('94DD78FD15','La licence DROIT', 'Armand Jean', 'Educatif');
INSERT INTO livres VALUES('94DD78FD16','La licence MEDECINE', 'Dan MERCIER', 'Policier');
/* Insertion d'achats de livres */
INSERT INTO achats VALUES(01, '94DD78FD12', '25-MAY-2010');
INSERT INTO achats VALUES(02, '94DD78FD12', '05-MAY-2009');
INSERT INTO achats VALUES(01, '94DD78FD14', '14-JUN-2012');
INSERT INTO achats VALUES(03, '94DD78FD15', '07-SEP-2011');
INSERT INTO achats VALUES(04, '94DD78FD13', '25-DEC-2013');
/* Insertion d'avis */
INSERT INTO avis VALUES(01, '94DD78FD12', 17, 'Bon');
INSERT INTO avis VALUES(02, '94DD78FD12', 07, 'Mauvais');
INSERT INTO avis VALUES(03, '94DD78FD15', 11, 'Moyen');
INSERT INTO avis VALUES(04, '94DD78FD13', 10, 'Moyen');
INSERT INTO avis VALUES(05, '94DD78FD14', 18, NULL);
-- Création des tables du TP3
CREATE TABLE parcours (
idp VARCHAR2(10) PRIMARY KEY,
intitulep VARCHAR2(15),
genre VARCHAR2(15),
date_deb date
);
CREATE TABLE inscrip_parcours(
idcl INTEGER REFERENCES clients (idcl),
idp VARCHAR2(10) REFERENCES parcours(idp),
PRIMARY KEY (idcl, idp)
);
CREATE TABLE inscrip_evt(
idcl INTEGER REFERENCES clients (idcl),
idp VARCHAR2(10) REFERENCES parcours (idp),
id_evt VARCHAR2(10),
PRIMARY KEY (idcl, idp, id_evt)
);
CREATE TABLE compo_parcours(
idp VARCHAR2(10) REFERENCES parcours(idp),
id_evt VARCHAR2(10), -- REFERENCES inscrip_evt (id_evt),
PRIMARY KEY(idp, id_evt)
);
-- Insertion des tuples du TP3
INSERT INTO parcours VALUES('facile', 'facile', 'Policier', '14-JUN-2012');
INSERT INTO parcours VALUES('moyen', 'moyen', 'Aventure', '15-JUN-2017');
INSERT INTO parcours VALUES('difficile', 'difficile', 'Science-fiction', '16-JUN-2017');
INSERT INTO compo_parcours VALUES('facile', 'facile_1');
INSERT INTO compo_parcours VALUES('facile', 'facile_2');
INSERT INTO compo_parcours VALUES('facile', 'facile_3');
INSERT INTO compo_parcours VALUES('moyen', 'moyen_1');
INSERT INTO compo_parcours VALUES('moyen', 'moyen_2');
INSERT INTO compo_parcours VALUES('moyen', 'moyen_3');
INSERT INTO compo_parcours VALUES('difficile', 'diff_1');
INSERT INTO compo_parcours VALUES('difficile', 'diff_2');
INSERT INTO compo_parcours VALUES('difficile', 'diff_3'); | true |
fedc7af5fff4db623a3c2a9549a63c2b9a196993 | SQL | thanglovemusic94/SpringMVC-Poly | /ass/database/update_table.sql | UTF-8 | 466 | 2.75 | 3 | [] | no_license | use newservlet12month2018;
insert into category(name, code) value('thể thao', 'the-thao');
insert into category(name, code) value('thế giới', 'the-gioi');
insert into category(name, code) value('chính trị', 'chinh-tri');
insert into news(title, categoryid) value('bài viết 1', 1);
insert into news(title, categoryid) value('bài viết 2', 1);
insert into news(title, categoryid) value('bài viết 3', 2);
select * from category;
select * from news; | true |
fc94cb886af5bf8ee6f80902d71a8b390dbb7c11 | SQL | Squirrelshit/Tawagoto | /database.sql | UTF-8 | 683 | 2.625 | 3 | [] | no_license |
-- phpMyAdmin SQL Dump
-- version 2.11.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 03, 2015 at 04:27 AM
-- Server version: 5.1.57
-- PHP Version: 5.2.17
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `tawagoto`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` bigint(20) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`userpage` text NOT NULL,
`avatar` varchar(255) NOT NULL,
`signup_date` date NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
| true |
6dd5df2c3a3b0eee3f75e9d22511b4d9f2eb6e3b | SQL | Andoromeda-Foundation/java-server-template | /pb-migration/src/main/resources/migrations/V20170329134333__ddl_add_md.sql | UTF-8 | 801 | 2.53125 | 3 | [] | no_license | CREATE TABLE `mds` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`p` DECIMAL(20,4) NULL DEFAULT NULL,
`q` DECIMAL(20,4) NULL DEFAULT NULL,
`value` DECIMAL(20,4) NULL DEFAULT NULL,
`name` VARCHAR(45) NULL DEFAULT NULL,
`node` VARCHAR(45) NULL DEFAULT NULL,
`uuid` VARCHAR(128) NULL DEFAULT NULL,
`redis_key` VARCHAR(256) NOT NULL,
`metric_at` DATETIME NULL DEFAULT NULL,
`create_by` BIGINT(20) NULL DEFAULT NULL,
`create_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`update_by` BIGINT(20) NULL DEFAULT NULL,
`update_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`delete_by` BIGINT(20) NULL DEFAULT NULL,
`delete_at` DATETIME NULL DEFAULT NULL,
`active` TINYINT(1) NULL DEFAULT '1',
`deleted` TINYINT(1) NULL DEFAULT '0',
PRIMARY KEY (`id`));
| true |
835de69a85b9a7f70daa2cb4b82cd8c361b5a1b2 | SQL | andre-franco/PAX | /monitoria2/paxmon2/pax/PMP_INSTANCIA.sql | UTF-8 | 962 | 3.375 | 3 | [] | no_license |
CREATE TABLE "PAX"."PMP_INSTANCIA"
( "INSTANCIA_ID" NUMBER,
"HOST_AMBIENTE_ID" NUMBER NOT NULL ENABLE,
"INSTANCIA" VARCHAR2(50) NOT NULL ENABLE,
"DESCRICAO" VARCHAR2(500),
PRIMARY KEY ("INSTANCIA_ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TS_DATA_PAX" ENABLE,
CONSTRAINT "PMP_INSTANCIA_PMP_HOST_AM_FK1" FOREIGN KEY ("HOST_AMBIENTE_ID")
REFERENCES "PAX"."PMP_HOST_AMBIENTE" ("HOST_AMBIENTE_ID") ENABLE
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TS_DATA_PAX"
| true |
e77efebe156b64590681e38bbb2523a2783eabd1 | SQL | richtermarkbaay/MEDTrip | /data/events/error_logs.events.sql | UTF-8 | 282 | 3.0625 | 3 | [
"MIT"
] | permissive | DROP EVENT IF EXISTS error_logs_purger $$
CREATE EVENT `error_logs_purger`
ON SCHEDULE
EVERY 1 DAY
COMMENT 'Purges >1 day old data in error_logs every day'
DO
BEGIN
## purges > 1 day old data
DELETE FROM `error_logs` WHERE DATEDIFF(NOW(), `date_created`) > 1;
END;
$$ | true |
bb629b45b4970d70072e0da8be8a812863200974 | SQL | volodden/MIPT | /Database/DB sql-ex.ru/070.SQL | UTF-8 | 433 | 4.25 | 4 | [] | no_license | WITH T AS (SELECT Battle, Country, COUNT(ship) AS CS
FROM (
SELECT Outcomes.battle, Classes.country, Outcomes.ship
FROM Outcomes INNER JOIN Ships ON Outcomes.ship = Ships.name INNER JOIN Classes ON Classes.class = Ships.class
UNION
SELECT Outcomes.battle, Classes.country, Outcomes.ship
FROM Outcomes INNER JOIN Classes ON Outcomes.ship = Classes.class ) AS X
GROUP BY Battle, Country )
SELECT DISTINCT battle
FROM T
WHERE CS >= 3 | true |
e14434f387cfb483d6d9f0e2d9ee8994d95d1b3f | SQL | Stokes06/mvcphp | /sql/scriptdb.sql | UTF-8 | 793 | 3.453125 | 3 | [] | no_license | drop database if EXISTS epicerie;
create database epicerie;
use epicerie;
create table TypeProduit(
id INT PRIMARY KEY auto_increment NOT NULL,
nom varchar(100)
);
create table Produit(
id int primary key auto_increment not null,
nom varchar(100),
prix double,
mois int,
stock int,
image VARCHAR(100),
idType int not null,
foreign key(idType) references TypeProduit(id)
);
create TABLE User(
id int PRIMARY KEY auto_increment not null,
login varchar(100) not null UNIQUE ,
password VARCHAR(20) not null
);
insert into TypeProduit(nom) values("fruit"),("légume");
insert into Produit(nom, prix, mois, stock, idType, image)
values("Tomate",2.5,5,25,1,null),
("Mangue",10,8,2,1,null),
("Salade",1,1,50,2,"salade.jpg");
insert into User(login, password) VALUE ("dev","dev");
| true |
def16867ac5a58c4fa0c90fcf45c6eaa501332a4 | SQL | jungeunlee95/mariadb-pratice | /문제/join.sql | UTF-8 | 251 | 3.359375 | 3 | [] | no_license | -- join
-- employees 테이블과 titles 테이블을 join하여
-- 직원의 이름과 직책을 모두출력하되 여성 엔지니어만 출력
select e.first_name, t.title
from employees e, titles t
where e.emp_no = t.emp_no
and e.gender = 'f';
| true |
64806f864647bbbbf367ac119edc445bc10fa114 | SQL | TseboMokoena/Intelli-Fleet | /IntelliFleet Database/SQL Queries/VEHICLE_DRIVER.sql | UTF-8 | 254 | 3 | 3 | [] | no_license | CREATE TABLE VEHICLE_DRIVER
(DRIVER_ID INTEGER NOT NULL IDENTITY(1,1),
VEHICLE_ID INTEGER NOT NULL,
PRIMARY KEY (DRIVER_ID,VEHICLE_ID),
FOREIGN KEY (DRIVER_ID) REFERENCES DRIVERS (DRIVER_ID),
FOREIGN KEY (VEHICLE_ID) REFERENCES VEHICLE (VEHICLE_ID)
); | true |
9f5ca49e0309e3dbe7cfbe2b5f443ccdd03ca0ec | SQL | zeroest/KITRI_ORACLEDB | /ORACLE_DB 정리/DDL.sql | UTF-8 | 2,633 | 4.28125 | 4 | [] | no_license |
DDL : Data Definition Lang
: CREATE TABLE 데이터 구조의 정의 / ALTER TABLE 변경 / DROP TABLE 삭제
=====================================================================
--table 생성
create table TEST
(A NUMBER(5) constraint pk_a primary key,
B VARCHAR2(50) [제약조건/생략가능],
.....);
TEST
A B
100 교육부 RECORD=ROW
200 인사개발부 RECORD=ROW
COLUMN COLUMN
create table student(
stu_no char(9),
stu_name varchar2(12),
stu_dept varchar2(20),
stu_grade number(1),
stu_class char(1),
stu_gender char(1),
stu_height number(5,2),
stu_weight number(5,2),
constraint p_stu_no primary key(stu_no));
--테이블이름 , 컬럼이름 속성
1. 대소문자 구분 없다.
2. DB 저장시 대문자 저장(테이블이름 조회시 대문자)
3. 30자 까지 가능
4. 숫자, 문자, _$#, 구성가능
5. 숫자로 시작 불가능
6. SQL 예약어 이름으로 사용 불가능 CREATE TABLE
7. 공백X
--데이터 타입(DATA TYPE)
정수 NUMBER(정수자리수) integer
실수 NUMBER(정수자리수+소수점이하자리수,소수점이하자리수) float
문자열
CHAR : 2000BYTE , VARCHAR2 : 4000BYTE(1300) ,
'KELLY'저장시
EMP_NAME CHAR(10) -- > 10바이트 공간 고정적 유지
EMP_NAME2 VARCHAR2(10) -- > 5바이트 공간 사용
CLOB, LONG : 대용량, GB
영문자 : 1글자 1BYTE
한글 : 1글자 3BYTE
날짜 DATE
정수, 실수값 저장 : 10, 3.14
문자, 날짜값 저장 : 'KELLY' , '08/01/01'
-- table 복사
CREATE TABLE 테이블명
AS
SELECT~
=>테이블 생성 + 데이터 복사
create table emp_copy
as select * from employees;
-필요 조건만 선택 가능
create table emp_50
as select first_name, salary, department_id
from employees where department_id = 50;
-기존 존재 테이블 복사(데이터 복사x)
create table emp_none
as
select * from employees
where 1=0;
--TABLE 테이블명 변경 수정
rename 이전테이블 to 새로운테이블 ;
rename 이전테이블 to 새로운테이블 ;
--table 삭제
drop table student;
===========================================================================
--컬럼 추가
alter table 테이블명 add(컬럼명 타입(길이))
alter table emp add(
GENDER varchar2(6));
--컬럼 수정
alter table emp modify (gender number(1));
기존 컬럼에 데이터가 들어 있다면 서로 호환 되는 것 끼리만 데이터타입의 변경이 가능하다(거의 불가능)
--컬럼 이름변경
alter table emp rename column 이전컬럼 to 새로운컬럼;
alter table emp rename column indate to hire_date;
-- 컬럼 삭제
alter table emp drop column GENDER;
alter table emp drop (GENDER, , , );
| true |
2618326a87f29b56fa2a5c1be0467e9075b5e53e | SQL | gmlakds21/Database_MariaDB | /src/_1_Class_Maria_DB/_12_08/1_Sub_query.sql | UTF-8 | 818 | 3.640625 | 4 | [] | no_license | -- 서브 쿼리
-- 메인 쿼리안에 또 다른 쿼리문으로 구성
-- 스칼라 서브 쿼리 : 결과값으로 하나의 값이 조희
-- 인라인 뷰 : 결과값으로 여러개의 값이 조희
-- 질의문을 여러 단게로 구조화 하기 때문에 쿼리의
-- 각 질의문이 의도하는 의미를 쉽게 파악
-- where, from, select 등에 서브쿼리 사용가능
-- 비스킷을 생산하는 모든 제조업체의 모든 과자
select 과자 from 제품 where 제조업체 =
( select 제조업체 from 제품 where 과자 = 비스킷)
where 제조업체 = ( 비스킷을 생산하는 모든 제조업체 )
where 제조업체 in ( ) // 여러개 일때 not in 도 가능
where 제조업체 > all // 여러개의 숫자값 크고 작은 것을 비교할때
| true |
661d942375662c8f6c4b2585758e37b0eace6c3d | SQL | CUBRID/cubrid-testcases | /sql/_24_aprium_qa/_05_non-ASCII/cases/bug_bts_10624.sql | UTF-8 | 10,618 | 3.609375 | 4 | [
"BSD-3-Clause"
] | permissive |
--+ holdcas on;
drop if exists À;
drop if exists Ö;
create table À(À int);
SHOW full COLUMNS FROM À;
rename table À as Ö;
SHOW full COLUMNS FROM Ö;
rename table Ö to À;
SHOW full COLUMNS FROM À;
drop table À;
create table À(À int);
SHOW full COLUMNS FROM À;
alter table À rename À as Ö;
SHOW full COLUMNS FROM À;
alter table À rename Ö to À ;
SHOW full COLUMNS FROM À;
alter table À CHANGE À Ö char(10) ;
SHOW full COLUMNS FROM À;
drop table À;
create table À(À string);
insert into À values('À');
select * from À;
update À set À='Ö';
select * from À;
delete from À;
insert into À values('À');
select * from À;
truncate À;
drop table À;
create table 计算机(s1 char(200));
alter table 计算机 add column i_列1 int;
create trigger 机器人 before update on 计算机 execute update 计算机 set i_列1 = 0;
alter table 计算机 add constraint i_列1_i_u unique index (i_列1);
desc 计算机;
show index in 计算机;
drop trigger 机器人;
alter table 计算机 drop constraint i_列1_i_u;
alter table 计算机 drop column i_列1;
drop table 计算机;
create table 我 (列 int);
alter table 我 add column 列1 int;
create trigger 机器人 before update on 我 execute update 我 set 列 = 0;
alter table 我 add constraint 约束1 unique index (列);
alter table 我 add constraint 约束2 unique index (列1);
desc 我;
show index in 我;
drop trigger 机器人;
alter table 我 drop constraint 约束1;
alter table 我 drop constraint 约束2;
alter table 我 drop column 列;
alter table 我 drop column 列1;
drop table 我;
create table t1 (i integer);
create user 用户1;
create user 用户组 members 用户1;
grant select on t1 to 用户1;
grant delete on t1 to 用户组;
show grants for 用户1;
show grants for 用户组;
drop user 用户组;
drop user 用户1;
drop table t1;
create table 计算机( i_列1 int) partition by range (i_列1) (partition p0 VALUES LESS THAN (2),partition p1 VALUES LESS THAN (20));
insert into 计算机 values (1), (3), (5);
select * from 计算机__P__P0;
select * from 计算机__p__p1;
desc 计算机;
drop table 计算机;
set @人工智能 = 2;
select @人工智能 + 2;
drop variable @人工智能;
create table "计算机" ( `i_列1` int , [a_列2] int);
desc 计算机;
drop table `计算机`;
CREATE TABLE test_cn (
id int NOT NULL,
name VARCHAR(20) collate utf8_gen);
insert into test_cn values (1,'鸢尾花');
insert into test_cn values (2,'你们');
insert into test_cn values (3,'你们');
insert into test_cn values (103,'你们');
insert into test_cn values (203,'你们');
insert into test_cn values (303,'你们.我们');
insert into test_cn values (403,'你们 他们');
insert into test_cn values (4,'他们');
insert into test_cn values (104,'迎春');
insert into test_cn values (5,'我们');
insert into test_cn values (105,'秋海棠');
insert into test_cn values (205,'碧桃');
insert into test_cn values (6,'水仙');
insert into test_cn values (106,'%水仙');
insert into test_cn values (7,'梨花');
insert into test_cn values (107,'_梨花');
insert into test_cn values (8,'桔梗');
insert into test_cn values (9,'科学');
insert into test_cn values (109,'?科学');
insert into test_cn values (10,'夹竹桃');
insert into test_cn values (110,'*夹竹桃');
select id, name, CHAR_LENGTH (name), lower (name), CHAR_LENGTH (lower(name)), upper(name), CHAR_LENGTH (upper(name)) from test_cn order by 1;
select id, name, OCTET_LENGTH (name), lower (name), OCTET_LENGTH (lower(name)), upper(name), OCTET_LENGTH (upper(name)) from test_cn order by 1;
drop table test_cn;
--+ holdcas on;
set system parameters 'intl_date_lang = zh_CN';
-- date
select 'to_date( , DAY )';
--test
SELECT TO_DATE('2011年5月1日 星期日', 'yyyy-MM-DD DAY');
--test
SELECT TO_DATE('2011-05-01 星期日', 'yyyy-MM-DD DAY');
--test
SELECT TO_DATE('2011-05-02 星期一', 'yyyy-MM-DD DAY');
--test
SELECT TO_DATE('2011-05-03 星期二', 'yyyy-MM-DD DAY');
--test
SELECT TO_DATE('2011-05-04 星期三', 'yyyy-MM-DD DAY');
--test
SELECT TO_DATE('2011-05-05 星期四', 'yyyy-MM-DD DAY');
--test
SELECT TO_DATE('2011-05-06 星期五', 'yyyy-MM-DD DAY');
--test
SELECT TO_DATE('2011-05-07 星期六', 'yyyy-MM-DD DAY');
select 'to_date( , day )';
--test
SELECT TO_DATE('2011年5月1日 星期日', 'yyyy-MM-DD day');
--test
SELECT TO_DATE('2011-05-01 星期日', 'yyyy-MM-DD day');
--test
SELECT TO_DATE('2011-05-02 星期一', 'yyyy-MM-DD day');
--test
SELECT TO_DATE('2011-05-03 星期二', 'yyyy-MM-DD day');
--test
SELECT TO_DATE('2011-05-04 星期三', 'yyyy-MM-DD day');
--test
SELECT TO_DATE('2011-05-05 星期四', 'yyyy-MM-DD day');
--test
SELECT TO_DATE('2011-05-06 星期五', 'yyyy-MM-DD day');
--test
SELECT TO_DATE('2011-05-07 星期六', 'yyyy-MM-DD day');
select 'to_date( , DY )';
--test
SELECT TO_DATE('2011年5月1日 星期日', 'yyyy-MM-DD DY');
SELECT TO_DATE('2011-05-01 周日', 'yyyy-MM-DD DY');
--test
SELECT TO_DATE('2011-05-02 周一', 'yyyy-MM-DD DY');
--test
SELECT TO_DATE('2011-05-03 周二', 'yyyy-MM-DD DY');
--test
SELECT TO_DATE('2011-05-04 周三', 'yyyy-MM-DD DY');
--test
SELECT TO_DATE('2011-05-05 周四', 'yyyy-MM-DD DY');
--test
SELECT TO_DATE('2011-05-06 周五', 'yyyy-MM-DD DY');
--test
SELECT TO_DATE('2011-05-07 周六', 'yyyy-MM-DD DY');
select 'to_date( , dy )';
--test
SELECT TO_DATE('2011年5月1日 星期日', 'yyyy-MM-DD dy');
--test
SELECT TO_DATE('2011-05-01 周日', 'yyyy-MM-DD dy');
--test
SELECT TO_DATE('2011-05-02 周一', 'yyyy-MM-DD dy');
--test
SELECT TO_DATE('2011-05-03 周二', 'yyyy-MM-DD dy');
--test
SELECT TO_DATE('2011-05-04 周三', 'yyyy-MM-DD dy');
--test
SELECT TO_DATE('2011-05-05 周四', 'yyyy-MM-DD dy');
--test
SELECT TO_DATE('2011-05-06 周五', 'yyyy-MM-DD dy');
--test
SELECT TO_DATE('2011-05-07 周六', 'yyyy-MM-DD dy');
-- month
select 'to_date( , MONTH)';
--test
SELECT TO_DATE('2010年1月1日', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 二月', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 三月', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 四月', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 五月', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 六月', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 七月', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 八月', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 九月', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 十月', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 十一月', 'yyyy-dd MONTH');
--test
SELECT TO_DATE('2010-01 十二月', 'yyyy-dd MONTH');
select 'to_date( , month)';
--test
SELECT TO_DATE('2010年1月1日', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 一月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 二月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 三月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 四月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 五月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 六月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 七月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 八月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 九月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 十月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 十一月', 'yyyy-dd month');
--test
SELECT TO_DATE('2010-01 十二月', 'yyyy-dd month');
select 'to_date( , MON)';
--test
SELECT TO_DATE('2010年1月1日', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 1月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 2月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 3月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 4月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 5月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 6月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 7月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 8月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 9月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 10月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 11月', 'yyyy-dd MON');
--test
SELECT TO_DATE('2010-01 12月', 'yyyy-dd MON');
select 'to_date( , mon)';
--test
SELECT TO_DATE('2010年1月1日', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 1月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 2月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 3月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 4月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 5月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 6月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 7月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 8月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 9月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 10月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 11月', 'yyyy-dd mon');
--test
SELECT TO_DATE('2010-01 12月', 'yyyy-dd mon');
select 'to_date( , Month)';
--test
SELECT TO_DATE('2010年1月1日', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 一月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 二月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 三月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 四月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 五月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 六月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 七月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 八月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 九月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 十月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 十一月', 'yyyy-dd Month');
--test
SELECT TO_DATE('2010-01 十二月', 'yyyy-dd Month');
select 'to_date( , Mon)';
--test
SELECT TO_DATE('2010年1月1日', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 1月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 2月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 3月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 4月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 5月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 6月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 7月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 8月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 9月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 10月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 11月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 12月', 'yyyy-dd Mon');
--test
SELECT TO_DATE('2010-01 测试 十一月', 'yyyy-dd "测试" Mon');
--test
SELECT TO_DATE('2010-01 测试 十一月', 'yyyy-dd "测试" Mon');
set system parameters 'intl_date_lang = en_US';
commit;
--+ holdcas off;
| true |
8cbeb89956c1844e7ceacbcfc85154089132e253 | SQL | nsdheeraj/Horacle | /userform.sql | UTF-8 | 1,349 | 2.625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 01, 2019 at 11:47 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: `oracle`
--
-- --------------------------------------------------------
--
-- Table structure for table `userform`
--
CREATE TABLE `userform` (
`name` varchar(30) DEFAULT NULL,
`email` varchar(25) DEFAULT NULL,
`phone` varchar(11) DEFAULT NULL,
`city` varchar(15) DEFAULT NULL,
`day` varchar(2) DEFAULT NULL,
`month` varchar(10) DEFAULT NULL,
`uyear` varchar(5) DEFAULT NULL,
`hour` varchar(5) DEFAULT NULL,
`minutes` varchar(5) DEFAULT NULL,
`meridiem` varchar(4) DEFAULT NULL,
`gender` varchar(7) DEFAULT NULL,
`subject` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
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 |
dc45af14416b9576e745b1b732c58d04dbb9771c | SQL | leskovsky1/FRI | /Bc/4.semester/zaklady databazovych systemov/databazy/pomocky z predoslych rokov/ZDBS/ZDBS/!_ZDBS cvika, prednasky,testy,skusky/Testy a iné materiály k zápočtu a skúške/zds/sql/isfr.sql | UTF-8 | 41,456 | 3.046875 | 3 | [] | no_license | { DATABASE isfr delimiter | }
grant dba to "isfr";
grant dba to "informix";
grant dba to "kmat";
grant dba to "novakova";
grant dba to "sicova";
grant dba to "grondzak";
grant dba to "jamrich";
grant dba to "vajsova";
grant dba to "sleziak";
grant connect to "mano";
grant connect to "oweis";
{ TABLE "isfr".zamestnavatel row size = 153 number of columns = 8 index size = 18
}
{ unload file name = zames00100.unl number of rows = 0 }
create table "isfr".zamestnavatel
(
ico char(8) not null ,
nazov char(40) not null ,
ulica char(20),
obec char(20),
psc char(5),
telefon char(20),
fax char(20),
telex char(20)
);
revoke all on "isfr".zamestnavatel from "public";
create unique index "isfr".ix112_1 on "isfr".zamestnavatel (ico);
{ TABLE "isfr".cis_asist row size = 12 number of columns = 2 index size = 9 }
{ unload file name = cis_a00101.unl number of rows = 3 }
create table "isfr".cis_asist
(
druh smallint not null ,
nazov char(10) not null
);
revoke all on "isfr".cis_asist from "public";
create unique index "isfr".ix237_1 on "isfr".cis_asist (druh);
{ TABLE "isfr".kalendar row size = 228 number of columns = 6 index size = 12 }
{ unload file name = kalen00102.unl number of rows = 187 }
create table "isfr".kalendar
(
id serial not null ,
datum date not null ,
udalost1 char(70) not null ,
udalost2 char(70),
udalost3 char(70),
zodpovednost char(10)
);
revoke all on "isfr".kalendar from "public";
create unique index "isfr".ix2186_1 on "isfr".kalendar (id);
{ TABLE "isfr".statut row size = 130 number of columns = 3 index size = 12 }
{ unload file name = statu00103.unl number of rows = 7 }
create table "isfr".statut
(
id serial not null ,
popis char(70) not null ,
subor text not null
);
revoke all on "isfr".statut from "public";
create unique index "isfr".ix2333_1 on "isfr".statut (id);
{ TABLE "isfr".prav row size = 44 number of columns = 3 index size = 0 }
{ unload file name = prav_00104.unl number of rows = 0 }
create table "isfr".prav
(
uzivatel char(20),
uzivatel_1 char(20),
datum date not null
);
revoke all on "isfr".prav from "public";
{ TABLE "isfr".ucitel_pr row size = 12 number of columns = 4 index size = 72 }
{ unload file name = ucite00105.unl number of rows = 679 }
create table "isfr".ucitel_pr
(
cis_predm char(4) not null ,
skrok smallint not null ,
os_cis char(5) not null ,
priznak char(1) not null
);
revoke all on "isfr".ucitel_pr from "public";
create index "isfr".ix241_2 on "isfr".ucitel_pr (skrok);
create index "isfr".ix240_1 on "isfr".ucitel_pr (cis_predm);
create index "isfr".ix240_6 on "isfr".ucitel_pr (os_cis);
create unique index "isfr".up_spo on "isfr".ucitel_pr (skrok,cis_predm,
os_cis);
create index "isfr".up_sp on "isfr".ucitel_pr (skrok,cis_predm);
{ TABLE "isfr".ucitel_cin row size = 261 number of columns = 2 index size = 13 }
{ unload file name = ucite00106.unl number of rows = 3 }
create table "isfr".ucitel_cin
(
os_cis char(5) not null ,
cinnost varchar(255)
);
revoke all on "isfr".ucitel_cin from "public";
create unique index "isfr".ix224_1 on "isfr".ucitel_cin (os_cis);
{ TABLE "isfr".druh_asist row size = 11 number of columns = 3 index size = 82 }
{ unload file name = druh_00107.unl number of rows = 14 }
create table "isfr".druh_asist
(
iddp char(4) not null ,
id_asistent char(5) not null ,
druh smallint not null
);
revoke all on "isfr".druh_asist from "public";
create unique index "isfr".da_ia on "isfr".druh_asist (iddp,id_asistent);
create unique index "isfr".da_id on "isfr".druh_asist (iddp,druh);
create index "isfr".ix208_1 on "isfr".druh_asist (iddp);
create unique index "isfr".da_dad on "isfr".druh_asist (iddp,druh,
id_asistent);
create index "isfr".ix120_2 on "isfr".druh_asist (id_asistent);
{ TABLE "isfr".tel_zoz row size = 75 number of columns = 4 index size = 49 }
{ unload file name = tel_z00108.unl number of rows = 3 }
create table "isfr".tel_zoz
(
os_cis char(5) not null ,
c_tel char(20) not null ,
druh char(20),
poznamka char(30)
);
revoke all on "isfr".tel_zoz from "public";
create index "isfr".ix293_1 on "isfr".tel_zoz (os_cis);
create index "isfr".ix293_2 on "isfr".tel_zoz (c_tel);
{ TABLE "isfr".zostavy row size = 1933 number of columns = 5 index size = 0 }
{ unload file name = zosta00109.unl number of rows = 51 }
create table "isfr".zostavy
(
idz smallint,
fcia char(15),
meno char(60),
help1 char(928),
help2 char(928)
);
revoke all on "isfr".zostavy from "public";
{ TABLE "isfr".asistent_dp row size = 62 number of columns = 5 index size = 31 }
{ unload file name = asist00110.unl number of rows = 0 }
create table "isfr".asistent_dp
(
id_asistent char(5) not null ,
meno char(25) not null ,
ico char(8),
uziv char(20),
dat_zmen date
);
revoke all on "isfr".asistent_dp from "public";
create unique index "isfr".ix127_1 on "isfr".asistent_dp (id_asistent);
create index "isfr".ix127_4 on "isfr".asistent_dp (ico);
{ TABLE "isfr".ucitel row size = 268 number of columns = 28 index size = 106 }
{ unload file name = ucite00111.unl number of rows = 396 }
create table "isfr".ucitel
(
os_cis char(5) not null ,
rod_cis char(10) not null ,
meno char(25) not null ,
rod_meno char(15),
titul char(15),
ped_hod char(8),
ped_ovz smallint,
ped_dat date,
ved_hod char(5),
ved_ovz smallint,
ved_dat date,
narod smallint,
rod_stav smallint,
dat_zrs date,
poc_deti smallint,
obec_s char(25),
ulica_s char(25),
psc_s char(5),
tel_s char(11),
obec_p char(25),
ulica_p char(25),
psc_p char(5),
tel_p char(11),
pr_kat smallint,
cis_kat char(4) not null ,
stav char(1),
uziv char(20),
dat_zmen date
);
revoke all on "isfr".ucitel from "public";
create index "isfr".ix213_25 on "isfr".ucitel (cis_kat);
create unique index "isfr".ix183_1 on "isfr".ucitel (os_cis);
create index "isfr".ix203_24 on "isfr".ucitel (pr_kat);
create index "isfr".ix183_2 on "isfr".ucitel (rod_cis);
create index "isfr".ix183_3 on "isfr".ucitel (meno);
create index "vajsova".ix117_26 on "isfr".ucitel (stav);
alter table "isfr".ucitel add constraint primary key (os_cis)
constraint "isfr".u117_223 ;
{ TABLE "isfr".bod_limit row size = 26 number of columns = 8 index size = 39 }
{ unload file name = bod_l00112.unl number of rows = 222 }
create table "isfr".bod_limit
(
rocnik smallint not null ,
bod_postup smallint not null ,
bod_opak smallint not null ,
skrok smallint not null ,
c_st_odboru smallint not null ,
c_specializacie smallint not null ,
uziv char(10),
dat_zmen date
);
revoke all on "isfr".bod_limit from "public";
create unique index "isfr".bl_sos on "isfr".bod_limit (skrok,rocnik,
c_st_odboru,c_specializacie);
create index "isfr".bl_os on "isfr".bod_limit (c_st_odboru,c_specializacie);
create index "isfr".ix129_1 on "isfr".bod_limit (rocnik);
alter table "isfr".bod_limit add constraint primary key (skrok,
rocnik,c_st_odboru,c_specializacie) constraint "isfr".u127_227
;
{ TABLE "isfr".katedra row size = 700 number of columns = 18 index size = 12 }
{ unload file name = kated00113.unl number of rows = 16 }
create table "isfr".katedra
(
cis_kat char(4) not null ,
nazov char(40) not null ,
skratka char(6) not null ,
cinnost varchar(255),
cinnost2 varchar(255),
adr_psc char(5),
adr_ulica char(20),
adr_mesto char(20),
adr_telefon1 char(11),
adr_telefon2 char(11),
adr_telefon3 char(11),
adr_fax char(11),
adr_email char(20),
ved_kat char(5),
z_ved_kat char(5),
sekrt_kat char(5),
uziv char(10),
dat_zmen date
);
revoke all on "isfr".katedra from "public";
create unique index "isfr".ix214_1 on "isfr".katedra (cis_kat);
alter table "isfr".katedra add constraint primary key (cis_kat)
constraint "isfr".u129_225 ;
{ TABLE "isfr".obec row size = 142 number of columns = 10 index size = 0 }
{ unload file name = obec_00114.unl number of rows = 2910 }
create table "isfr".obec
(
krj char(1),
oks char(3),
okres char(4),
iczuj char(6),
psc char(5),
nazzuj char(55),
nazkrj char(16),
nazoks char(25),
nazokres char(25),
skr char(2)
);
revoke all on "isfr".obec from "public";
{ TABLE "isfr".test row size = 121 number of columns = 6 index size = 0 }
{ unload file name = test_00115.unl number of rows = 741 }
create table "isfr".test
(
rok smallint,
meno char(50),
priezvisko char(50),
dnar date,
rc char(11),
oc integer
);
revoke all on "isfr".test from "public";
{ TABLE "isfr".predmet_eng row size = 219 number of columns = 8 index size = 25 }
{ unload file name = predm00116.unl number of rows = 888 }
create table "isfr".predmet_eng
(
cis_predm char(4) not null ,
nazov char(180) not null ,
gestor char(5),
zrok smallint,
prok smallint,
rrok smallint,
uziv char(20),
dat_zmen date
);
revoke all on "isfr".predmet_eng from "public";
create unique index "isfr".p_eng_cp on "isfr".predmet_eng (cis_predm);
create index "isfr".p_eng_gestor on "isfr".predmet_eng (gestor);
alter table "isfr".predmet_eng add constraint primary key (cis_predm)
constraint "isfr".u135_191 ;
{ TABLE "isfr".sk_spravy row size = 34 number of columns = 10 index size = 21 }
{ unload file name = sk_sp00117.unl number of rows = 4963 }
create table "isfr".sk_spravy
(
id integer not null ,
os_cislo smallint not null ,
st_skupina char(5) not null ,
cis_predm char(4) not null ,
dat_zap date,
dat_prv date,
dat_drh date,
dat_dek date,
znamka char(1),
skrok smallint
);
revoke all on "isfr".sk_spravy from "public";
create unique index "isfr".ix167_1 on "isfr".sk_spravy (id);
create index "isfr".ix167_2 on "isfr".sk_spravy (os_cislo);
{ TABLE "isfr".predmet_stsk row size = 33 number of columns = 6 index size = 37 }
{ unload file name = predm00118.unl number of rows = 324 }
create table "isfr".predmet_stsk
(
skrok smallint not null ,
cis_predm char(4) not null ,
miesto char(1) not null ,
poc_stsk smallint,
uziv char(20),
dat_zmen date
);
revoke all on "isfr".predmet_stsk from "public";
create index "isfr".ixx267_1 on "isfr".predmet_stsk (skrok);
create index "isfr".ixx267_2 on "isfr".predmet_stsk (cis_predm);
create unique index "isfr".xpb_sk on "isfr".predmet_stsk (skrok,
cis_predm,miesto);
{ TABLE "isfr".sysmenus row size = 78 number of columns = 2 index size = 33 }
{ unload file name = sysme00119.unl number of rows = 63 }
create table "isfr".sysmenus
(
menuname char(18),
title char(60)
);
revoke all on "isfr".sysmenus from "public";
create unique index "isfr".sysmenidx on "isfr".sysmenus (menuname);
{ TABLE "isfr".sysmenuitems row size = 143 number of columns = 5 index size = 39
}
{ unload file name = sysme00120.unl number of rows = 214 }
create table "isfr".sysmenuitems
(
imenuname char(18),
itemnum integer,
mtext char(60),
mtype char(1),
progname char(60)
);
revoke all on "isfr".sysmenuitems from "public";
create unique index "isfr".meniidx on "isfr".sysmenuitems (imenuname,
itemnum);
{ TABLE "isfr".neuspesne_2 row size = 6 number of columns = 2 index size = 0 }
{ unload file name = neusp00121.unl number of rows = 0 }
create table "isfr".neuspesne_2
(
os_cislo smallint,
cis_predm char(4)
);
revoke all on "isfr".neuspesne_2 from "public";
{ TABLE "isfr".neuspesne_3 row size = 6 number of columns = 2 index size = 0 }
{ unload file name = neusp00122.unl number of rows = 0 }
create table "isfr".neuspesne_3
(
os_cislo smallint,
cis_predm char(4)
);
revoke all on "isfr".neuspesne_3 from "public";
{ TABLE "isfr".profesia row size = 32 number of columns = 2 index size = 9 }
{ unload file name = profe00123.unl number of rows = 81 }
create table "isfr".profesia
(
id_profes smallint not null ,
popis char(30) not null
);
revoke all on "isfr".profesia from "public";
create unique index "isfr".ix163_1 on "isfr".profesia (id_profes);
alter table "isfr".profesia add constraint primary key (id_profes)
constraint "isfr".u163_202 ;
{ TABLE "isfr".os_udaje row size = 198 number of columns = 18 index size = 111 }
{ unload file name = os_ud00124.unl number of rows = 4974 }
create table "isfr".os_udaje
(
rod_cislo char(11) not null ,
meno char(15) not null ,
priezvisko char(15) not null ,
ulica char(20),
obec char(20),
psc char(5),
narodnost smallint,
st_prisl char(2),
telefon char(20),
mobil char(13),
email char(40),
okres char(4),
drstsk char(1),
vp char(2),
body smallint,
celkom smallint,
uziv char(20),
dat_zmen date,
primary key (rod_cislo) constraint "isfr".ou_pk
);
revoke all on "isfr".os_udaje from "public";
create index "isfr".os_mp on "isfr".os_udaje (priezvisko,meno);
create index "isfr".ix134_3 on "isfr".os_udaje (priezvisko);
{ TABLE "isfr".zap_predmety row size = 66 number of columns = 16 index size = 88
}
{ unload file name = zap_p00125.unl number of rows = 100089 }
create table "isfr".zap_predmety
(
os_cislo smallint not null ,
cis_predm char(4) not null ,
vysledok smallint,
datum_sk date,
termin smallint,
zapocet date,
skrok smallint not null ,
body smallint,
ects smallint,
prednasajuci char(5),
skusajuci char(5),
cviciaci char(5),
miesto char(1),
c_st_odboru smallint,
uziv char(20),
dat_zmen date,
primary key (os_cislo,cis_predm,skrok)
);
revoke all on "isfr".zap_predmety from "public";
create index "isfr".jx118_2 on "isfr".zap_predmety (cis_predm);
create index "isfr".jx195_9 on "isfr".zap_predmety (prednasajuci);
create index "isfr".jx124_7 on "isfr".zap_predmety (skrok);
create index "vajsova".ix168_14 on "isfr".zap_predmety (c_st_odboru);
{ TABLE "isfr".st_odbory row size = 185 number of columns = 9 index size = 30 }
{ unload file name = st_od00126.unl number of rows = 23 }
create table "isfr".st_odbory
(
c_st_odboru smallint not null ,
c_specializacie smallint not null ,
popis_odboru char(40) not null ,
popis_special char(40),
odbor_eng char(40),
special_eng char(40),
cis_odb char(7),
uziv char(10),
dat_zmen date,
primary key (c_st_odboru,c_specializacie)
);
revoke all on "isfr".st_odbory from "public";
create index "isfr".ix139_1 on "isfr".st_odbory (c_st_odboru);
create index "vajsova".ix169_2 on "isfr".st_odbory (c_specializacie);
{ TABLE "isfr".okres row size = 24 number of columns = 2 index size = 12 }
{ unload file name = okres00128.unl number of rows = 207 }
create table "isfr".okres
(
cisokr char(4) not null ,
nazov char(20) not null ,
primary key (cisokr)
);
revoke all on "isfr".okres from "public";
{ TABLE "isfr".narodnost row size = 22 number of columns = 2 index size = 9 }
{ unload file name = narod00129.unl number of rows = 12 }
create table "isfr".narodnost
(
id smallint,
popis char(20) not null ,
primary key (id)
);
revoke all on "isfr".narodnost from "public";
{ TABLE "isfr".predmet row size = 219 number of columns = 8 index size = 25 }
{ unload file name = predm00130.unl number of rows = 936 }
create table "isfr".predmet
(
cis_predm char(4) not null ,
nazov char(180) not null ,
gestor char(5) not null ,
zrok smallint,
prok smallint,
rrok smallint,
uziv char(20),
dat_zmen date,
primary key (cis_predm)
);
revoke all on "isfr".predmet from "public";
create index "isfr".ix181_4 on "isfr".predmet (gestor);
{ TABLE "isfr".predmet_bod row size = 41 number of columns = 10 index size = 36 }
{ unload file name = predm00131.unl number of rows = 4925 }
create table "isfr".predmet_bod
(
skrok smallint not null ,
cis_predm char(4) not null ,
body smallint not null ,
ects smallint,
forma_kont char(1) not null ,
poc_predn smallint not null ,
poc_cvic smallint not null ,
poc_lab smallint not null ,
uziv char(20),
dat_zmen date,
primary key (cis_predm,skrok)
);
revoke all on "isfr".predmet_bod from "public";
create index "isfr".ix267_1 on "isfr".predmet_bod (skrok);
{ TABLE "isfr".otvorenie row size = 9 number of columns = 4 index size = 31 }
{ unload file name = otvor00132.unl number of rows = 0 }
create table "isfr".otvorenie
(
cis_predm char(4) not null ,
skrok smallint not null ,
pracovisko char(1) not null ,
kapacita smallint,
primary key (cis_predm,skrok,pracovisko)
);
revoke all on "isfr".otvorenie from "public";
{ TABLE "isfr".ucitel_novy row size = 63 number of columns = 8 index size = 25 }
{ unload file name = ucite00133.unl number of rows = 0 }
create table "isfr".ucitel_novy
(
cis_kat char(4) not null ,
os_cis char(5) not null ,
meno char(20) not null ,
priezvisko char(15) not null ,
stav char(1) not null ,
dat_vst date not null ,
dat_zmen date,
uziv char(10),
primary key (os_cis)
);
revoke all on "isfr".ucitel_novy from "public";
{ TABLE "isfr".cis_stp row size = 36 number of columns = 4 index size = 9 }
{ unload file name = cis_s00134.unl number of rows = 6 }
create table "isfr".cis_stp
(
cis_stp smallint not null ,
popis char(30) not null ,
skratka char(2) not null ,
suma smallint,
primary key (cis_stp)
);
revoke all on "isfr".cis_stp from "public";
{ TABLE "isfr".stip row size = 10 number of columns = 4 index size = 36 }
{ unload file name = stip_00135.unl number of rows = 14 }
create table "isfr".stip
(
cis_stp smallint not null ,
os_cislo smallint not null ,
datum date not null ,
suma smallint not null ,
primary key (cis_stp,os_cislo,datum)
);
revoke all on "isfr".stip from "public";
{ TABLE "isfr".param row size = 532 number of columns = 26 index size = 0 }
{ unload file name = param00136.unl number of rows = 2 }
create table "isfr".param
(
skola char(30) not null ,
fakulta char(30) not null ,
skola_eng char(50) not null ,
fakulta_eng char(50) not null ,
miesto char(20),
ulica char(20),
psc char(5),
cisokr char(4),
ciskoly char(4),
ico char(9) not null ,
titul_rp char(15),
rektorm char(20),
rektorp char(20),
titul_rz char(15),
titul_dp char(15),
dekanm char(20),
dekanp char(20),
titul_dz char(15),
telefon char(20),
fax char(20),
email char(50),
www char(50),
skrok smallint not null ,
cis_faklt_ek char(4),
uziv char(20),
dat_zmen date
);
revoke all on "isfr".param from "public";
{ TABLE "isfr".st_program row size = 72 number of columns = 10 index size = 111 }
{ unload file name = st_pr00137.unl number of rows = 2770 }
create table "isfr".st_program
(
skrok smallint not null ,
cis_predm char(4) not null ,
rocnik smallint not null ,
zabezpecuje char(5),
poznamka char(40),
c_st_odboru smallint not null ,
c_specializacie smallint not null ,
semester char(1) not null ,
uziv char(10),
dat_zmen date,
primary key (skrok,rocnik,cis_predm,c_st_odboru,c_specializacie)
);
revoke all on "isfr".st_program from "public";
create index "isfr".sp_sp on "isfr".st_program (skrok,cis_predm);
create index "isfr".sp_sps on "isfr".st_program (skrok,cis_predm,
semester);
create index "isfr".ix198_2 on "isfr".st_program (cis_predm);
create index "isfr".ix198_1 on "isfr".st_program (skrok);
create index "isfr".ix132_6 on "isfr".st_program (c_st_odboru);
create index "isfr".ix184_4 on "isfr".st_program (zabezpecuje);
{ TABLE "isfr".prerusenia row size = 14 number of columns = 5 index size = 27 }
{ unload file name = preru00138.unl number of rows = 52 }
create table "isfr".prerusenia
(
os_cislo smallint not null ,
od date not null ,
do date,
sk_rok smallint not null ,
rocnik smallint,
primary key (os_cislo,od,sk_rok)
);
revoke all on "isfr".prerusenia from "public";
{ TABLE "isfr".pozicky row size = 7 number of columns = 4 index size = 31 }
{ unload file name = pozic00139.unl number of rows = 57 }
create table "isfr".pozicky
(
os_cislo smallint not null ,
sk_rok smallint not null ,
suma smallint not null ,
typ char(1) not null ,
primary key (os_cislo,sk_rok,typ)
);
revoke all on "isfr".pozicky from "public";
create index "isfr".poz_rok on "isfr".pozicky (sk_rok);
{ TABLE "isfr".druh_uvazku row size = 21 number of columns = 3 index size = 9 }
{ unload file name = druh_00140.unl number of rows = 14 }
create table "isfr".druh_uvazku
(
druh smallint not null ,
popis char(15) not null ,
norma smallfloat,
primary key (druh)
);
revoke all on "isfr".druh_uvazku from "public";
{ TABLE "isfr".uvazok row size = 74 number of columns = 13 index size = 150 }
{ unload file name = uvazo00141.unl number of rows = 0 }
create table "isfr".uvazok
(
id serial not null ,
os_cis char(5) not null ,
cis_predm char(4) not null ,
druh smallint not null ,
semester char(1) not null ,
poc_hod smallint,
poc_sk smallint,
skrok smallint not null ,
poznamka varchar(20),
uziv char(20),
dat_zmen date,
poc_tyzd smallint,
stsk char(5),
primary key (id)
);
revoke all on "isfr".uvazok from "public";
create index "isfr".ix206_7 on "isfr".uvazok (skrok);
create index "isfr".uv_spo on "isfr".uvazok (skrok,cis_predm,os_cis);
create index "isfr".ix107_2 on "isfr".uvazok (cis_predm);
create index "isfr".uv_sps on "isfr".uvazok (skrok,cis_predm,semester);
create index "isfr".uv_sp on "isfr".uvazok (skrok,cis_predm);
create unique index "isfr".uv_spod on "isfr".uvazok (skrok,cis_predm,
os_cis,druh);
{ TABLE "isfr".diplomka row size = 860 number of columns = 15 index size = 117 }
{ unload file name = diplo00142.unl number of rows = 744 }
create table "isfr".diplomka
(
rod_cislo char(11) not null ,
iddp integer not null ,
os_cislo smallint not null ,
pracovisko char(1) not null ,
nazov varchar(200) not null ,
anazov varchar(200),
rok_zadania smallint not null ,
popis varchar(255),
veduci char(50) not null ,
cis_katedra char(4) not null ,
tutor char(50),
oponent char(50),
termin_obh date,
uziv char(20),
dat_zmen date,
primary key (iddp,pracovisko,rok_zadania)
);
revoke all on "isfr".diplomka from "public";
create index "isfr".ix165_2 on "isfr".diplomka (iddp);
create index "isfr".ix165_4 on "isfr".diplomka (pracovisko);
create unique index "isfr".i_dipl on "isfr".diplomka (os_cislo,
pracovisko,rok_zadania);
create unique index "isfr".i_dipl2 on "isfr".diplomka (rod_cislo,
pracovisko,rok_zadania);
create index "isfr".ix291_4 on "isfr".diplomka (rok_zadania);
create index "isfr".ix158_1 on "isfr".diplomka (rod_cislo);
{ TABLE "isfr".hist_skupin row size = 36 number of columns = 6 index size = 34 }
{ unload file name = hist_00144.unl number of rows = 2830 }
create table "isfr".hist_skupin
(
os_cislo integer not null ,
skrok smallint not null ,
st_skupina char(5) not null ,
stav char(1) not null ,
uziv char(20),
datum date
);
revoke all on "isfr".hist_skupin from "public";
create index "isfr".ix192_1 on "isfr".hist_skupin (os_cislo);
create index "isfr".ix192_2 on "isfr".hist_skupin (skrok);
create index "isfr".ix192_3 on "isfr".hist_skupin (st_skupina);
{ TABLE "isfr".zp_st_prog row size = 8 number of columns = 3 index size = 18 }
{ unload file name = zp_st00145.unl number of rows = 1539 }
create table "isfr".zp_st_prog
(
skrok smallint not null ,
cis_predm char(4) not null ,
c_st_odboru smallint not null ,
primary key (skrok,cis_predm,c_st_odboru)
);
revoke all on "isfr".zp_st_prog from "public";
{ TABLE "isfr".ldap_st row size = 100 number of columns = 7 index size = 25 }
{ unload file name = ldap_00146.unl number of rows = 1244 }
create table "isfr".ldap_st
(
os_cislo smallint,
login char(8) not null ,
heslo char(30) not null ,
telefon char(40),
stav char(1),
datum date not null ,
uziv char(15) not null
);
revoke all on "isfr".ldap_st from "public";
create unique index "isfr".ldap_st_log on "isfr".ldap_st (login);
create index "isfr".ldap_st_stav on "isfr".ldap_st (stav);
{ TABLE "isfr".ldap_uc row size = 114 number of columns = 8 index size = 25 }
{ unload file name = ldap_00147.unl number of rows = 382 }
create table "isfr".ldap_uc
(
os_cislo char(5),
rod_cislo char(11),
login char(8) not null ,
heslo char(30) not null ,
telefon char(40),
stav char(1),
datum date not null ,
uziv char(15) not null
);
revoke all on "isfr".ldap_uc from "public";
create unique index "isfr".ldap_uc_log on "isfr".ldap_uc (login);
create index "isfr".ldap_uc_stav on "isfr".ldap_uc (stav);
{ TABLE "vajsova".abeceda row size = 5 number of columns = 2 index size = 12 }
{ unload file name = abece00152.unl number of rows = 7803 }
create table "vajsova".abeceda
(
id serial not null ,
pismeno char(1) not null
);
revoke all on "vajsova".abeceda from "public";
create unique index "vajsova".ix152_1 on "vajsova".abeceda (id);
{ TABLE "vajsova".ldap_serv row size = 136 number of columns = 8 index size = 0 }
{ unload file name = ldap_00153.unl number of rows = 1291 }
create table "vajsova".ldap_serv
(
uid char(8),
userpassword char(20),
uidnumber integer,
gindnumber integer,
surname char(20),
givenname char(30),
telephonenumnber char(20),
ou char(30)
);
revoke all on "vajsova".ldap_serv from "public";
{ TABLE "vajsova".tab1 row size = 8 number of columns = 1 index size = 0 }
{ unload file name = tab1_00154.unl number of rows = 1 }
create table "vajsova".tab1
(
id char(8)
);
revoke all on "vajsova".tab1 from "public";
{ TABLE "isfr".prerekvizity row size = 12 number of columns = 4 index size = 78 }
{ unload file name = prere00157.unl number of rows = 940 }
create table "isfr".prerekvizity
(
co char(4) not null constraint "isfr".n143_153,
od_coho char(4) not null constraint "isfr".n143_154,
skrok smallint not null constraint "isfr".n143_155,
mnozina smallint not null ,
primary key (co,od_coho,skrok,mnozina) constraint "isfr".u143_152
);
revoke all on "isfr".prerekvizity from "public";
create index "isfr".prop1 on "isfr".prerekvizity (skrok);
create index "isfr".prop2 on "isfr".prerekvizity (co,mnozina);
create index "isfr".prop3 on "isfr".prerekvizity (skrok,co,mnozina);
{ TABLE "isfr".zp2 row size = 66 number of columns = 16 index size = 75 }
{ unload file name = zp2__00159.unl number of rows = 1895 }
create table "isfr".zp2
(
os_cislo smallint not null ,
cis_predm char(4) not null ,
vysledok smallint,
datum_sk date,
termin smallint,
zapocet date,
skrok smallint not null ,
body smallint,
ects smallint,
prednasajuci char(5),
skusajuci char(5),
cviciaci char(5),
miesto char(1),
c_st_odboru smallint,
uziv char(20),
dat_zmen date,
primary key (os_cislo,cis_predm,skrok)
);
revoke all on "isfr".zp2 from "public";
create index "sicova".zp2_cp on "isfr".zp2 (cis_predm);
create index "isfr".zp2_skrok on "isfr".zp2 (skrok);
create index "isfr".zp2_odb on "isfr".zp2 (c_st_odboru);
{ TABLE "isfr".poc_st row size = 6 number of columns = 2 index size = 12 }
{ unload file name = poc_s00160.unl number of rows = 52 }
create table "isfr".poc_st
(
pocet smallint,
datum date,
primary key (datum)
);
revoke all on "isfr".poc_st from "public";
{ TABLE "isfr".student_iny row size = 157 number of columns = 10 index size = 22
}
{ unload file name = stude00165.unl number of rows = 44 }
create table "isfr".student_iny
(
os_cislo smallint not null ,
meno char(30),
priezvisko char(30) not null ,
rocnik smallint not null ,
st_skupina char(5) not null ,
specializacia char(30),
odbor char(30),
ukoncenie date,
uziv char(20),
dat_zmen date,
primary key (os_cislo)
);
revoke all on "isfr".student_iny from "public";
create index "isfr".st_iny on "isfr".student_iny (st_skupina);
{ TABLE "isfr".student row size = 97 number of columns = 27 index size = 66 }
{ unload file name = stude00169.unl number of rows = 4983 }
create table "isfr".student
(
os_cislo smallint not null constraint "isfr".n127_66,
rod_cislo char(11) not null constraint "isfr".n127_67,
rocnik smallint not null constraint "isfr".n127_68,
opakovanie char(1),
st_skupina char(5) not null constraint "isfr".n127_69,
st_sk_old char(5),
prerusenie char(1),
dat_prv_zap date,
prdp_zam smallint,
c_specializacie smallint not null constraint "isfr".n127_70,
c_st_odboru smallint not null constraint "isfr".n127_71,
ukoncenie date,
pozicka smallint,
soc_stipko datetime year to year,
stipko smallint,
bakalar char(1),
bc_datum date,
datumop date,
datumpr date,
ziadost char(1),
forma char(1) not null constraint "isfr".n127_72,
rocnikop smallint,
skrok_op smallint,
stsk char(5),
stav char(1) not null constraint "isfr".n127_73,
uziv char(20),
dat_zmen date,
primary key (os_cislo) constraint "isfr".u127_65
);
revoke all on "isfr".student from "public";
create index "isfr".ix160_6 on "isfr".student (st_skupina);
create index "isfr".ix121_10 on "isfr".student (c_st_odboru);
{ TABLE "isfr".ucitel_iny row size = 131 number of columns = 11 index size = 64 }
{ unload file name = ucite00173.unl number of rows = 3 }
create table "isfr".ucitel_iny
(
os_cis char(5) not null ,
meno char(25) not null ,
titul char(15),
ped_hod char(8),
tel_p char(11),
pr_kat smallint,
fakulta char(15) not null ,
katedra char(25) not null ,
stav char(1),
uziv char(20),
dat_zmen date
);
revoke all on "isfr".ucitel_iny from "public";
create unique index "isfr".uc_i_oc on "isfr".ucitel_iny (os_cis);
create index "isfr".uc_i_m on "isfr".ucitel_iny (meno);
create index "vajsova".uc_i_s on "isfr".ucitel_iny (stav);
alter table "isfr".ucitel_iny add constraint primary key (os_cis)
constraint "isfr".uc_i_pk ;
alter table "isfr".stip add constraint (foreign key (cis_stp)
references "isfr".cis_stp );
alter table "isfr".stip add constraint (foreign key (os_cislo)
references "isfr".student );
alter table "isfr".uvazok add constraint (foreign key (cis_predm,
skrok) references "isfr".predmet_bod );
alter table "isfr".uvazok add constraint (foreign key (os_cis)
references "isfr".ucitel_novy );
alter table "isfr".uvazok add constraint (foreign key (druh)
references "isfr".druh_uvazku );
alter table "isfr".student add constraint (foreign key (rod_cislo)
references "isfr".os_udaje constraint "isfr".r127_178);
alter table "isfr".student add constraint (foreign key (c_st_odboru,
c_specializacie) references "isfr".st_odbory constraint "isfr"
.r127_179);
alter table "isfr".st_program add constraint (foreign key (c_st_odboru,
c_specializacie) references "isfr".st_odbory );
alter table "isfr".predmet_bod add constraint (foreign key (cis_predm)
references "isfr".predmet );
alter table "isfr".os_udaje add constraint (foreign key (narodnost)
references "isfr".narodnost );
alter table "isfr".predmet_eng add constraint (foreign key (cis_predm)
references "isfr".predmet );
alter table "isfr".pozicky add constraint (foreign key (os_cislo)
references "isfr".student );
alter table "isfr".diplomka add constraint (foreign key (os_cislo)
references "isfr".student );
alter table "isfr".prerusenia add constraint (foreign key (os_cislo)
references "isfr".student );
alter table "isfr".ucitel add constraint (foreign key (pr_kat)
references "isfr".profesia );
alter table "isfr".otvorenie add constraint (foreign key (cis_predm,
skrok) references "isfr".predmet_bod );
alter table "isfr".prerekvizity add constraint (foreign key (od_coho)
references "isfr".predmet constraint "isfr".r143_189);
alter table "isfr".ucitel_novy add constraint (foreign key (os_cis)
references "isfr".ucitel );
alter table "isfr".ucitel_novy add constraint (foreign key (cis_kat)
references "isfr".katedra );
alter table "isfr".bod_limit add constraint (foreign key (c_st_odboru,
c_specializacie) references "isfr".st_odbory );
alter table "isfr".zap_predmety add constraint (foreign key (os_cislo)
references "isfr".student );
alter table "isfr".st_program add constraint (foreign key (zabezpecuje)
references "isfr".ucitel_novy );
alter table "isfr".zap_predmety add constraint (foreign key (skrok,
cis_predm,c_st_odboru) references "isfr".zp_st_prog );
alter table "isfr".diplomka add constraint (foreign key (rod_cislo)
references "isfr".os_udaje );
alter table "isfr".zp2 add constraint (foreign key (os_cislo)
references "isfr".student );
alter table "isfr".zp2 add constraint (foreign key (skrok,cis_predm,
c_st_odboru) references "isfr".zp_st_prog );
grant select on "isfr".ucitel_pr to "oweis" as "isfr";
grant select on "isfr".ucitel_pr to "sleziak" as "isfr";
grant select on "isfr".ucitel to "mano" as "isfr";
grant select on "isfr".ucitel to "oweis" as "isfr";
grant select on "isfr".ucitel to "sleziak" as "isfr";
grant select on "isfr".sysmenus to "jamrich" as "isfr";
grant select on "isfr".sysmenus to "novakova" as "isfr";
grant select on "isfr".sysmenus to "oweis" as "isfr";
grant select on "isfr".sysmenus to "sicova" as "isfr";
grant select on "isfr".sysmenus to "sleziak" as "isfr";
grant select on "isfr".sysmenuitems to "jamrich" as "isfr";
grant select on "isfr".sysmenuitems to "novakova" as "isfr";
grant select on "isfr".sysmenuitems to "oweis" as "isfr";
grant select on "isfr".sysmenuitems to "sicova" as "isfr";
grant select on "isfr".sysmenuitems to "sleziak" as "isfr";
grant select on "isfr".profesia to "public" as "isfr";
grant update on "isfr".profesia to "public" as "isfr";
grant insert on "isfr".profesia to "public" as "isfr";
grant delete on "isfr".profesia to "public" as "isfr";
grant index on "isfr".profesia to "public" as "isfr";
grant select on "isfr".os_udaje to "mano" as "isfr";
grant select on "isfr".os_udaje to "oweis" as "isfr";
grant select on "isfr".zap_predmety to "mano" as "isfr";
grant select on "isfr".zap_predmety to "oweis" as "isfr";
grant select on "isfr".st_odbory to "oweis" as "isfr";
grant select on "isfr".student to "mano" as "isfr";
grant select on "isfr".student to "oweis" as "isfr";
grant select on "isfr".okres to "oweis" as "isfr";
grant select on "isfr".predmet to "mano" as "isfr";
grant select on "isfr".predmet to "oweis" as "isfr";
grant select on "isfr".predmet_bod to "oweis" as "isfr";
grant select on "isfr".otvorenie to "public" as "isfr";
grant update on "isfr".otvorenie to "public" as "isfr";
grant insert on "isfr".otvorenie to "public" as "isfr";
grant delete on "isfr".otvorenie to "public" as "isfr";
grant index on "isfr".otvorenie to "public" as "isfr";
grant select on "isfr".ucitel_novy to "public" as "isfr";
grant update on "isfr".ucitel_novy to "public" as "isfr";
grant insert on "isfr".ucitel_novy to "public" as "isfr";
grant delete on "isfr".ucitel_novy to "public" as "isfr";
grant index on "isfr".ucitel_novy to "public" as "isfr";
grant select on "isfr".prerusenia to "oweis" as "isfr";
grant select on "isfr".pozicky to "oweis" as "isfr";
grant select on "isfr".zp2 to "public" as "isfr";
grant update on "isfr".zp2 to "public" as "isfr";
grant insert on "isfr".zp2 to "public" as "isfr";
grant delete on "isfr".zp2 to "public" as "isfr";
grant index on "isfr".zp2 to "public" as "isfr";
grant select on "isfr".hist_skupin to "public" as "isfr";
grant update on "isfr".hist_skupin to "public" as "isfr";
grant insert on "isfr".hist_skupin to "public" as "isfr";
grant delete on "isfr".hist_skupin to "public" as "isfr";
grant index on "isfr".hist_skupin to "public" as "isfr";
grant select on "isfr".zp_st_prog to "public" as "isfr";
grant update on "isfr".zp_st_prog to "public" as "isfr";
grant insert on "isfr".zp_st_prog to "public" as "isfr";
grant delete on "isfr".zp_st_prog to "public" as "isfr";
grant index on "isfr".zp_st_prog to "public" as "isfr";
grant select on "isfr".ldap_st to "public" as "isfr";
grant update on "isfr".ldap_st to "public" as "isfr";
grant insert on "isfr".ldap_st to "public" as "isfr";
grant delete on "isfr".ldap_st to "public" as "isfr";
grant index on "isfr".ldap_st to "public" as "isfr";
grant select on "isfr".ldap_uc to "public" as "isfr";
grant update on "isfr".ldap_uc to "public" as "isfr";
grant insert on "isfr".ldap_uc to "public" as "isfr";
grant delete on "isfr".ldap_uc to "public" as "isfr";
grant index on "isfr".ldap_uc to "public" as "isfr";
grant select on "vajsova".abeceda to "public" as "vajsova";
grant update on "vajsova".abeceda to "public" as "vajsova";
grant insert on "vajsova".abeceda to "public" as "vajsova";
grant delete on "vajsova".abeceda to "public" as "vajsova";
grant index on "vajsova".abeceda to "public" as "vajsova";
grant select on "vajsova".ldap_serv to "public" as "vajsova";
grant update on "vajsova".ldap_serv to "public" as "vajsova";
grant insert on "vajsova".ldap_serv to "public" as "vajsova";
grant delete on "vajsova".ldap_serv to "public" as "vajsova";
grant index on "vajsova".ldap_serv to "public" as "vajsova";
grant select on "vajsova".tab1 to "public" as "vajsova";
grant update on "vajsova".tab1 to "public" as "vajsova";
grant insert on "vajsova".tab1 to "public" as "vajsova";
grant delete on "vajsova".tab1 to "public" as "vajsova";
grant index on "vajsova".tab1 to "public" as "vajsova";
grant select on "isfr".poc_st to "public" as "isfr";
grant update on "isfr".poc_st to "public" as "isfr";
grant insert on "isfr".poc_st to "public" as "isfr";
grant delete on "isfr".poc_st to "public" as "isfr";
grant index on "isfr".poc_st to "public" as "isfr";
grant select on "isfr".student_iny to "public" as "isfr";
grant update on "isfr".student_iny to "public" as "isfr";
grant insert on "isfr".student_iny to "public" as "isfr";
grant delete on "isfr".student_iny to "public" as "isfr";
grant index on "isfr".student_iny to "public" as "isfr";
grant select on "isfr".ucitel_iny to "public" as "isfr";
grant update on "isfr".ucitel_iny to "public" as "isfr";
grant insert on "isfr".ucitel_iny to "public" as "isfr";
grant delete on "isfr".ucitel_iny to "public" as "isfr";
grant index on "isfr".ucitel_iny to "public" as "isfr";
create procedure "vajsova".instr(kde char(100), co char(1))
returning int;
define i,j,n int;
let n = length(kde);
let i = 1;
while (substr(kde,i,1) <> co) and (i<n)
let i= i+1;
end while;
if (substr(kde,i,1) =co) then
let j=i;
else let j=0;
end if;
return j;
end procedure;
create procedure "vajsova".heslo(login char(8), dlzka int)
returning char(20);
define i,j,n int;
define p_heslo char(20);
define c char(1);
let p_heslo='a';
let j=-1;
for i = 1 to dlzka
select min(id) into j from abeceda;
select pismeno into c from abeceda
where id = j;
let p_heslo = substr(p_heslo,1,i-1)||c;
-- update abeceda
-- set pismeno=substr(login,i,1)
-- where id = j;
-- delete from abeceda
-- where id = j;
end for;
for i = 1 to length(login)
let c = substr(login,i,1);
-- insert into abeceda(pismeno) values('c');
-- insert into abeceda values (0,i);
end for;
return p_heslo;
end procedure;
grant execute on "vajsova".instr to "public" as "vajsova";
grant execute on "vajsova".heslo to "public" as "vajsova";
create view "isfr".skuska (cis_kat) as
select x0.cis_kat from "isfr".katedra x0 ;
create view "isfr".w_sekret (cis_kat,sek) as
select x0.cis_kat ,x1.meno from "isfr".katedra x0 ,"isfr".ucitel
x1 where (x0.sekrt_kat = x1.os_cis ) ;
create view "isfr".w_veduci (cis_kat,ved) as
select x0.cis_kat ,x1.meno from "isfr".katedra x0 ,"isfr".ucitel
x1 where (x0.ved_kat = x1.os_cis ) ;
create view "isfr".w_zastupca (cis_kat,zas) as
select x0.cis_kat ,x1.meno from "isfr".katedra x0 ,"isfr".ucitel
x1 where (x0.z_ved_kat = x1.os_cis ) ;
create view "isfr".ldap_login (login) as
select x0.login from "isfr".ldap_st x0 union select x1.login
from "isfr".ldap_uc x1 ;
create view "isfr".ldap_serv_st (uid,userpassword,uidnumber,gindnumber,surname,givenname,telephonenumnber,ou) as
select x0.uid ,x0.userpassword ,x0.uidnumber ,x0.gindnumber
,x0.surname ,x0.givenname ,x0.telephonenumnber ,x0.ou from
"vajsova".ldap_serv x0 where (x0.gindnumber = 14005 ) ;
| true |
9423f65ae2eedbb37ca2d623cb38d4c25198c74a | SQL | beea27/klinik | /baseDados_N2.sql | UTF-8 | 4,944 | 3.15625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.7.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: 15-Jun-2020 às 02:06
-- Versão do servidor: 10.1.25-MariaDB
-- PHP Version: 7.1.7
CREATE DATABASE n2;
USE n2;
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: `n2`
--
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_consulta`
--
CREATE TABLE `tb_consulta` (
`id` int(11) NOT NULL,
`crm` varchar(20) COLLATE utf8_bin NOT NULL,
`cpf_paciente` varchar(14) COLLATE utf8_bin NOT NULL,
`data_consulta` date NOT NULL,
`horario` time NOT NULL,
`diagnostico` varchar(500) COLLATE utf8_bin DEFAULT NULL,
`tratamento` varchar(500) COLLATE utf8_bin DEFAULT NULL,
`exames` varchar(500) COLLATE utf8_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Extraindo dados da tabela `tb_consulta`
--
INSERT INTO `tb_consulta` (`id`, `crm`, `cpf_paciente`, `data_consulta`, `horario`, `diagnostico`, `tratamento`, `exames`) VALUES
(2, '12444343434', '43815861829', '2020-06-15', '00:23:10', 'O paciente está com virose.', 'Se hidratar, dramim e buscopan.', 'Solicitação de um exame de sangue');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_medico`
--
CREATE TABLE `tb_medico` (
`crm` varchar(20) COLLATE utf8_bin NOT NULL,
`nome_m` varchar(200) COLLATE utf8_bin NOT NULL,
`cpf` varchar(14) COLLATE utf8_bin NOT NULL,
`dt_nasc` date NOT NULL,
`nacionalidade` varchar(100) COLLATE utf8_bin NOT NULL,
`especialidade` varchar(100) COLLATE utf8_bin NOT NULL,
`celular` varchar(15) COLLATE utf8_bin NOT NULL,
`email` varchar(50) COLLATE utf8_bin NOT NULL,
`senha` varchar(30) COLLATE utf8_bin NOT NULL,
`cep` varchar(14) COLLATE utf8_bin NOT NULL,
`logradouro` varchar(100) COLLATE utf8_bin NOT NULL,
`numero` varchar(10) COLLATE utf8_bin NOT NULL,
`bairro` varchar(100) COLLATE utf8_bin NOT NULL,
`cidade` varchar(100) COLLATE utf8_bin NOT NULL,
`estado` varchar(50) COLLATE utf8_bin NOT NULL,
`complemento` varchar(100) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Extraindo dados da tabela `tb_medico`
--
INSERT INTO `tb_medico` (`crm`, `nome_m`, `cpf`, `dt_nasc`, `nacionalidade`, `especialidade`, `celular`, `email`, `senha`, `cep`, `logradouro`, `numero`, `bairro`, `cidade`, `estado`, `complemento`) VALUES
('12444343434', 'Fulano de Sicrano', '43815861829', '1998-11-02', 'Brasileiro', 'Clinico Geral', '11988888888', 'teste@gmail.com', '123', '05590-000', 'Rua Pereira do Lago', '24', 'Vila Gomes', 'São Paulo', 'SP', '432');
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_paciente`
--
CREATE TABLE `tb_paciente` (
`cpf` varchar(14) COLLATE utf8_bin NOT NULL,
`nome` varchar(100) COLLATE utf8_bin NOT NULL,
`dt_nasc` date NOT NULL,
`sexo` varchar(10) COLLATE utf8_bin NOT NULL,
`celular` varchar(15) COLLATE utf8_bin NOT NULL,
`email` varchar(50) COLLATE utf8_bin NOT NULL,
`convenio` varchar(100) COLLATE utf8_bin NOT NULL,
`cep` varchar(14) COLLATE utf8_bin NOT NULL,
`logradouro` varchar(100) COLLATE utf8_bin NOT NULL,
`numero` varchar(10) COLLATE utf8_bin NOT NULL,
`bairro` varchar(100) COLLATE utf8_bin NOT NULL,
`cidade` varchar(100) COLLATE utf8_bin NOT NULL,
`estado` varchar(100) COLLATE utf8_bin NOT NULL,
`complemento` varchar(100) COLLATE utf8_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Extraindo dados da tabela `tb_paciente`
--
INSERT INTO `tb_paciente` (`cpf`, `nome`, `dt_nasc`, `sexo`, `celular`, `email`, `convenio`, `cep`, `logradouro`, `numero`, `bairro`, `cidade`, `estado`, `complemento`) VALUES
('23667569840', 'Lidiaaaaaaaa', '2020-02-01', 'Feminino', '11988888888', 'teste@teste.com', 'Bradesco', '12233250', 'Rua Galiléia', '2213', 'Bosque dos Eucaliptos', 'São José dos Campos', 'SP', 'teste');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tb_consulta`
--
ALTER TABLE `tb_consulta`
ADD PRIMARY KEY (`id`) KEY_BLOCK_SIZE=10;
--
-- Indexes for table `tb_medico`
--
ALTER TABLE `tb_medico`
ADD PRIMARY KEY (`crm`);
--
-- Indexes for table `tb_paciente`
--
ALTER TABLE `tb_paciente`
ADD PRIMARY KEY (`cpf`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `tb_consulta`
--
ALTER TABLE `tb_consulta`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;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 |
54cdcf8096cdf49eef522e2adeede311b39ef5e5 | SQL | ScarlettUtopia/sql-crowdfunding-lab-seattle-web-082619 | /lib/insert.sql | UTF-8 | 1,734 | 2.875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | INSERT INTO users (id, name, age) VALUES
(1, "Joe", 28),
(2, "Sue", 47),
(3, "Mary", 39),
(4, "Luke", 35),
(5, "Alex", 37),
(6, "Gary", 52),
(7, "Peggy", 54),
(8, "Ben", 31),
(9, "Drew", 25),
(10, "Leah", 37),
(11, "June", 41),
(12, "Cale", 38),
(13, "Kate", 36),
(14, "Mae", 51),
(15, "Sally", 53),
(16, "Peter", 43),
(17, "Kyle", 24),
(18, "Iris", 41),
(19, "Jim", 49),
(20, "Rena", 53);
INSERT INTO projects (id, title, category,
funding_goal, start_date, end_date) VALUES
(1, "Amri School", "Education", 50000, 06/19, 06/20),
(2, "Tears Foundation", "Loss and Grief Support", 100000, 05/19, 05/20),
(3, "Oblideride", "Medical", 5000, 07/19, 08/19),
(4, "St Jude", "Medical", 10000, 06/19, 12/19),
(5, "Endangered Speceis", "Wildlife", 500000, 03/19, 11/19),
(6, "Boys & Girls Club", "Community", 20000, 09/19, 12/19),
(7, "TP Forever", "Community and Education", 70000, 04/19, 10/19),
(8, "Local Markets", "Community", 8000, 10/19, 11/19),
(9, "Personal", "Personal", 3000, 09/19, 10/19),
(10, "Humane Society", "Pets and Animals", 30000, 07/19, 12/19);
INSERT INTO pledges (id, amount, user_id, project_id) VALUES
(1, 500.00, 4, 2),
(2, 800.00, 3, 8),
(3, 1000.00, 1, 3),
(4, 20000.00, 8, 2),
(5, 3000.00, 6, 7),
(6, 400.00, 5, 9),
(7, 5000.00, 20, 10),
(8, 300.00, 19, 9),
(9, 700.00, 18, 6),
(10, 200.00, 17, 5),
(11, 100.00, 16, 4),
(12, 50.00, 15, 1),
(13, 300.00, 14, 7),
(14, 400.00, 13, 5),
(15, 600.00, 12, 6),
(16, 900.00, 11, 4),
(17, 300.00, 10, 5),
(18, 100.00, 9, 3),
(19, 400.00, 8, 2),
(20, 100.00, 7, 3),
(21, 200.00, 6, 9),
(22, 500.00, 5, 10),
(23, 100.00, 4, 6),
(24, 300.00, 3, 1),
(25, 1000.00, 20, 5),
(26, 700.00, 18, 8),
(27, 200.00, 16, 4),
(28, 30.00, 14, 9),
(29, 100.00, 17, 2),
(30, 300.00, 12, 5); | true |
f304d8460429827d1873c3fb1791efc4a30e998b | SQL | CarolSi-hub/Trybe-MySQLVocabulary-Booster | /desafio16.sql | UTF-8 | 340 | 3.609375 | 4 | [] | no_license | DELIMITER $$
CREATE FUNCTION buscar_quantidade_de_empregos_por_funcionario(email VARCHAR(50))
RETURNS INT READS SQL DATA
BEGIN
DECLARE qnt_jobs INT;
SELECT COUNT(*)
FROM hr.employees AS emp
INNER JOIN hr.job_history AS jobH
ON emp.EMPLOYEE_ID = jobH.EMPLOYEE_ID
WHERE emp.EMAIL = email INTO qnt_jobs;
RETURN qnt_jobs;
END $$
DELIMITER ;
| true |
65fe529b13c011bb9ba329641c0d2e9163ff8427 | SQL | FelipeCooper/CNC_Internal_API | /src/repository/DB/sql/setores_membros.sql | UTF-8 | 4,525 | 2.703125 | 3 | [] | no_license | CREATE TABLE
IF NOT EXISTS setores_membros
(
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
setor_id INT UNSIGNED NOT NULL,
email VARCHAR
(255) NOT NULL,
nome VARCHAR
(80) NOT NULL
) ENGINE = InnoDB;
INSERT INTO setores_membros
(id, setor_id, email, nome)
VALUES
(1, 6 , "gerente.vendas@grupoembracon.com.br", "Agnes Chaves"),
(2, 6 , "coord.vendas@grupoembracon.com.br", "Marcelo Pinto"),
(3, 6 , "suporte.comercial1@grupoembracon.com.br", "Jefter"),
(4, 6 , "suporte.comercial3@grupoembracon.com.br", "Caroline da Silveira"),
(5, 6 , "suporte.comercial@grupoembracon.com.br", "Maria Eduarda"),
(6, 6 , "prevendas3@grupoembracon.com.br", "Lais"),
(7, 6 , "prevendas2@grupoembracon.com.br", "Sabrina Macedo"),
(8, 7, "gerente.consultoria@grupoembracon.com.br", "Sabrina Vieira"),
(9, 7, "consultor.campo2@grupoembracon.com.br", "Jesael "),
(10, 7, "consultor.campo3@grupoembracon.com.br", "Elisabeth" ),
(11, 7, "estagiario1.consultoria@grupoembracon.com.br", "Marcos Felipe " ),
(12, 7, "cs@grupoembracon.com.br", "Camila" ),
(13, 7, "estagiario.consultoria@grupoembracon.com.br", "Vinicius Longen" ),
(14, 12, "imoveis3@grupoembracon.com.br", "Leticia Pereira" ),
(15, 12, "imoveis4@grupoembracon.com.br", "Fabiano" ),
(16, 12, "imoveis2@grupoembracon.com.br", "Jaqueline" ),
(17, 1, "maria@grupoembracon.com.br", "Duda (correta)" ),
(18, 1, "coord.apoioadm@grupoembracon.com.br", "Tarcila Dorn" ),
(19, 1, "condominio56@grupoembracon.com.br", "Vanessa Brad" ),
(20, 1, "condominio59@grupoembracon.com.br", "Thais " ),
(21, 1, "condominio25@grupoembracon.com.br", "Alice " ),
(22, 1, "condominio37@grupoembracon.com.br", "Beatriz Araujo" ),
(23, 1, "condominio55@grupoembracon.com.br", "Pauline" ),
(24, 1, "condominio45@grupoembracon.com.br", "Gislaine" ),
(25, 1, "condominio21@grupoembracon.com.br", "Jessica Eduarda da Silva" ),
(27, 1, "condominio53@grupoembracon.com.br", "Joana" ),
(29, 1, "condominio44@grupoembracon.com.br", "Priscila Pinto da Silva" ),
(30, 1, "condominio28@grupoembracon.com.br", "Érica Sales" ),
(31, 1, "condominio57@grupoembracon.com.br", "Fernanda" ),
(32, 1, "condominio51@grupoembracon.com.br", "Solange" ),
(33, 1, "condominio56@grupoembracon.com.br", "Kécila" ),
(26, 4, "estagiariobalancete12@grupoembracon.com.br", "Ana Caroline dos Santos" ),
(28, 4, "condominio34@grupoembracon.com.br", "André Ferreira" ),
(34, 4, "condominio22@grupoembracon.com.br", "Andréia Martens" ),
(35, 4, "condominio61@grupoembracon.com.br", "Andreza Antunes" ),
(36, 4, "condominio60@grupoembracon.com.br", "Beatriz Silveira" ),
(37, 4, "condominio12@grupoembracon.com.br", "Caroline Duarte" ),
(38, 4, "condominio17@grupoembracon.com.br", "Cristiani Morais" ),
(39, 4, "estagiariobalancete2@grupoembracon.com.br", "Debora Maia" ),
(40, 4, "estagiariobalancete8@grupoembracon.com.br", "Filipe Rospide" ),
(41, 4, "estagiariobalancete9@grupoembracon.com.br", "Gabriel Spricigo" ),
(42, 4, "estagiariobalancete3@grupoembracon.com.br", "Gabriela Porto" ),
(43, 4, "coord.balancete@grupoembracon.com.br", "Gabriela Rosa" ),
(44, 4, "condominio4@grupoembracon.com.br", "Gabrielle Martins" ),
(45, 4, "estagiariobalancete5@grupoembracon.com.br", "Gabriely Aparecida" ),
(46, 4, "condominio64@grupoembracon.com.br", "Guilherme Evandro" ),
(47, 4, "estagiariobalancete10@grupoembracon.com.br", "Helen de Faria" ),
(48, 4, "condominio10@grupoembracon.com.br", "Jaqueline Santos" ),
(49, 4, "condominio65@grupoembracon.com.br", "João Felipe Silveira" ),
(50, 4, "estagiariobalancete6@grupoembracon.com.br", "Julia Dutra" ),
(51, 4, "condominio32@grupoembracon.com.br", "Karine da Luz" ),
(52, 4, "condominio43@grupoembracon.com.br", "Kenya Rosa" ),
(53, 4, "condominio14@grupoembracon.com.br", "Leticia Anselmo" ),
(54, 4, "condominio20@grupoembracon.com.br", "Leticia Eli " ),
(55, 4, "condominio66@grupoembracon.com.br", "Maria Eduarda da Silva (correta)" ),
(56, 4, "condominio63@grupoembracon.com.br", "Nathani Silva (correta)" ),
(57, 4, "estagiariobalancete4@grupoembracon.com.br", "Otavio Fontes" ),
(58, 4, "estagiariobalancete7@grupoembracon.com.br", "Samuel Telam" ),
(59, 4, "coord.conciliacao@grupoembracon.com.br", "Sandra Wolfart" ),
(60, 3, "condominio30@grupoembracon.com.br", "Pamela Rezini" ),
(61, 3, "condominio18@grupoembracon.com.br", "Renata Otacilio" ),
(62, 3, "condominio33@grupoembracon.com.br", "Jessyka Costa" ),
(63, 3, "condominio39@grupoembracon.com.br", "Felippe Nunes" ),
(64, 3, "coord.baixas@grupoembracon.com.br", "Gabriela Westphal" ),
(65, 3, "condominio58@grupoembracon.com.br", "Janir Pereira" ),
(66, 8, "pessoal8@grupoembracon.com.br", "Caroline Espindola " ),
(67, 8, "pessoal7@grupoembracon.com.br", "Barbara Sangaletti" ),
(68, 8, "pessoal1@grupoembracon.com.br", "Mariana (correta) " ),
(69, 8, "pessoal10@grupoembracon.com.br", "Chaiany" ),
(70, 8, "pessoal14@grupoembracon.com.br", "Amanda Hessmann" ),
(71, 8, "coord.pessoal@grupoembracon.com.br", "Deise Seara" ),
(72, 8, "dpoperacional5@grupoembracon.com.br", "Juliana Konig" ),
(73, 8, "dpoperacional2@grupoembracon.com.br", "Bianca de Souza" ),
(74, 8, "dpoperacional4@grupoembracon.com.br", "Margarete " ),
(75, 8, "pessoal2@grupoembracon.com.br", "Marinete " ),
(76, 8, "pessoal4@grupoembracon.com.br", "Fernanda Rocha" ),
(77, 8, "pessoal5@grupoembracon.com.br", "Nicolly " ),
(78, 8, "pessoal3@grupoembracon.com.br", "Patricia Bonetti " ),
(79, 8, "pessoal12@grupoembracon.com.br", "Pyetro" ),
(80, 8, "pessoal15@grupoembracon.com.br", "Giovanna Pagnan" ),
(81, 8, "pessoal9@grupoembracon.com.br", "Kethelym Mantovani" ),
(82, 8, "Pessoal11@grupoembracon.com.br", "Tatiane Araujo" ),
(83, 9, "gerente.financeiro@grupoembracon.com.br" , "Barbara Souza" ),
(84, 9, "coord.financeiro@grupoembracon.com.br" , "Aline Alves" ),
(85, 9, "financeiro4@grupoembracon.com.br" , "Ana Carolina da Silva " ),
(86, 9, "financeiro5@grupoembracon.com.br" , "Ralf Salvador" ),
(87, 9, "financeiro17@grupoembracon.com.br" , "Bianca Machado" ),
(88, 9, "financeiro20@grupoembracon.com.br" , "Caroline Azambuja" ),
(89, 9, "coord.financeiroflex@flexsa.com.br" , "Laiane Nikitenko" ),
(90, 9, "estagiario1@flexsa.com.br" , "Mariane Flores" ),
(91, 9, "financeiro9@grupoembracon.com.br" , "Juliana Kellen" ),
(92, 9, "financeiro1@grupoembracon.com.br" , "Annelise Andrade" ),
(93, 9, "financeiro3@grupoembracon.com.br" , "Priscila Teles" ),
(94, 9, "financeiro11@grupoembracon.com.br" , "Giseli Salomon" ),
(95, 9, "financeiro12@grupoembracon.com.br" , "Patricia Domingos" ),
(96, 9, "financeiro14@grupoembracon.com.br" , "Thayane Schutz" ),
(97, 9, "financeiro21@grupoembracon.com.br" , "Kelly Cristina Oliveira" ),
(98, 9, "gestaofinanceira@grupoembracon.com.br" , "Thalya Pavlack" ),
(99 ,10, "coord.flex@flexsa.com.br", "Godoy" ),
(100,10, "juridico2@grupoembracon.com.br", "Laryssa Oliveira" ),
(101,10, "rodrigo@grupoembracon.com.br", "Rodrigo" ),
(102,10, "juridico4@grupoembracon.com.br", "Scharlayne" ),
(103,10, "juridico3@grupoembracon.com.br", "Fiama" ),
(104, 14, "coord.societario@grupoembracon.com.br", "Ana Paula Duarte" ),
(105, 14, "societario2@grupoembracon.com.br", "Marcos Ouriques" ),
(106, 13, "gerente.rh@grupoembracon.com.br", "Andreia Ferreira" ),
(107, 13, "rh4@grupoembracon.com.br", "Tayna Passos" ),
(108, 13, "rh1@grupoembracon.com.br", "Daniela Brusda" ),
(109, 13, "rh3@grupoembracon.com.br", "Natália Alves" ),
(110, 13, "rh6@grupoembracon.com.br", "Gustavo Sens" ),
(111, 13, "rh5@grupoembracon.com.br", "Josefa Sanaélia" ),
(112, 13, "rh2@grupoembracon.com.br", "Tassia Amanda" ),
(113, 13, "vivabem2@grupoembracon.com.br", "Natalia Tivis" ),
(114, 13, "vivabem1@grupoembracon.com.br", "Gabriel Sens" ),
(115, 2, "operacional2@grupoembracon.com.br","Fernanda Irene" ),
(116, 2, "gerente.operacional@grupoembracon.com.br","Osvalcir Feliciano" ),
(117, 2, "operacional3@grupoembracon.com.br","Jessica Teixeira" ),
(118, 2, "operacional1@grupoembracon.com.br","Marcela Munoz" ),
(119, 2, "gerente.administrativo@grupoembracon.com.br","Rosi" ),
(120, 2, "administrativo1@grupoembracon.com.br","Diogo" ),
(121, 2, "administrativo2@grupoembracon.com.br","Bruna (correta) " ),
(122, 2, "coord.admoperacional@grupoembracon.com.br","Priscila Rosa " ),
(123, 15, "desenvolvimento.ti@grupoembracon.com.br","Rovelcio Jr." ),
(124, 15, "ti5@grupoembracon.com.br","Anderson" ),
(125, 15, "ti1@grupoembracon.com.br","Francisco" ); | true |
2fab7e813a160d1eb68a79e63543fb060fe18155 | SQL | laksjpoid/lishibook | /src/main/java/com/lishibook/sql/localhost.sql | UTF-8 | 21,939 | 3.3125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.0.5
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2014 年 03 月 03 日 12:56
-- 服务器版本: 5.5.27
-- PHP 版本: 5.3.27
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 */;
--
-- 数据库: `django_test`
--
--
-- 数据库: `lishi`
--
-- --------------------------------------------------------
--
-- 表的结构 `pictures`
--
CREATE TABLE IF NOT EXISTS `pictures` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`rid` int(10) unsigned NOT NULL,
`uid` int(10) unsigned NOT NULL,
`filename` varchar(100) NOT NULL,
`path` varchar(255) NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`views` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `resource`
--
CREATE TABLE IF NOT EXISTS `resource` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(160) NOT NULL,
`description` varchar(400) DEFAULT NULL,
`content` text NOT NULL,
`creatorid` int(10) unsigned NOT NULL,
`createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lasteditid` int(10) unsigned NOT NULL,
`lastedittime` timestamp NULL DEFAULT NULL,
`views` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `resource_focosgroup`
--
CREATE TABLE IF NOT EXISTS `resource_focosgroup` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`rid` int(10) unsigned NOT NULL,
`name` varchar(160) NOT NULL,
`desc` varchar(400) DEFAULT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `resource_focus`
--
CREATE TABLE IF NOT EXISTS `resource_focus` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fromrid` int(10) unsigned NOT NULL,
`torid` int(10) unsigned NOT NULL,
`groupid` int(10) unsigned DEFAULT NULL,
`desc` varchar(400) NOT NULL COMMENT 'relationship description',
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `resource_topic`
--
CREATE TABLE IF NOT EXISTS `resource_topic` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`rid` int(10) unsigned NOT NULL,
`title` varchar(160) NOT NULL,
`content` text NOT NULL,
`authorid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastedit` timestamp NULL DEFAULT NULL,
`views` int(10) unsigned NOT NULL DEFAULT '0',
`replys` int(10) unsigned NOT NULL DEFAULT '0',
`like` int(10) unsigned NOT NULL DEFAULT '0',
`hate` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `resource_topic_reply`
--
CREATE TABLE IF NOT EXISTS `resource_topic_reply` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`tid` int(10) unsigned NOT NULL,
`content` text NOT NULL,
`authorid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(50) NOT NULL,
`username` varchar(50) DEFAULT NULL COMMENT '姓名',
`password` char(32) NOT NULL,
`gender` int(11) DEFAULT '0' COMMENT '0未知1男2女',
`birthday` int(11) DEFAULT NULL,
`iconid` int(11) DEFAULT NULL,
`regip` varchar(15) DEFAULT NULL,
`regtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastip` varchar(15) DEFAULT NULL,
`lasttime` timestamp NULL DEFAULT NULL,
`truename` varchar(50) DEFAULT NULL,
`telephone` varchar(15) DEFAULT NULL,
`admin` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '1-管理员',
`topics` int(10) unsigned NOT NULL DEFAULT '0',
`collection` int(10) unsigned NOT NULL DEFAULT '0',
`focususers` int(11) NOT NULL DEFAULT '0',
`befocused` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '被关注次数',
`checkup` int(11) NOT NULL DEFAULT '0' COMMENT '1-已审核 0-未审核',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `user_collections`
--
CREATE TABLE IF NOT EXISTS `user_collections` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL,
`rid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `user_link`
--
CREATE TABLE IF NOT EXISTS `user_link` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`fromuid` int(10) unsigned NOT NULL,
`touid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- 数据库: `lishibook`
--
-- --------------------------------------------------------
--
-- 表的结构 `album_picture`
--
CREATE TABLE IF NOT EXISTS `album_picture` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`resourcealbumid` int(10) unsigned DEFAULT NULL,
`useralbumid` int(10) unsigned DEFAULT NULL,
`visible` int(3) unsigned NOT NULL DEFAULT '1',
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`filename` varchar(255) NOT NULL,
`description` varchar(255) DEFAULT NULL,
`filetype` char(50) NOT NULL,
`filesize` int(11) NOT NULL DEFAULT '0',
`path` varchar(255) DEFAULT NULL,
`downloads` int(10) unsigned NOT NULL DEFAULT '0',
`uid` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
--
-- 转存表中的数据 `album_picture`
--
INSERT INTO `album_picture` (`id`, `resourcealbumid`, `useralbumid`, `visible`, `time`, `filename`, `description`, `filetype`, `filesize`, `path`, `downloads`, `uid`) VALUES
(1, 0, 0, 1, '2014-01-19 09:03:09', 'abc.jpeg', 'my description', 'jpeg', 789, 'hh', 0, 1),
(2, NULL, NULL, 1, '2014-01-19 09:03:13', 'abc.jpeg', 'my first picture', 'jpeg', 789, 'hh', 0, 1),
(3, 0, 0, 1, '2014-01-19 09:36:31', 'helloworld', NULL, 'jpeg', 0, NULL, 0, 0),
(4, 0, 0, 1, '2014-01-20 10:43:32', 'helloworld', NULL, 'jpeg', 0, NULL, 0, 0),
(5, NULL, NULL, 1, '2014-01-20 13:40:39', 'helloworld', NULL, 'jpeg', 0, NULL, 0, 0);
-- --------------------------------------------------------
--
-- 表的结构 `album_resource`
--
CREATE TABLE IF NOT EXISTS `album_resource` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`resourceid` int(10) unsigned NOT NULL,
`name` varchar(100) NOT NULL,
`description` varchar(255) NOT NULL,
`views` int(10) unsigned NOT NULL DEFAULT '0',
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastedit` timestamp NULL DEFAULT NULL,
`lastupload` timestamp NULL DEFAULT NULL,
`creatorid` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `album_user`
--
CREATE TABLE IF NOT EXISTS `album_user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL,
`name` varchar(100) NOT NULL,
`description` varchar(255) DEFAULT NULL,
`views` int(10) unsigned NOT NULL DEFAULT '0',
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastedit` timestamp NULL DEFAULT NULL,
`lastupload` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `resource`
--
CREATE TABLE IF NOT EXISTS `resource` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`description` varchar(255) NOT NULL DEFAULT '',
`content` mediumtext NOT NULL,
`authorid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastedit` timestamp NULL DEFAULT NULL,
`lasteditorid` int(10) unsigned NOT NULL,
`views` int(10) unsigned NOT NULL DEFAULT '0',
`editions` int(10) unsigned NOT NULL DEFAULT '1',
`visible` int(1) NOT NULL DEFAULT '1',
`locked` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- 转存表中的数据 `resource`
--
INSERT INTO `resource` (`id`, `name`, `description`, `content`, `authorid`, `time`, `lastedit`, `lasteditorid`, `views`, `editions`, `visible`, `locked`) VALUES
(1, '第一个资源', '这是我的第一个资源', '在刚开始学习Mybatis注解的时候,总是遇到错误Type interface com.souvi.ibatis.xxxMapper is not known to the MapperRegistry,在网上搜索相关的解决方案时,得到的答案都不怎么详细,但知道了Mybatis注解一定要注册自己写的接口类,不然就会老报开头提到的这个错误。经过一段时间的学习后,想在这里和大家分享一下mybatis注解的使用,以基础数据的增、删、改、查为例。', 1, '2014-01-22 10:58:07', NULL, 1, 0, 1, 1, 0),
(2, '第一个资源', '这是我的第一个资源', '在刚开始学习Mybatis注解的时候,总是遇到错误Type interface com.souvi.ibatis.xxxMapper is not known to the MapperRegistry,在网上搜索相关的解决方案时,得到的答案都不怎么详细,但知道了Mybatis注解一定要注册自己写的接口类,不然就会老报开头提到的这个错误。经过一段时间的学习后,想在这里和大家分享一下mybatis注解的使用,以基础数据的增、删、改、查为例。', 1, '2014-01-22 10:58:14', NULL, 1, 0, 1, 1, 0);
-- --------------------------------------------------------
--
-- 表的结构 `resource_edition`
--
CREATE TABLE IF NOT EXISTS `resource_edition` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`resourceid` int(10) unsigned NOT NULL,
`authorid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ip` varchar(40) NOT NULL,
`name` varchar(100) NOT NULL,
`description` varchar(255) NOT NULL DEFAULT '',
`content` mediumint(9) NOT NULL,
`reason` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `resource_relation`
--
CREATE TABLE IF NOT EXISTS `resource_relation` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fromrid` int(11) NOT NULL,
`torid` int(11) NOT NULL,
`type` varchar(100) DEFAULT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `resource_topic`
--
CREATE TABLE IF NOT EXISTS `resource_topic` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`resourceid` int(10) unsigned NOT NULL,
`title` varchar(100) NOT NULL,
`content` mediumint(9) NOT NULL,
`authorid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastedit` int(11) DEFAULT NULL,
`views` int(11) NOT NULL DEFAULT '0',
`replys` int(11) NOT NULL DEFAULT '0',
`visible` int(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `resource_topic_reply`
--
CREATE TABLE IF NOT EXISTS `resource_topic_reply` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`topicid` int(10) unsigned NOT NULL,
`content` text NOT NULL,
`authorid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`visible` int(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(100) NOT NULL,
`password` char(32) NOT NULL,
`nickname` varchar(50) NOT NULL,
`gender` int(4) DEFAULT NULL COMMENT '1 男 2 女 0 未知 3 其他',
`birthday` date DEFAULT NULL,
`iconid` int(10) unsigned DEFAULT NULL,
`location` varchar(255) DEFAULT NULL,
`regip` varchar(40) DEFAULT NULL,
`regtime` timestamp NULL DEFAULT NULL,
`lastip` varchar(40) DEFAULT NULL,
`lasttime` timestamp NULL DEFAULT NULL,
`truename` varchar(100) DEFAULT NULL,
`telephone` varchar(20) DEFAULT NULL,
`isadmin` int(4) DEFAULT '0',
`creates` int(10) unsigned NOT NULL DEFAULT '0',
`focus` int(10) unsigned NOT NULL DEFAULT '0',
`views` int(10) unsigned NOT NULL DEFAULT '0',
`checkup` int(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`,`nickname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `user_focus_resource`
--
CREATE TABLE IF NOT EXISTS `user_focus_resource` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`userid` int(10) unsigned NOT NULL,
`resourceid` int(10) unsigned NOT NULL,
`description` varchar(255) DEFAULT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` int(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `user_link`
--
CREATE TABLE IF NOT EXISTS `user_link` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`fromuid` int(10) unsigned NOT NULL,
`touid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` int(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `user_link_request`
--
CREATE TABLE IF NOT EXISTS `user_link_request` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`fromuid` int(10) unsigned NOT NULL,
`touid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`status` int(4) NOT NULL DEFAULT '0' COMMENT '0 已请求 1 已接受 2 已拒绝 3 已忽略',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `user_topic`
--
CREATE TABLE IF NOT EXISTS `user_topic` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL,
`title` varchar(100) NOT NULL,
`content` mediumint(9) NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastedit` timestamp NULL DEFAULT NULL,
`views` int(10) unsigned NOT NULL DEFAULT '0',
`replys` int(10) unsigned NOT NULL DEFAULT '0',
`status` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '0 公开 1.保密 2.好友可见',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `user_topic_reply`
--
CREATE TABLE IF NOT EXISTS `user_topic_reply` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`topicid` int(10) unsigned NOT NULL,
`content` text NOT NULL,
`authorid` int(10) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`visible` int(3) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- 数据库: `snake`
--
-- --------------------------------------------------------
--
-- 表的结构 `snake_object_object_link`
--
CREATE TABLE IF NOT EXISTS `snake_object_object_link` (
`id` bigint(20) NOT NULL,
`from_object_id` bigint(20) NOT NULL,
`to_object_id` bigint(20) NOT NULL,
`weight` int(11) NOT NULL,
`creation_time` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `snake_object_role_link`
--
CREATE TABLE IF NOT EXISTS `snake_object_role_link` (
`id` bigint(20) NOT NULL,
`object_id` bigint(20) NOT NULL,
`role_id` bigint(20) NOT NULL,
`creation_time` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `snake_objects`
--
CREATE TABLE IF NOT EXISTS `snake_objects` (
`id` bigint(20) NOT NULL,
`name` varchar(256) CHARACTER SET latin1 NOT NULL,
`description` text CHARACTER SET latin1 NOT NULL,
`creation_time` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `snake_roles`
--
CREATE TABLE IF NOT EXISTS `snake_roles` (
`id` bigint(20) NOT NULL,
`name` varchar(256) CHARACTER SET latin1 NOT NULL,
`description` text CHARACTER SET latin1 NOT NULL,
`creation_time` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- 数据库: `test`
--
-- --------------------------------------------------------
--
-- 表的结构 `snake_subjects`
--
CREATE TABLE IF NOT EXISTS `snake_subjects` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`type_id` int(11) DEFAULT NULL,
`basic_contents` text,
`creation_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `type_id` (`type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `snake_subjects_links`
--
CREATE TABLE IF NOT EXISTS `snake_subjects_links` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`from_subject_id` int(11) DEFAULT NULL,
`to_subject_id` int(11) DEFAULT NULL,
`weight` int(11) DEFAULT NULL,
`creation_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `from_subject_id` (`from_subject_id`),
KEY `to_subject_id` (`to_subject_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `snake_types`
--
CREATE TABLE IF NOT EXISTS `snake_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`creation_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- 限制导出的表
--
--
-- 限制表 `snake_subjects`
--
ALTER TABLE `snake_subjects`
ADD CONSTRAINT `snake_subjects_ibfk_1` FOREIGN KEY (`type_id`) REFERENCES `snake_types` (`id`);
--
-- 限制表 `snake_subjects_links`
--
ALTER TABLE `snake_subjects_links`
ADD CONSTRAINT `snake_subjects_links_ibfk_1` FOREIGN KEY (`from_subject_id`) REFERENCES `snake_subjects` (`id`),
ADD CONSTRAINT `snake_subjects_links_ibfk_2` FOREIGN KEY (`to_subject_id`) REFERENCES `snake_subjects` (`id`);
--
-- 数据库: `testdb`
--
-- --------------------------------------------------------
--
-- 表的结构 `article`
--
CREATE TABLE IF NOT EXISTS `article` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userid` int(11) NOT NULL,
`title` varchar(100) NOT NULL,
`content` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
--
-- 转存表中的数据 `article`
--
INSERT INTO `article` (`id`, `userid`, `title`, `content`) VALUES
(1, 1, 'test_title', 'test_content'),
(2, 1, 'test_title_2', 'test_content_2'),
(3, 1, 'test_title_3', 'test_content_3'),
(4, 1, 'test_title_4', 'test_content_4');
-- --------------------------------------------------------
--
-- 表的结构 `goods`
--
CREATE TABLE IF NOT EXISTS `goods` (
`goodsId` int(11) unsigned NOT NULL AUTO_INCREMENT,
`price` double(10,2) NOT NULL,
`goodName` varchar(20) NOT NULL,
PRIMARY KEY (`goodsId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=18 ;
--
-- 转存表中的数据 `goods`
--
INSERT INTO `goods` (`goodsId`, `price`, `goodName`) VALUES
(2, 36.20, '面包'),
(7, 5200.00, 'thinkpad笔记本'),
(8, 5200.00, 'thinkpad笔记本'),
(13, 5200.00, 'thinkpad???'),
(14, 5200.00, 'thinkpad???'),
(15, 5200.00, 'thinkpad???'),
(16, 5200.00, 'thinkpad???'),
(17, 5200.00, 'thinkpad???');
-- --------------------------------------------------------
--
-- 表的结构 `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userName` varchar(50) DEFAULT NULL,
`userAge` int(11) DEFAULT NULL,
`userAddress` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- 转存表中的数据 `user`
--
INSERT INTO `user` (`id`, `userName`, `userAge`, `userAddress`) VALUES
(1, 'summer', 100, 'shanghai,pudong');
--
-- 数据库: `webdb`
--
-- --------------------------------------------------------
--
-- 表的结构 `t_message`
--
CREATE TABLE IF NOT EXISTS `t_message` (
`id` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `t_message`
--
INSERT INTO `t_message` (`id`, `name`) VALUES
(5, 'this name');
/*!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 |
06dfbfec431b01e2d2e005b62d3bb5f679a1361c | SQL | namila/WorldCup | /hive_scripts/4-histogram_no_of_unique_page_visits.sql | UTF-8 | 201 | 2.78125 | 3 | [] | no_license | USE worldcup;
SELECT hourOfDay, COUNT(DISTINCT userId, request) AS UniquePageVisits
FROM logData
WHERE requestType = "GET" AND isHTML = true AND statusCode = 200
GROUP BY hourOfDay
ORDER BY hourOfDay; | true |
4405b028800ef97b5233008c80de9145fdcf9bd6 | SQL | radtek/abs3 | /sql/mmfo/bars/Table/k2tmp.sql | UTF-8 | 2,544 | 3 | 3 | [] | no_license |
PROMPT =====================================================================================
PROMPT *** Run *** ========== Scripts /Sql/BARS/Table/K2TMP.sql =========*** Run *** =======
PROMPT =====================================================================================
PROMPT *** ALTER_POLICY_INFO to K2TMP ***
BEGIN
execute immediate
'begin
bpa.alter_policy_info(''K2TMP'', ''CENTER'' , null, null, null, null);
bpa.alter_policy_info(''K2TMP'', ''FILIAL'' , null, null, null, null);
bpa.alter_policy_info(''K2TMP'', ''WHOLE'' , null, null, null, null);
null;
end;
';
END;
/
PROMPT *** Create table K2TMP ***
begin
execute immediate '
CREATE TABLE BARS.K2TMP
( ISP NUMBER(*,0),
ACC9 NUMBER(*,0),
NLS9 VARCHAR2(15),
PR NUMBER(*,0),
OCH NUMBER(*,0),
ACC NUMBER(*,0),
REF NUMBER(*,0),
FDAT DATE,
SD NUMBER(38,0),
S NUMBER(38,0)
) SEGMENT CREATION DEFERRED
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
TABLESPACE BRSDYND ';
exception when others then
if sqlcode=-955 then null; else raise; end if;
end;
/
PROMPT *** ALTER_POLICIES to K2TMP ***
exec bpa.alter_policies('K2TMP');
COMMENT ON TABLE BARS.K2TMP IS '';
COMMENT ON COLUMN BARS.K2TMP.ISP IS '';
COMMENT ON COLUMN BARS.K2TMP.ACC9 IS '';
COMMENT ON COLUMN BARS.K2TMP.NLS9 IS '';
COMMENT ON COLUMN BARS.K2TMP.PR IS '';
COMMENT ON COLUMN BARS.K2TMP.OCH IS '';
COMMENT ON COLUMN BARS.K2TMP.ACC IS '';
COMMENT ON COLUMN BARS.K2TMP.REF IS '';
COMMENT ON COLUMN BARS.K2TMP.FDAT IS '';
COMMENT ON COLUMN BARS.K2TMP.SD IS '';
COMMENT ON COLUMN BARS.K2TMP.S IS '';
PROMPT *** Create grants K2TMP ***
grant SELECT on K2TMP to BARSREADER_ROLE;
grant DELETE,INSERT,SELECT,UPDATE on K2TMP to BARS_ACCESS_DEFROLE;
grant DELETE,INSERT,SELECT,UPDATE on K2TMP to START1;
grant SELECT on K2TMP to UPLD;
PROMPT =====================================================================================
PROMPT *** End *** ========== Scripts /Sql/BARS/Table/K2TMP.sql =========*** End *** =======
PROMPT =====================================================================================
| true |
18475169ad9d8f40b4e2a9c86f26aa76964070cb | SQL | Pawan1005/MI-10-MEAN | /sanket/MySQL/sanketA3.sql | UTF-8 | 4,358 | 4.0625 | 4 | [] | no_license | -- DML Operations on student and course table
-- 1. Insert a record in student table
-- 1 Amit 1234567890 9999833445 science 101 camp
INSERT INTO student (studId, studName, studAadhar, mobileNo, streams, studCourseId, address)
VALUES(1, "Amit", 1234567890, 9999833445, "science", 101, "camp");
-- 2. Is the record inserted in the table? The record is not inserted because there is a referential integrity
-- constraint on courseId and there is no record in the master course table.
-- No w try inserting the same record with courseId value as null
INSERT INTO student (studId, studName, studAadhar, mobileNo, streams, studCourseId, address)
VALUES(1, "Amit", 1234567890, 9999833445, "science", NULL, "camp");
-- 3. Insert the following values in course table
-- courseID courseName
-- 101 Computers
-- 102 Electronics
-- 103 Mechanical
-- 104 Civil
INSERT INTO course
VALUES (101, "Computers"),
(102, "Electronics"),
(103, "Mechanical"),
(104, "Civil");
-- 4. Add a column in course table – courseCode varachar(4)
ALTER TABLE course
ADD courseCode VARCHAR(4);
-- 5. Display all the records in the course table.
SELECT *
FROM course;
-- 6. Update the courseCode as follows 101 – COMP,102 – ENTC,103- MECH,104 – CIVL
UPDATE course
SET courseCode = "COMP"
WHERE courseId = 101;
UPDATE course
SET courseCode = "ENTC"
WHERE courseId = 102;
UPDATE course
SET courseCode = "MECH"
WHERE courseId = 103;
UPDATE course
SET courseCode = "CIVL"
WHERE courseId = 104;
-- 7. Insert 10 records in student table against various coourseIds. - use multiple insert.
INSERT INTO student
VALUES(2, "Bmit", 1234567891, 9999833446, "science", 102, "campa","1111-1-1"),
(3, "Cmit", 1234567892, 9999833447, "science", 103, "campb","1111-1-2"),
(4, "Dmit", 1234567893, 9999833448, "science", 104, "campc","1111-1-3"),
(5, "Emit", 1234567894, 9999833449, "science", 101, "campd","1111-1-4"),
(6, "Fmit", 1234567895, 9999833450, "commerce", 102, "campe","1111-1-5"),
(7, "Gmit", 1234567896, 9999833451, "commerce", 103, "campf","1111-1-6"),
(8, "Hmit", 1234567897, 9999833452, "commerce", 104, "campg","1111-1-7"),
(9, "Imit", 1234567898, 9999833453, "commerce", 101, "campg","1111-1-8"),
(10, "Jmit", 1234567899, 9999833454, "commerce", 102, "camph","1111-1-9"),
(11, "Kmit", 1234567900, 9999833455, "commerce", 103, "campi","1111-1-10");
-- 8. Create a duplicate table of student table. Name it DUP_EMP
CREATE TABLE DUP_EMP AS
SELECT *
FROM student;
-- 9. Delete all the records of course Mechanical course from DUP_EMP table.
SET SQL_SAFE_UPDATES = 0;
DELETE FROM DUP_EMP
WHERE studCourseId =(
SELECT courseId
FROM course
WHERE courseName = "Mechanical"
);
-- 10. set the auotcommit to 0. Give start transaction command.
SET autocommit = 0;
START TRANSACTION;
-- 11. Add a columns marks and practical in student table.
ALTER TABLE student
ADD marks INT,
ADD practical INT;
-- 12. Give a rollback statement.Check if the columns added are still in the table
ROLLBACK;
SELECT *
FROM student;
-- 13. insert two more records in student table.
INSERT INTO student
VALUES(12, "Lmit", 1234567901, 9999833546, "science", 102, "campa","1111-1-11",NULL,NULL),
(22, "Mmit", 1234567902, 9999833547, "science", 103, "campb","1111-1-12",NULL,NULL);
-- 14. Give Rollback command. Check if the records are still there in the table.
ROLLBACK;
SELECT *
FROM student;
-- 15. insert two more records in student table.Give a commit command.
INSERT INTO student
VALUES(12, "Lmit", 1234567901, 9999833546, "science", 102, "campa","1111-1-11",NULL,NULL),
(22, "Mmit", 1234567902, 9999833547, "science", 103, "campb","1111-1-12",NULL,NULL);
COMMIT;
-- 16. Now give a savepoint A and update the marks and practical marks of all students.
SAVEPOINT A;
UPDATE student
SET marks = 22, practical = 33;
-- 17. Display the data from student table.See if the data is updated in the table.
SELECT *
FROM student;
-- 18. Now give savepoint B and delete the records from the student table whose name start from S.
SAVEPOINT B;
DELETE FROM student
WHERE studName LIKE "M%";
-- 19. Display the result and check if the records are deleted.
SELECT *
FROM student;
-- 20. Give a Roll back command.Display the results and check if the records are there in the table.
ROLLBACK;
SELECT *
FROM student;
| true |
bf3543a35a0629481fd4c2e39591a1e3c3aee95b | SQL | tester200xm/pgcodekeeper | /apgdiff.tests/src/main/resources/cz/startnet/utils/pgdiff/create_func_type_new.sql | UTF-8 | 1,131 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | --
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
--
-- Name: add(typ_composite, integer); Type: FUNCTION; Schema: public; Owner: botov_av
--
CREATE FUNCTION add(typ_composite, integer) RETURNS integer
LANGUAGE sql IMMUTABLE STRICT
AS $_$select $2;$_$;
ALTER FUNCTION public.add(typ_composite, integer) OWNER TO botov_av;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: typ_composite; Type: TYPE; Schema: public; Owner: botov_av
--
CREATE TYPE typ_composite AS (
key character varying(80) COLLATE pg_catalog."ru_RU.utf8",
val text COLLATE pg_catalog."en_GB"
);
ALTER TYPE typ_composite OWNER TO botov_av;
--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--
| true |
1b5bf962e5c1f0afac6f03a5355d93c5ecbb9c7c | SQL | jose4125/promo | /usuariosalkosto_2012-06-22.sql | UTF-8 | 2,310 | 3.046875 | 3 | [] | no_license | # ************************************************************
# Sequel Pro SQL dump
# Version 3408
#
# http://www.sequelpro.com/
# http://code.google.com/p/sequel-pro/
#
# Host: 127.0.0.1 (MySQL 5.1.44)
# Database: usuariosalkosto
# Generation Time: 2012-06-23 04:52:28 +0000
# ************************************************************
/*!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 */;
/*!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 */;
# Dump of table DATOS
# ------------------------------------------------------------
CREATE TABLE `DATOS` (
`consecutivo` int(11) NOT NULL AUTO_INCREMENT,
`cedula` int(11) NOT NULL DEFAULT '0',
`nombres` varchar(200) DEFAULT NULL,
`ciudad` varchar(100) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`telefono` varchar(50) DEFAULT NULL,
`aceptaT` char(1) DEFAULT NULL,
`ofertas` char(1) DEFAULT NULL,
`fan` varchar(140) DEFAULT '',
`frase` varchar(200) DEFAULT '',
PRIMARY KEY (`consecutivo`,`cedula`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
LOCK TABLES `DATOS` WRITE;
/*!40000 ALTER TABLE `DATOS` DISABLE KEYS */;
INSERT INTO `DATOS` (`consecutivo`, `cedula`, `nombres`, `ciudad`, `email`, `telefono`, `aceptaT`, `ofertas`, `fan`, `frase`)
VALUES
(1,80000000,'prueba1','bogota','prueba1@hotmail.com','1234567','N','N','',''),
(2,70000000,'prueba2','medellin','prueba2@hotmail.com','7654321','S','S','',''),
(3,60000000,'prueba3','cucuta','prueba3@hotmail.com','2111111','N','N','',''),
(4,50000000,'prueba4','bquilla','prueba4@hotmail.com','3111111','S','S','',''),
(5,40000000,'prueba5','bucaramanga','prueba5@hotmail.com','4111111','N','N','','');
/*!40000 ALTER TABLE `DATOS` ENABLE KEYS */;
UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_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 */;
| true |
1efe85d4b11311c3c7873735ef4506c7c64c85ee | SQL | fandashtic/arc_chennai | /Sivabalan-SQL/SQL_STORED_PROCEDURE/sp_ser_checkbankaccount.sql | UTF-8 | 215 | 2.953125 | 3 | [] | no_license | CREATE procedure sp_ser_checkbankaccount(@AccountName as nvarchar(255))
as
Select Bank.AccountId from AccountsMaster
Inner Join Bank On Bank.AccountId = AccountsMaster.AccountID
Where AccountName = @AccountName
| true |
53ddf9b028422e57582eb617cdb8ca35ce2bd8dd | SQL | srqway/dba.postgresql | /dba.v_dublicate_indexes.sql | UTF-8 | 813 | 3.65625 | 4 | [
"Apache-2.0"
] | permissive | CREATE VIEW dba.v_dublicate_indexes AS
SELECT
rank() OVER (ORDER BY schema_name, table_name) AS grp,
schema_name,
table_name,
unnest(index_names) AS index_names,
unnest(index_sizes) AS index_sizes
FROM (
SELECT
s.nspname AS schema_name,
tc.relname AS table_name,
array_agg(ic.relname) AS index_names,
array_agg(pg_relation_size(i.indexrelid)) AS index_sizes
FROM pg_index i
JOIN pg_class tc ON tc.oid = i.indrelid
JOIN pg_class ic ON ic.oid = i.indexrelid
JOIN pg_namespace s ON s.oid = tc.relnamespace
GROUP BY
s.nspname,
tc.relname,
i.indrelid,
i.indclass,
i.indkey,
i.indexprs,
i.indpred,
i.indisunique
HAVING
count(*) > 1
) index_dbls; | true |
c8d8c04cf1ed91bffc825129149b87a75b2652e7 | SQL | henry-ns/iTern | /db/deletes.sql | UTF-8 | 601 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | --Exclusão de uma vaga oferecida por uma empresa
DELETE FROM vacancy
WHERE company_id = x
-- Exclusão de uma empresa
DELETE FROM company
Where id = x;
-- Exclusão do número de telefone de um estudante
DELETE FROM student_telephone
WHERE student_id = x;
-- Exclusão de uma rede social de um estudante
DELETE FROM student_social
WHERE student_id = x;
-- Exclusão de um curso de um estudante
DELETE FROM student_course
WHERE student_id = x;
-- Exclusão de uma vaga de estudante
DELETE FROM student_vacancy
WHERE student_id = x;
-- Exclusão de um estudante
DELETE FROM student
WHERE id = x;
| true |
b0b26226213b48c42f7bd0b9392c859c209a2303 | SQL | freshmuffin/curbside-client | /server/db/schema.sql | UTF-8 | 315 | 2.546875 | 3 | [] | no_license | USE FreshMuffin;
DROP TABLE IF EXISTS `client`;
CREATE TABLE client (
id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
site_id VARCHAR(50) UNIQUE NOT NULL,
phone VARCHAR(255),
address VARCHAR(255) NOT NULL,
latitude VARCHAR(255) ,
longitude VARCHAR(255),
date DATETIME NOT NULL
-- ,time_window TIME
);
| true |
05be667ccfd8e9bd1a3b38cd793d427f0140e0fc | SQL | Vova0199/NU_LP | /2_course/1_semester/database/4_lab/MySQL/Trigger(4).sql | UTF-8 | 133 | 2.953125 | 3 | [
"MIT"
] | permissive | DELIMITER ;;
CREATE TRIGGER `my_table_bi`
BEFORE INSERT ON user FOR EACH ROW
BEGIN
SET NEW.login = min(surname);
END;;
DELIMITER ; | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.