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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
fcb4f7cec67a52b793995197c6324b1e9bace334 | SQL | ci2backend/ci2backend | /database/base-database.sql | UTF-8 | 48,376 | 3.046875 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.5.2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 13, 2017 at 08:17 AM
-- Server version: 5.7.9
-- PHP Version: 5.6.16
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
SET FOREIGN_KEY_CHECKS = 0;
/*!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: `base_code_ci`
--
-- --------------------------------------------------------
--
-- Table structure for table `languages`
--
DROP TABLE IF EXISTS `languages`;
CREATE TABLE IF NOT EXISTS `languages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`lang_key` varchar(32) DEFAULT NULL,
`lang_display` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`lang_folder` varchar(255) DEFAULT NULL,
`lang_class_flag` varchar(32) DEFAULT NULL,
`is_default` int(1) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `languages`
--
INSERT INTO `languages` (`lang_key`, `lang_display`, `lang_folder`, `lang_class_flag`, `is_default`) VALUES
('en', 'English', 'english', 'flag-us', 1),
('vn', 'Viet Nam', 'vietnam', 'flag-vn', 0),
('jp', 'Japanese', 'japanese', 'flag-jp', 0);
-- --------------------------------------------------------
--
-- Table structure for table `sessions`
--
DROP TABLE IF EXISTS `sessions`;
CREATE TABLE IF NOT EXISTS `sessions` (
`session_id` varchar(40) CHARACTER SET latin1 NOT NULL DEFAULT '0',
`ip_address` varchar(45) CHARACTER SET latin1 NOT NULL DEFAULT '0',
`user_agent` varchar(120) CHARACTER SET latin1 NOT NULL,
`last_activity` int(10) UNSIGNED NOT NULL DEFAULT '0',
`user_data` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`date_access` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`session_id`),
KEY `last_activity_idx` (`last_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `tokens`
--
DROP TABLE IF EXISTS `tokens`;
CREATE TABLE IF NOT EXISTS `tokens` (
`token_key` varchar(255) NOT NULL,
`session_id` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
PRIMARY KEY (`token_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tokens`
--
INSERT INTO `tokens` (`token_key`, `session_id`, `email`, `username`) VALUES
('F14CA6E92811-3F67-D632-4CDB96FD736F', '3F67-D632-4CDB96FD736F', 'truong.van.phu@bpotech.com.vn', ''),
('F1aCA6E92811-3F67-D632-4CDB96FD736F', '3F67-D632-4CDB96FD736F', 'phu_tv@live.com', '');
-- --------------------------------------------------------
--
-- Table structure for table `constants`
--
DROP TABLE IF EXISTS `constants`;
CREATE TABLE IF NOT EXISTS `constants` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`constant` varchar(100) NOT NULL,
`value` varchar(255) NOT NULL,
`is_system` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `extensions`
--
DROP TABLE IF EXISTS `extensions`;
CREATE TABLE IF NOT EXISTS `extensions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`extension_name` varchar(255) NOT NULL,
`extension_key` varchar(255) NOT NULL,
`system_load` int(1) NOT NULL DEFAULT '0',
`description` varchar(255) NULL,
`create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`allow_delete` int(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `extensions`
--
INSERT INTO `extensions` (`id`, `extension_name`, `extension_key`, `system_load`, `description`, `create_date`, `allow_delete`) VALUES
(1, 'Jquery', 'jquery', 0, 'jQuery is a fast, small, and feature-rich JavaScript library.', '2017-06-09 16:21:38', 0),
(2, 'Bootstrap 3.3.7', 'bootstrap', 0, 'Bootstrap 3.3.7', '2017-06-09 16:21:38', 0),
(3, 'Uniform', 'uniform', 0, 'Uniform', '2017-06-09 16:21:38', 0),
(6, 'Jquery validation', 'jquery-validation', 0, 'The jQuery Validation Plugin provides drop-in validation for your existing forms, while making all kinds of customizations to fit your application really easy.', '2017-06-09 16:21:38', 0),
(8, 'Confirmation bootstrap', 'confirmation', 0, 'Confirmation bootstrap', '2017-06-09 16:21:38', 0),
(9, 'Font Awesome v4.5', 'font-awesome', 0, 'Font Awesome v4.5', '2017-06-09 16:21:38', 0),
(10, 'Form Builder', 'formbuilder', 0, 'Form Builder', '2017-06-09 16:21:38', 0),
(11, 'Jquery UI 1.11.4', 'jquery-ui', 0, 'Jquery UI 1.11.4', '2017-06-09 16:21:38', 0),
(12, 'elFinder 2.1.14', 'elfinder', 0, 'elFinder file manager for web', '2017-06-09 16:21:38', 0),
(13, 'CodeMirror - 5.1.1', 'codemirror', 0, 'CodeMirror - 5.1.1', '2017-06-09 16:21:38', 0),
(14, 'DropZone Upload File', 'dropzone', 0, 'Dropzone is an easy to use drag\'n\'drop library. It supports image previews and shows nice progress bars.', '2017-06-09 16:21:38', 0),
(15, 'Jquery Chosen', 'jquery-chosen', 0, 'Jquery Chosen', '2017-06-09 16:21:38', 0),
(16, 'Form Post Download', 'ajax_download', 0, 'Form Post Download', '2017-06-09 16:21:38', 0),
(17, 'Bootstrap File Input', 'bootstrap-fileinput', 0, 'An enhanced HTML 5 file input for Bootstrap 3.x with file preview, multiple selection, and more features.', '2017-06-09 16:21:38', 0),
(18, 'Jquery slug URL', 'jquery-slug-url', 0, 'Jquery slug URL', '2017-06-09 16:21:38', 0),
(19, 'Preview tool', 'preview-tool', 0, 'Preview tool', '2017-06-09 16:23:10', 0),
(20, 'Overlay', 'overlay', 0, 'Overlay', '2017-06-09 16:25:24', 0),
(21, 'Messi Notify', 'messi', 0, 'Messi Notify', '2017-06-09 16:27:35', 0),
(22, 'Ajax.org Cloud9 Editor', 'ace-builds', 0, 'Ace is a code editor written in JavaScript.', '2017-06-09 16:42:44', 0),
(23, 'Bootbox', 'bootbox', 0, 'Bootbox - Bootstrap powered alert, confirm and flexible dialog boxes', '2017-06-09 16:50:17', 0),
(24, 'Table Search Plugin', 'jquery.tablesearch', 0, 'A jQuery plugin for a quick search in big tables. Will display only the line that matchs the query and hightlight the terms in the line', '2017-06-09 16:50:17', 0),
(25, 'Table Sorter Plugin', 'tablesorter', 0, 'Flexible client-side table sorting', '2017-06-22 02:48:49', 0);
-- --------------------------------------------------------
--
-- Table structure for table `groups`
--
DROP TABLE IF EXISTS `groups`;
CREATE TABLE IF NOT EXISTS `groups` (
`id` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`description` varchar(100) NOT NULL,
`security` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `groups`
--
INSERT INTO `groups` (`id`, `name`, `description`, `security`) VALUES
(1, 'admin', 'Administrator', 1),
(2, 'members', 'General User', 0);
-- --------------------------------------------------------
--
-- Table structure for table `login_attempts`
--
DROP TABLE IF EXISTS `login_attempts`;
CREATE TABLE IF NOT EXISTS `login_attempts` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`ip_address` varchar(15) NOT NULL,
`login` varchar(100) NOT NULL,
`time` int(11) UNSIGNED DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `menus`
--
DROP TABLE IF EXISTS `menus`;
CREATE TABLE IF NOT EXISTS `menus` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title_key` varchar(255) NOT NULL,
`action_router` varchar(255) NOT NULL,
`icon` varchar(255) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`is_show` int(1) NOT NULL DEFAULT '1',
`is_delete` int(1) NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `menus`
--
INSERT INTO `menus` (`id`, `title_key`, `action_router`, `icon`, `description`, `is_show`, `is_delete`, `created`, `modified`) VALUES
(1, 'Dashboard', 'dev/index', NULL, 'Manage all module in the system', 1, 0, '2017-06-13 08:15:34', '2017-06-13 08:15:34'),
(2, 'Views', 'views/index', NULL, 'Manage page in the system', 1, 0, '2017-06-13 08:15:34', '2017-06-13 08:15:34'),
(3, 'Controllers', 'controllers/index', NULL, 'Manage all controller in the sysytem', 1, 0, '2017-06-13 08:15:34', '2017-06-13 08:15:34'),
(4, 'MyQueries', 'models/index', NULL, 'Manage all model in the sysytem', 1, 0, '2017-06-13 08:15:34', '2017-06-13 08:15:34'),
(5, 'Languages', 'languages/index', NULL, 'Manage all language in the sysytem', 1, 0, '2017-06-13 08:15:34', '2017-06-13 08:15:34'),
(6, 'Databases', 'databases/index', NULL, 'Manage all database in the sysytem', 1, 0, '2017-06-13 08:15:34', '2017-06-13 08:15:34'),
(7, 'Users', 'users/index', NULL, 'Manage all user in the sysytem', 1, 0, '2017-06-13 08:15:34', '2017-06-13 08:15:34'),
(8, 'Menus', 'menus/index', NULL, 'Manage all menu in the system', 0, 0, '2017-06-13 08:15:34', '2017-06-23 11:41:39'),
(9, 'Settings', 'dev/setting', NULL, 'Setting in the system', 1, 0, '2017-06-13 08:15:34', '2017-06-13 08:15:34'),
(10, 'Templates', 'templates/index', NULL, 'Manage template', 0, 1, '2017-06-13 08:15:34', '2017-06-13 08:15:34'),
(11, 'Platforms', 'platforms/index', NULL, 'Manage platform', 0, 1, '2017-06-13 08:15:34', '2017-06-13 08:15:34'),
(12, 'Extensions', 'extensions/index', NULL, 'Manage extension', 0, 0, '2017-06-18 21:54:20', '2017-06-18 14:54:20');
-- --------------------------------------------------------
--
-- Table structure for table `modules`
--
DROP TABLE IF EXISTS `modules`;
CREATE TABLE IF NOT EXISTS `modules` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title_key` varchar(255) NOT NULL,
`action` varchar(255) NOT NULL,
`is_show` int(1) NOT NULL DEFAULT '1',
`icon` varchar(255) NOT NULL,
`description` varchar(255) NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `modules`
--
INSERT INTO `modules` (`id`, `title_key`, `action`, `is_show`, `icon`, `description`) VALUES
(1, 'Views', 'views/index', 1, 'modules/manage_view.png', 'Manage View'),
(2, 'Controllers', 'controllers/index', 1, 'modules/manage_controller.png', 'Manage Controller'),
(3, 'MyQueries', 'models/index', 1, 'modules/manage_model.png', 'Manage Model'),
(4, 'Languages', 'languages/index', 1, 'modules/manage_language.png', 'Manage Language'),
(5, 'Databases', 'databases/index', 1, 'modules/manage_database.png', 'Manage Database'),
(6, 'Users', 'users/index', 1, 'modules/manage_user.png', 'Manage User'),
(7, 'Menus', 'menus/index', 0, 'modules/menu.png', 'Main Menu'),
(8, 'Platforms', 'platforms/index', 1, 'modules/manage_platform.png', 'Manage Platform'),
(9, 'Routers', 'routers/index', 1, 'modules/manage_router.png', 'Router'),
(10, 'Commons', 'commons/index', 0, 'modules/manage_common.png', 'Common file'),
(11, 'Templates', 'templates/index', 1, 'modules/manage_template.png', 'Manage Template'),
(12, 'Elements', 'elements/index', 0, 'modules/manage_element.png', 'Form Elements'),
(13, 'Extensions', 'extensions/index', 1, 'modules/manage_extension.png', 'Manage Extension'),
(14, 'Supports', 'supports/index', 1, 'modules/support.png', 'Support'),
(15, 'Settings', 'dev/setting', 1, 'modules/setting.png', 'Settings');
-- --------------------------------------------------------
--
-- Table structure for table `platform`
--
DROP TABLE IF EXISTS `platforms`;
CREATE TABLE IF NOT EXISTS `platforms` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`platform_key` varchar(255) NOT NULL,
`platform_name` varchar(255) NOT NULL,
`description` varchar(255) NULL,
`is_default` int(1) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `platform`
--
INSERT INTO `platforms` (`id`, `platform_key`, `platform_name`, `description`, `is_default`) VALUES
(1, 'web', "Desktop browser", 'Website for desktop', 1),
(2, 'mobile', "Mobile browser", 'Mobile browser for Wap, Wap2, Imode', 0),
(3, 'smartphone', "Smartphone browser", 'Smartphone for iPod, iPhone, Android, IEMobile', 0),
(4, 'sys_admin', "Backend System", 'Admin System is a customize platform for all devices', 0);
-- --------------------------------------------------------
--
-- Table structure for table `routers`
--
DROP TABLE IF EXISTS `routers`;
CREATE TABLE IF NOT EXISTS `routers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`router_source` varchar(255) NOT NULL,
`router_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`router_value` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `routers`
--
INSERT INTO `routers` (`router_source`, `router_key`, `router_value`) VALUES
('dev/index', 'dev/index', 'admin.html'),
('dev/index', 'dev/index', 'admin'),
('dev/profile', 'dev/profile', 'profile'),
('dev/profile', 'dev/profile', 'profile.html'),
('dev/setting', 'dev/setting/database_settings', 'database_settings.html'),
('dev/setting', 'dev/setting/configure', 'configure.html'),
('dev/setting', 'dev/setting', 'configure.html'),
('dev/setting', 'dev/setting/constant_define', 'constant_define.html'),
('dev/setting', 'dev/setting/repair_database', 'repair_database.html'),
('dev/setting', 'dev/setting/site_settings', 'site_settings.html'),
('dev/index', 'dev/index', 'admin.html'),
('dev/index', 'dev/index', 'admin'),
('users/login', 'users/login', 'login.html'),
('dev/setting', 'dev/setting/database_settings', 'database_settings.html'),
('dev/setting', 'dev/setting/configure', 'configure.html'),
('dev/setting', 'dev/setting', 'configure.html'),
('dev/setting', 'dev/setting/constant_define', 'constant_define.html'),
('dev/setting', 'dev/setting/repair_database', 'repair_database.html'),
('dev/setting', 'dev/setting/site_settings', 'site_settings.html'),
('dev/setting', 'dev/setting/site_settings', 'site_settings.html'),
('dev/setting', 'dev/setting/email_configure', 'email_configure.html'),
('dev/form_ajax', 'dev/form_ajax', 'ajax.html'),
('dev/form_ajax', 'dev/form_ajax/$1', 'ajax.html/(:any)'),
('users/logout', 'users/logout', 'logout.html'),
('extensions/index', 'extensions/index', 'local_extension.html'),
('extensions/index', 'extensions/index/local_extension', 'local_extension.html'),
('extensions/index', 'extensions/index/new_extension', 'new_extension.html');
-- --------------------------------------------------------
--
-- Table structure for table `sub_menus`
--
DROP TABLE IF EXISTS `sub_menus`;
CREATE TABLE IF NOT EXISTS `sub_menus` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title_key` varchar(255) NOT NULL,
`menu_id` int(11) NOT NULL,
`action_router` varchar(255) NOT NULL,
`icon` varchar(255) DEFAULT NULL,
`is_show` int(1) NOT NULL DEFAULT '1',
`description` varchar(255) NULL,
PRIMARY KEY (`id`),
KEY `fk_menus_id` (`menu_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `sub_menus`
--
INSERT INTO `sub_menus` (`id`, `title_key`, `menu_id`, `action_router`, `icon`, `is_show`, `description`) VALUES
(1, 'Create_new', 8, 'menus/create', NULL, 1, 'Create new menu'),
(2, 'Create_sub_menu', 8, 'menus/sub_menu', NULL, 1, 'Create sub menu'),
(3, 'Platforms', 1, 'platforms/index', NULL, 1, 'Manage platform'),
(4, 'Routers', 1, 'routers/index', NULL, 1, 'Manage router'),
(5, 'Commons', 1, 'commons/index', NULL, 0, 'Manage common'),
(6, 'Templates', 1, 'templates/index', NULL, 1, 'Manage template'),
(7, 'Elements', 1, 'elements/index', NULL, 0, 'Manage form'),
(8, 'Extensions', 1, 'extensions/index', NULL, 1, 'Manage extension'),
(9, 'Supports', 1, 'supports/index', NULL, 1, 'Support online'),
(10, 'Create_page', 2, 'views/create', NULL, 1, 'Create new page'),
(11, 'Create_controller', 3, 'controllers/create', NULL, 1, 'Create new controller'),
(12, 'Create_query', 4, 'models/create', NULL, 1, 'Create new query file'),
(13, 'Region_list', 5, 'languages/region', NULL, 1, 'Region list'),
(14, 'Create_group', 7, 'auth/create_group', NULL, 1, 'Add a new group'),
(15, 'Create_user', 7, 'auth/create_user', NULL, 1, 'Add a new user'),
(16, 'Add_new_template', 10, 'templates/create', NULL, 1, 'Add new template'),
(17, 'Add_new_platform', 11, 'platforms/create', NULL, 1, 'Add new platform'),
(18, 'View_detail', 2, 'views/detail', NULL, 0, 'View detai'),
(19, 'Edit_content', 2, 'views/edit', NULL, 0, 'Edit content'),
(20, 'Compare_language', 5, 'dev/compare_lang', NULL, 0, 'Compare language'),
(21, 'Extension_detail', 12, 'extensions/detail', NULL, 0, 'Extension detail'),
(22, 'Template_detail', 10, 'templates/detail', NULL, 1, ''),
(23, 'Compare_language', 5, 'languages/compare', NULL, 0, 'Compare language page'),
(24, 'Edit_content', 5, 'languages/edit', NULL, 0, 'Edit language page'),
(25, 'Add_new_language', 5, 'languages/create', NULL, 1, 'Add new language'),
(26, 'Edit_content', 3, 'controllers/edit', NULL, 0, 'Edit content'),
(27, 'Access_right', 7, 'users/access_right', NULL, 1, 'Access right'),
(28, 'Edit_content', 4, 'models/edit', NULL, 0, 'Edit content'),
(29, 'Detail_controller', 3, 'controllers/detail', NULL, 1, 'Detail controller');
-- --------------------------------------------------------
--
-- Table structure for table `system_settings`
--
DROP TABLE IF EXISTS `settings`;
CREATE TABLE IF NOT EXISTS `settings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`key_setting` varchar(255) NOT NULL,
`value_setting` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `key_setting` (`key_setting`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `settings`
--
INSERT INTO `settings` (`id`, `key_setting`, `value_setting`) VALUES
(1, 'MULTI_PLATFORM', '1'),
(2, 'ENABLE_AUTHENTICATION', '1'),
(3, 'DEVELOPER_PLATFORM', 'sys_admin'),
(4, 'DEVELOPER_TEMPLATE', 'sys_admin'),
(5, 'AUTO_GENERATE_ASSEST_FILE', '1'),
(6, 'AUTO_GENERATE_LANGUAGE_FILE', '1'),
(7, 'ENABLE_PRODUCTION', '0'),
(8, 'AUTO_LOAD_VIEW', '1');
-- --------------------------------------------------------
--
-- Table structure for table `templates`
--
DROP TABLE IF EXISTS `templates`;
CREATE TABLE IF NOT EXISTS `templates` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`template_name` varchar(255) NOT NULL,
`template_key` varchar(255) NOT NULL,
`page_content_default` varchar(255) NULL,
`description` varchar(255) NULL,
`enable_customize_view` int(1) NOT NULL DEFAULT '0',
`customize_view_folder` varchar(255) NULL DEFAULT 'custom_view',
`is_default` int(1) NOT NULL DEFAULT '0',
`is_backend` int(1) NOT NULL DEFAULT '0',
`allow_delete` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `templates`
--
INSERT INTO `templates` (`template_name`, `template_key`, `page_content_default`, `is_default`, `is_backend`) VALUES
('Admin System', 'sys_admin', '<div class="grid_12">
<div class="module">
<h2 class="text-primary"><span>Title</span></h2>
<div class="module-body">
<div class="grid_12 grid">
</div>
</div>
</div>
</div>', 0, 1),
('Web Application', 'web', '', 1, 0),
('No Template', 'notemplate', '', 0, 0);
-- --------------------------------------------------------
--
-- Table structure for table `templates_extensions`
--
DROP TABLE IF EXISTS `templates_extensions`;
CREATE TABLE IF NOT EXISTS `templates_extensions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`template_key` varchar(50) NOT NULL,
`extension_key` varchar(50) NOT NULL,
`is_load` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `templates_extensions`
--
INSERT INTO `templates_extensions` (`id`, `template_key`, `extension_key`, `is_load`) VALUES
(1, 'sys_admin', 'bootbox', 1),
(3, 'web', 'jquery', 1),
(4, 'web', 'bootstrap', 1);
-- --------------------------------------------------------
--
-- Table structure for table `templates_menus`
--
DROP TABLE IF EXISTS `templates_menus`;
CREATE TABLE IF NOT EXISTS `templates_menus` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`template_key` varchar(50) NOT NULL,
`menu_id` int(11) NOT NULL,
`is_load` int(11) NOT NULL DEFAULT '1',
`priority` int(11) DEFAULT NULL,
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `templates_menus`
--
INSERT INTO `templates_menus` (`id`, `template_key`, `menu_id`, `is_load`, `priority`, `created`, `modified`) VALUES
(1, 'sys_admin', 1, 1, 0, '2017-06-13 08:15:35', '2017-06-13 08:15:35'),
(2, 'sys_admin', 2, 1, 1, '2017-06-13 08:15:35', '2017-06-13 08:15:35'),
(3, 'sys_admin', 3, 1, 2, '2017-06-13 08:15:35', '2017-06-13 08:15:35'),
(4, 'sys_admin', 4, 1, 3, '2017-06-13 08:15:35', '2017-06-13 08:15:35'),
(5, 'sys_admin', 5, 1, 4, '2017-06-13 08:15:35', '2017-06-13 08:15:35'),
(6, 'sys_admin', 6, 1, 5, '2017-06-13 08:15:35', '2017-06-13 08:15:35'),
(7, 'sys_admin', 7, 1, 6, '2017-06-13 08:15:35', '2017-06-13 08:15:35'),
(8, 'sys_admin', 8, 1, 7, '2017-06-13 08:15:35', '2017-06-13 08:15:35'),
(9, 'sys_admin', 9, 1, 8, '2017-06-13 08:15:35', '2017-06-13 08:15:35');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`ip_address` varchar(15) NOT NULL,
`username` varchar(100) DEFAULT NULL,
`password` varchar(255) NOT NULL,
`salt` varchar(255) DEFAULT NULL,
`email` varchar(100) NOT NULL,
`activation_code` varchar(40) DEFAULT NULL,
`forgotten_password_code` varchar(40) DEFAULT NULL,
`forgotten_password_time` int(11) UNSIGNED DEFAULT NULL,
`remember_code` varchar(40) DEFAULT NULL,
`created_on` int(11) UNSIGNED NOT NULL,
`last_login` int(11) UNSIGNED DEFAULT NULL,
`first_login` tinyint(1) NOT NULL DEFAULT '1',
`active` tinyint(1) UNSIGNED DEFAULT NULL,
`first_name` varchar(50) DEFAULT NULL,
`last_name` varchar(50) DEFAULT NULL,
`company` varchar(100) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`lang_folder` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `ip_address`, `username`, `password`, `salt`, `email`, `activation_code`, `forgotten_password_code`, `forgotten_password_time`, `remember_code`, `created_on`, `last_login`, `first_login`, `active`, `first_name`, `last_name`, `company`, `phone`, `lang_folder`) VALUES
(1, '127.0.0.1', 'administrator', '$2a$07$SeBknntpZror9uyftVopmu61qg0ms8Qv1yV6FG.kQOSM.9QhmTo36', '', 'admin@admin.com', '', NULL, NULL, NULL, 1268889823, NULL, 1, 1, 'Admin', 'istrator', 'ADMIN', '0', 'english');
-- --------------------------------------------------------
--
-- Table structure for table `users_groups`
--
DROP TABLE IF EXISTS `users_groups`;
CREATE TABLE IF NOT EXISTS `users_groups` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` int(11) UNSIGNED NOT NULL,
`group_id` mediumint(8) UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uc_users_groups` (`user_id`,`group_id`),
KEY `fk_users_groups_users1_idx` (`user_id`),
KEY `fk_users_groups_groups1_idx` (`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `users_groups`
--
INSERT INTO `users_groups` (`id`, `user_id`, `group_id`) VALUES
(1, 1, 1),
(2, 1, 2);
-- --------------------------------------------------------
--
-- Table structure for table `views`
--
DROP TABLE IF EXISTS `views`;
CREATE TABLE IF NOT EXISTS `views` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`view_name` varchar(255) NOT NULL,
`module_name` varchar(255) NOT NULL,
`platform_id` int(11) NOT NULL,
`allow_delete` int(1) NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Table structure for table `controllers`
--
DROP TABLE IF EXISTS `controllers`;
CREATE TABLE IF NOT EXISTS `controllers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`controller_name` varchar(255) NOT NULL,
`controller_key` varchar(255) NOT NULL,
`directory` varchar(255) NOT NULL,
`template_key` varchar(255) NOT NULL,
`is_backend` int(1) NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `ci_controllers`
--
INSERT INTO `controllers` (`id`, `controller_name`, `controller_key`, `template_key`, `is_backend`, `created`, `modified`) VALUES
(1, 'Admin.php', 'admin', 'sys_admin', 1, '2017-06-24 11:33:16', '2017-06-24 04:33:16'),
(2, 'Ajax.php', 'ajax', 'sys_admin', 1, '2017-06-24 11:33:16', '2017-06-24 04:33:16'),
(3, 'Auth.php', 'auth', 'sys_admin', 1, '2017-06-24 11:33:16', '2017-06-24 04:33:16'),
(4, 'Code.php', 'code', 'sys_admin', 1, '2017-06-24 11:33:16', '2017-06-24 04:33:16'),
(5, 'Commons.php', 'commons', 'sys_admin', 1, '2017-06-24 11:33:16', '2017-06-24 04:33:16'),
(6, 'Controllers.php', 'controllers', 'sys_admin', 1, '2017-06-24 11:33:16', '2017-06-24 04:33:16'),
(7, 'Databases.php', 'databases', 'sys_admin', 1, '2017-06-24 11:33:16', '2017-06-24 04:33:16'),
(8, 'Elements.php', 'elements', 'sys_admin', 1, '2017-06-24 11:33:16', '2017-06-24 04:33:16'),
(9, 'Extensions.php', 'extensions', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(10, 'Home.php', 'home', 'web', 0, '2017-06-24 11:33:17', '2017-06-24 08:24:52'),
(11, 'Languages.php', 'languages', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(12, 'Menus.php', 'menus', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(13, 'Models.php', 'models', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(14, 'Modules.php', 'modules', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(15, 'My_constants.php', 'my_constants', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(16, 'Platforms.php', 'platforms', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(17, 'Routers.php', 'routers', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(18, 'Supports.php', 'supports', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(19, 'Templates.php', 'templates', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(20, 'Tree.php', 'tree', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(21, 'Users.php', 'users', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(22, 'Views.php', 'views', 'sys_admin', 1, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(23, 'Welcome.php', 'welcome', 'web', 0, '2017-06-24 11:33:17', '2017-06-24 04:33:17'),
(24, 'Dev.php', 'dev', 'sys_admin', 1, '2017-06-24 15:23:52', '2017-06-24 08:23:52'),
(25, 'Generate.php', 'generate', 'sys_admin', 1, '2017-06-24 15:23:52', '2017-06-24 08:23:52');
DROP TABLE IF EXISTS `country`;
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Đang đổ dữ liệu cho bảng `country`
--
INSERT INTO `country` (`code`, `name`) VALUES
('AD', 'Andorra'),
('AE', 'United Arab Emirates'),
('AF', 'Afghanistan'),
('AG', 'Antigua and Barbuda'),
('AI', 'Anguilla'),
('AL', 'Albania'),
('AM', 'Armenia'),
('AN', 'Netherlands Antilles'),
('AO', 'Angola'),
('AQ', 'Antarctica'),
('AR', 'Argentina'),
('AS', 'American Samoa'),
('AT', 'Austria'),
('AU', 'Australia'),
('AW', 'Aruba'),
('AX', 'Ă…land Islands'),
('AZ', 'Azerbaijan'),
('BA', 'Bosnia and Herzegovina'),
('BB', 'Barbados'),
('BD', 'Bangladesh'),
('BE', 'Belgium'),
('BF', 'Burkina Faso'),
('BG', 'Bulgaria'),
('BH', 'Bahrain'),
('BI', 'Burundi'),
('BJ', 'Benin'),
('BL', 'Saint Barthélemy'),
('BM', 'Bermuda'),
('BN', 'Brunei'),
('BO', 'Bolivia'),
('BQ', 'British Antarctic Territory'),
('BR', 'Brazil'),
('BS', 'Bahamas'),
('BT', 'Bhutan'),
('BV', 'Bouvet Island'),
('BW', 'Botswana'),
('BY', 'Belarus'),
('BZ', 'Belize'),
('CA', 'Canada'),
('CC', 'Cocos [Keeling] Islands'),
('CD', 'Congo - Kinshasa'),
('CF', 'Central African Republic'),
('CG', 'Congo - Brazzaville'),
('CH', 'Switzerland'),
('CI', 'Côte d’Ivoire'),
('CK', 'Cook Islands'),
('CL', 'Chile'),
('CM', 'Cameroon'),
('CN', 'China'),
('CO', 'Colombia'),
('CR', 'Costa Rica'),
('CS', 'Serbia and Montenegro'),
('CT', 'Canton and Enderbury Islands'),
('CU', 'Cuba'),
('CV', 'Cape Verde'),
('CX', 'Christmas Island'),
('CY', 'Cyprus'),
('CZ', 'Czech Republic'),
('DD', 'East Germany'),
('DE', 'Germany'),
('DJ', 'Djibouti'),
('DK', 'Denmark'),
('DM', 'Dominica'),
('DO', 'Dominican Republic'),
('DZ', 'Algeria'),
('EC', 'Ecuador'),
('EE', 'Estonia'),
('EG', 'Egypt'),
('EH', 'Western Sahara'),
('ER', 'Eritrea'),
('ES', 'Spain'),
('ET', 'Ethiopia'),
('FI', 'Finland'),
('FJ', 'Fiji'),
('FK', 'Falkland Islands'),
('FM', 'Micronesia'),
('FO', 'Faroe Islands'),
('FQ', 'French Southern and Antarctic Territories'),
('FR', 'France'),
('FX', 'Metropolitan France'),
('GA', 'Gabon'),
('GB', 'United Kingdom'),
('GD', 'Grenada'),
('GE', 'Georgia'),
('GF', 'French Guiana'),
('GG', 'Guernsey'),
('GH', 'Ghana'),
('GI', 'Gibraltar'),
('GL', 'Greenland'),
('GM', 'Gambia'),
('GN', 'Guinea'),
('GP', 'Guadeloupe'),
('GQ', 'Equatorial Guinea'),
('GR', 'Greece'),
('GS', 'South Georgia and the South Sandwich Islands'),
('GT', 'Guatemala'),
('GU', 'Guam'),
('GW', 'Guinea-Bissau'),
('GY', 'Guyana'),
('HK', 'Hong Kong SAR China'),
('HM', 'Heard Island and McDonald Islands'),
('HN', 'Honduras'),
('HR', 'Croatia'),
('HT', 'Haiti'),
('HU', 'Hungary'),
('ID', 'Indonesia'),
('IE', 'Ireland'),
('IL', 'Israel'),
('IM', 'Isle of Man'),
('IN', 'India'),
('IO', 'British Indian Ocean Territory'),
('IQ', 'Iraq'),
('IR', 'Iran'),
('IS', 'Iceland'),
('IT', 'Italy'),
('JE', 'Jersey'),
('JM', 'Jamaica'),
('JO', 'Jordan'),
('JP', 'Japan'),
('JT', 'Johnston Island'),
('KE', 'Kenya'),
('KG', 'Kyrgyzstan'),
('KH', 'Cambodia'),
('KI', 'Kiribati'),
('KM', 'Comoros'),
('KN', 'Saint Kitts and Nevis'),
('KP', 'North Korea'),
('KR', 'South Korea'),
('KW', 'Kuwait'),
('KY', 'Cayman Islands'),
('KZ', 'Kazakhstan'),
('LA', 'Laos'),
('LB', 'Lebanon'),
('LC', 'Saint Lucia'),
('LI', 'Liechtenstein'),
('LK', 'Sri Lanka'),
('LR', 'Liberia'),
('LS', 'Lesotho'),
('LT', 'Lithuania'),
('LU', 'Luxembourg'),
('LV', 'Latvia'),
('LY', 'Libya'),
('MA', 'Morocco'),
('MC', 'Monaco'),
('MD', 'Moldova'),
('ME', 'Montenegro'),
('MF', 'Saint Martin'),
('MG', 'Madagascar'),
('MH', 'Marshall Islands'),
('MI', 'Midway Islands'),
('MK', 'Macedonia'),
('ML', 'Mali'),
('MM', 'Myanmar [Burma]'),
('MN', 'Mongolia'),
('MO', 'Macau SAR China'),
('MP', 'Northern Mariana Islands'),
('MQ', 'Martinique'),
('MR', 'Mauritania'),
('MS', 'Montserrat'),
('MT', 'Malta'),
('MU', 'Mauritius'),
('MV', 'Maldives'),
('MW', 'Malawi'),
('MX', 'Mexico'),
('MY', 'Malaysia'),
('MZ', 'Mozambique'),
('NA', 'Namibia'),
('NC', 'New Caledonia'),
('NE', 'Niger'),
('NF', 'Norfolk Island'),
('NG', 'Nigeria'),
('NI', 'Nicaragua'),
('NL', 'Netherlands'),
('NO', 'Norway'),
('NP', 'Nepal'),
('NQ', 'Dronning Maud Land'),
('NR', 'Nauru'),
('NT', 'Neutral Zone'),
('NU', 'Niue'),
('NZ', 'New Zealand'),
('OM', 'Oman'),
('PA', 'Panama'),
('PC', 'Pacific Islands Trust Territory'),
('PE', 'Peru'),
('PF', 'French Polynesia'),
('PG', 'Papua New Guinea'),
('PH', 'Philippines'),
('PK', 'Pakistan'),
('PL', 'Poland'),
('PM', 'Saint Pierre and Miquelon'),
('PN', 'Pitcairn Islands'),
('PR', 'Puerto Rico'),
('PS', 'Palestinian Territories'),
('PT', 'Portugal'),
('PU', 'U.S. Miscellaneous Pacific Islands'),
('PW', 'Palau'),
('PY', 'Paraguay'),
('PZ', 'Panama Canal Zone'),
('QA', 'Qatar'),
('RE', 'Réunion'),
('RO', 'Romania'),
('RS', 'Serbia'),
('RU', 'Russia'),
('RW', 'Rwanda'),
('SA', 'Saudi Arabia'),
('SB', 'Solomon Islands'),
('SC', 'Seychelles'),
('SD', 'Sudan'),
('SE', 'Sweden'),
('SG', 'Singapore'),
('SH', 'Saint Helena'),
('SI', 'Slovenia'),
('SJ', 'Svalbard and Jan Mayen'),
('SK', 'Slovakia'),
('SL', 'Sierra Leone'),
('SM', 'San Marino'),
('SN', 'Senegal'),
('SO', 'Somalia'),
('SR', 'Suriname'),
('ST', 'SĂ£o TomĂ© and PrĂncipe'),
('SU', 'Union of Soviet Socialist Republics'),
('SV', 'El Salvador'),
('SY', 'Syria'),
('SZ', 'Swaziland'),
('TC', 'Turks and Caicos Islands'),
('TD', 'Chad'),
('TF', 'French Southern Territories'),
('TG', 'Togo'),
('TH', 'Thailand'),
('TJ', 'Tajikistan'),
('TK', 'Tokelau'),
('TL', 'Timor-Leste'),
('TM', 'Turkmenistan'),
('TN', 'Tunisia'),
('TO', 'Tonga'),
('TR', 'Turkey'),
('TT', 'Trinidad and Tobago'),
('TV', 'Tuvalu'),
('TW', 'Taiwan'),
('TZ', 'Tanzania'),
('UA', 'Ukraine'),
('UG', 'Uganda'),
('UM', 'U.S. Minor Outlying Islands'),
('US', 'United States'),
('UY', 'Uruguay'),
('UZ', 'Uzbekistan'),
('VA', 'Vatican City'),
('VC', 'Saint Vincent and the Grenadines'),
('VD', 'North Vietnam'),
('VE', 'Venezuela'),
('VG', 'British Virgin Islands'),
('VI', 'U.S. Virgin Islands'),
('VN', 'Vietnam'),
('VU', 'Vanuatu'),
('WF', 'Wallis and Futuna'),
('WK', 'Wake Island'),
('WS', 'Samoa'),
('YD', 'People\'s Democratic Republic of Yemen'),
('YE', 'Yemen'),
('YT', 'Mayotte'),
('ZA', 'South Africa'),
('ZM', 'Zambia'),
('ZW', 'Zimbabwe'),
('ZZ', 'Unknown or Invalid Region');
--
-- Table structure for table `access_right`
--
DROP TABLE IF EXISTS `access_rights`;
CREATE TABLE IF NOT EXISTS `access_rights` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`control` varchar(255) NOT NULL,
`action` varchar(255) DEFAULT NULL,
`require_login` int(11) UNSIGNED NOT NULL DEFAULT '0',
`allow_delete` int(11) UNSIGNED NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
INSERT INTO `access_rights` (`id`, `control`, `action`, `require_login`, `allow_delete`) VALUES
(1, 'Admin', 'index', 1, 1),
(2, 'Admin', 'edit', 1, 1),
(3, 'Admin', 'delete', 1, 1),
(4, 'Ajax', 'index', 1, 1),
(5, 'Auth', 'index', 1, 1),
(6, 'Auth', 'delete_user', 1, 1),
(7, 'Auth', 'change_password', 1, 1),
(8, 'Auth', 'forgot_password', 0, 1),
(9, 'Auth', 'reset_password', 0, 1),
(10, 'Auth', 'activate', 0, 1),
(11, 'Auth', 'deactivate', 1, 1),
(12, 'Auth', 'create_user', 1, 1),
(13, 'Auth', 'edit_user', 1, 1),
(14, 'Auth', 'create_group', 1, 1),
(15, 'Auth', 'edit_group', 1, 1),
(16, 'Auth', '_get_csrf_nonce', 1, 1),
(17, 'Auth', '_valid_csrf_nonce', 1, 1),
(18, 'Auth', '_render_page', 1, 1),
(19, 'Code', 'eval_php', 1, 1),
(20, 'Code', 'getErrorName', 1, 1),
(21, 'Code', 'index', 1, 1),
(22, 'Code', 'edit', 1, 1),
(23, 'Code', 'delete', 1, 1),
(24, 'Commons', 'index', 1, 1),
(25, 'Commons', 'create', 1, 1),
(26, 'Commons', 'edit', 1, 1),
(27, 'Commons', 'delete', 1, 1),
(28, 'Controllers', 'index', 1, 1),
(29, 'Controllers', 'create', 1, 1),
(30, 'Controllers', 'edit', 1, 1),
(31, 'Controllers', 'detail', 1, 1),
(32, 'Controllers', 'delete', 1, 1),
(33, 'Databases', 'index', 1, 1),
(34, 'Databases', 'reset', 1, 1),
(35, 'Databases', 'create', 1, 1),
(36, 'Databases', 'edit', 1, 1),
(37, 'Databases', 'delete', 1, 1),
(38, 'Databases', 'rename', 1, 1),
(39, 'Dev', 'index', 1, 1),
(40, 'Dev', 'profile', 1, 1),
(41, 'Dev', 'user_profile', 1, 1),
(42, 'Dev', 'user_settings', 1, 1),
(43, 'Dev', 'db_resetdb', 1, 1),
(44, 'Dev', 'db_check_database', 1, 1),
(45, 'Dev', 'db_check_connection', 1, 1),
(46, 'Dev', 'change_db_setting', 1, 1),
(47, 'Dev', 'form_ajax', 1, 1),
(48, 'Dev', 'setting', 1, 1),
(49, 'Dev', 'formbuilder', 1, 1),
(50, 'Dev', 'delete', 1, 1),
(51, 'Dev', 'parse_arr_2_str', 1, 1),
(52, 'Dev', 'loop_var_value', 1, 1),
(53, 'Dev', 'confirm_delete', 1, 1),
(54, 'Elements', 'index', 1, 1),
(55, 'Elements', 'create', 1, 1),
(56, 'Elements', 'edit', 1, 1),
(57, 'Elements', 'delete', 1, 1),
(58, 'Extensions', 'index', 1, 1),
(59, 'Extensions', 'edit', 1, 1),
(60, 'Extensions', 'download', 1, 1),
(61, 'Extensions', 'detail', 1, 1),
(62, 'Extensions', 'create', 1, 1),
(63, 'Extensions', 'delete', 1, 1),
(64, 'Extensions', 'import', 1, 1),
(65, 'Extensions', 'check_existed_extension_key', 1, 1),
(66, 'Extensions', 'get_list_extension', 1, 1),
(67, 'Generate', 'index', 1, 1),
(68, 'Generate', 'controller', 1, 1),
(69, 'Generate', 'model', 1, 1),
(70, 'Generate', 'write_php_ini', 1, 1),
(71, 'Generate', 'view', 1, 1),
(72, 'Generate', 'library', 1, 1),
(73, 'Generate', 'helper', 1, 1),
(74, 'Generate', '_add_contruct', 1, 1),
(75, 'Generate', 'result', 1, 1),
(76, 'Home', 'index', 1, 1),
(77, 'Languages', 'index', 1, 1),
(78, 'Languages', 'create', 1, 1),
(79, 'Languages', 'edit', 1, 1),
(80, 'Languages', 'delete', 1, 1),
(81, 'Languages', 'common', 1, 1),
(82, 'Languages', 'compare', 1, 1),
(83, 'Languages', 'region', 1, 1),
(84, 'Menus', 'index', 1, 1),
(85, 'Menus', 'sub_menu', 1, 1),
(86, 'Menus', 'create', 1, 1),
(87, 'Menus', 'edit', 1, 1),
(88, 'Menus', 'delete', 1, 1),
(89, 'Models', 'index', 1, 1),
(90, 'Models', 'create', 1, 1),
(91, 'Models', 'edit', 1, 1),
(92, 'Models', 'delete', 1, 1),
(93, 'Modules', 'index', 1, 1),
(94, 'Modules', 'create', 1, 1),
(95, 'Modules', 'edit', 1, 1),
(96, 'Modules', 'delete', 1, 1),
(97, 'My_constants', 'checkConstantExist', 1, 1),
(98, 'My_constants', 'create', 1, 1),
(99, 'My_constants', 'edit', 1, 1),
(100, 'My_constants', 'delete', 1, 1),
(101, 'Platforms', 'index', 1, 1),
(102, 'Platforms', 'create', 1, 1),
(103, 'Platforms', 'edit', 1, 1),
(104, 'Platforms', 'set_default', 1, 1),
(105, 'Platforms', 'delete', 1, 1),
(106, 'Platforms', 'get_default_platform', 1, 1),
(107, 'Routers', 'index', 1, 1),
(108, 'Routers', 'create', 1, 1),
(109, 'Routers', 'edit', 1, 1),
(110, 'Routers', 'delete', 1, 1),
(111, 'Supports', 'index', 1, 1),
(112, 'Supports', 'create', 1, 1),
(113, 'Supports', 'edit', 1, 1),
(114, 'Supports', 'delete', 1, 1),
(115, 'Templates', 'index', 1, 1),
(116, 'Templates', 'create', 1, 1),
(117, 'Templates', 'edit', 1, 1),
(118, 'Templates', 'detail', 1, 1),
(119, 'Templates', 'delete', 1, 1),
(120, 'Templates', 'check_existed_template_key', 1, 1),
(121, 'Templates', 'create_template_directory', 1, 1),
(122, 'Templates', 'template_loader', 1, 1),
(123, 'Templates', 'get_default_template', 1, 1),
(124, 'Tree', 'index', 1, 1),
(125, 'Tree', 'loadExtensionFolder', 1, 1),
(126, 'Tree', 'loadTemplateFolder', 1, 1),
(127, 'Tree', 'loadTemplateCommonFolder', 1, 1),
(128, 'Users', 'index', 1, 1),
(129, 'Users', 'edit', 1, 1),
(130, 'Users', 'access_right', 1, 1),
(131, 'Users', 'enable_access_right', 1, 1),
(132, 'Users', 'set_require_login', 1, 1),
(133, 'Users', 'delete', 1, 1),
(134, 'Users', 'update_last_login', 1, 1),
(135, 'Users', 'check_expired_session', 1, 1),
(136, 'Users', 'change_language', 1, 1),
(137, 'Views', 'index', 1, 1),
(138, 'Views', 'detail', 1, 1),
(139, 'Views', 'create', 1, 1),
(140, 'Views', 'edit', 1, 1),
(141, 'Views', 'delete', 1, 1),
(142, 'Views', 'preview', 1, 1),
(143, 'Views', 'get_preview_box', 1, 1),
(144, 'Views', 'edit_info', 1, 1),
(145, 'Welcome', 'index', 1, 1);
DROP TABLE IF EXISTS `access_right_groups`;
CREATE TABLE IF NOT EXISTS `access_right_groups` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`access_right_id` int(11) UNSIGNED NOT NULL,
`group_id` int(11) UNSIGNED NOT NULL,
`enable` int(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `uc_access_rights_groups` (`access_right_id`,`group_id`),
KEY `fk_access_rights_access_right_groups1_idx` (`access_right_id`),
KEY `fk_access_right_groups_groups1_idx` (`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
INSERT INTO `access_right_groups` (`id`, `access_right_id`, `group_id`, `enable`) VALUES
(1, 1, 1, 1),
(2, 1, 2, 0),
(3, 1, 3, 0),
(4, 2, 1, 1),
(5, 2, 2, 0),
(6, 2, 3, 0),
(7, 3, 1, 1),
(8, 3, 2, 0),
(9, 3, 3, 0),
(10, 4, 1, 1),
(11, 4, 2, 0),
(12, 4, 3, 0),
(13, 5, 1, 1),
(14, 5, 2, 0),
(15, 5, 3, 0),
(16, 6, 1, 1),
(17, 6, 2, 0),
(18, 6, 3, 0),
(19, 7, 1, 1),
(20, 7, 2, 0),
(21, 7, 3, 0),
(22, 8, 1, 1),
(23, 8, 2, 1),
(24, 8, 3, 1),
(25, 9, 1, 1),
(26, 9, 2, 1),
(27, 9, 3, 1),
(28, 10, 1, 1),
(29, 10, 2, 1),
(30, 10, 3, 1),
(31, 11, 1, 1),
(32, 11, 2, 0),
(33, 11, 3, 0),
(34, 12, 1, 1),
(35, 12, 2, 0),
(36, 12, 3, 0),
(37, 13, 1, 1),
(38, 13, 2, 0),
(39, 13, 3, 0),
(40, 14, 1, 1),
(41, 14, 2, 0),
(42, 14, 3, 0),
(43, 15, 1, 1),
(44, 15, 2, 0),
(45, 15, 3, 0),
(46, 16, 1, 1),
(47, 16, 2, 0),
(48, 16, 3, 0),
(49, 17, 1, 1),
(50, 17, 2, 0),
(51, 17, 3, 0),
(52, 18, 1, 1),
(53, 18, 2, 0),
(54, 18, 3, 0),
(55, 19, 1, 1),
(56, 19, 2, 0),
(57, 19, 3, 0),
(58, 20, 1, 1),
(59, 20, 2, 0),
(60, 20, 3, 0),
(61, 21, 1, 1),
(62, 21, 2, 0),
(63, 21, 3, 0),
(64, 22, 1, 1),
(65, 22, 2, 0),
(66, 22, 3, 0),
(67, 23, 1, 1),
(68, 23, 2, 0),
(69, 23, 3, 0),
(70, 24, 1, 1),
(71, 24, 2, 0),
(72, 24, 3, 0),
(73, 25, 1, 1),
(74, 25, 2, 0),
(75, 25, 3, 0),
(76, 26, 1, 1),
(77, 26, 2, 0),
(78, 26, 3, 0),
(79, 27, 1, 1),
(80, 27, 2, 0),
(81, 27, 3, 0),
(82, 28, 1, 1),
(83, 28, 2, 0),
(84, 28, 3, 0),
(85, 29, 1, 1),
(86, 29, 2, 0),
(87, 29, 3, 0),
(88, 30, 1, 1),
(89, 30, 2, 0),
(90, 30, 3, 0),
(91, 31, 1, 1),
(92, 31, 2, 0),
(93, 31, 3, 0),
(94, 32, 1, 1),
(95, 32, 2, 0),
(96, 32, 3, 0),
(97, 33, 1, 1),
(98, 33, 2, 0),
(99, 33, 3, 0),
(100, 34, 1, 1),
(101, 34, 2, 0),
(102, 34, 3, 0),
(103, 35, 1, 1),
(104, 35, 2, 0),
(105, 35, 3, 0),
(106, 36, 1, 1),
(107, 36, 2, 0),
(108, 36, 3, 0),
(109, 37, 1, 1),
(110, 37, 2, 0),
(111, 37, 3, 0),
(112, 38, 1, 1),
(113, 38, 2, 0),
(114, 38, 3, 0),
(115, 39, 1, 1),
(116, 39, 2, 0),
(117, 39, 3, 0),
(118, 40, 1, 1),
(119, 40, 2, 0),
(120, 40, 3, 0),
(121, 41, 1, 1),
(122, 41, 2, 0),
(123, 41, 3, 0),
(124, 42, 1, 1),
(125, 42, 2, 0),
(126, 42, 3, 0),
(127, 43, 1, 1),
(128, 43, 2, 0),
(129, 43, 3, 0),
(130, 44, 1, 1),
(131, 44, 2, 0),
(132, 44, 3, 0),
(133, 45, 1, 1),
(134, 45, 2, 0),
(135, 45, 3, 0),
(136, 46, 1, 1),
(137, 46, 2, 0),
(138, 46, 3, 0),
(139, 47, 1, 1),
(140, 47, 2, 0),
(141, 47, 3, 0),
(142, 48, 1, 1),
(143, 48, 2, 0),
(144, 48, 3, 0),
(145, 49, 1, 1),
(146, 49, 2, 0),
(147, 49, 3, 0),
(148, 50, 1, 1),
(149, 50, 2, 0),
(150, 50, 3, 0),
(151, 51, 1, 1),
(152, 51, 2, 0),
(153, 51, 3, 0),
(154, 52, 1, 1),
(155, 52, 2, 0),
(156, 52, 3, 0),
(157, 53, 1, 1),
(158, 53, 2, 0),
(159, 53, 3, 0),
(160, 54, 1, 1),
(161, 54, 2, 0),
(162, 54, 3, 0),
(163, 55, 1, 1),
(164, 55, 2, 0),
(165, 55, 3, 0),
(166, 56, 1, 1),
(167, 56, 2, 0),
(168, 56, 3, 0),
(169, 57, 1, 1),
(170, 57, 2, 0),
(171, 57, 3, 0),
(172, 58, 1, 1),
(173, 58, 2, 0),
(174, 58, 3, 0),
(175, 59, 1, 1),
(176, 59, 2, 0),
(177, 59, 3, 0),
(178, 60, 1, 1),
(179, 60, 2, 0),
(180, 60, 3, 0),
(181, 61, 1, 1),
(182, 61, 2, 0),
(183, 61, 3, 0),
(184, 62, 1, 1),
(185, 62, 2, 0),
(186, 62, 3, 0),
(187, 63, 1, 1),
(188, 63, 2, 0),
(189, 63, 3, 0),
(190, 64, 1, 1),
(191, 64, 2, 0),
(192, 64, 3, 0),
(193, 65, 1, 1),
(194, 65, 2, 0),
(195, 65, 3, 0),
(196, 66, 1, 1),
(197, 66, 2, 0),
(198, 66, 3, 0),
(199, 67, 1, 1),
(200, 67, 2, 0),
(201, 67, 3, 0),
(202, 68, 1, 1),
(203, 68, 2, 0),
(204, 68, 3, 0),
(205, 69, 1, 1),
(206, 69, 2, 0),
(207, 69, 3, 0),
(208, 70, 1, 1),
(209, 70, 2, 0),
(210, 70, 3, 0),
(211, 71, 1, 1),
(212, 71, 2, 0),
(213, 71, 3, 0),
(214, 72, 1, 1),
(215, 72, 2, 0),
(216, 72, 3, 0),
(217, 73, 1, 1),
(218, 73, 2, 0),
(219, 73, 3, 0),
(220, 74, 1, 1),
(221, 74, 2, 0),
(222, 74, 3, 0),
(223, 75, 1, 1),
(224, 75, 2, 1),
(225, 75, 3, 1),
(226, 76, 1, 1),
(227, 76, 2, 0),
(228, 76, 3, 0),
(229, 77, 1, 1),
(230, 77, 2, 0),
(231, 77, 3, 0),
(232, 78, 1, 1),
(233, 78, 2, 0),
(234, 78, 3, 0),
(235, 79, 1, 1),
(236, 79, 2, 0),
(237, 79, 3, 0),
(238, 80, 1, 1),
(239, 80, 2, 0),
(240, 80, 3, 0),
(241, 81, 1, 1),
(242, 81, 2, 0),
(243, 81, 3, 0),
(244, 82, 1, 1),
(245, 82, 2, 0),
(246, 82, 3, 0),
(247, 83, 1, 1),
(248, 83, 2, 0),
(249, 83, 3, 0),
(250, 84, 1, 1),
(251, 84, 2, 0),
(252, 84, 3, 0),
(253, 85, 1, 1),
(254, 85, 2, 0),
(255, 85, 3, 0),
(256, 86, 1, 1),
(257, 86, 2, 0),
(258, 86, 3, 0),
(259, 87, 1, 1),
(260, 87, 2, 0),
(261, 87, 3, 0),
(262, 88, 1, 1),
(263, 88, 2, 0),
(264, 88, 3, 0),
(265, 89, 1, 1),
(266, 89, 2, 0),
(267, 89, 3, 0),
(268, 90, 1, 1),
(269, 90, 2, 0),
(270, 90, 3, 0),
(271, 91, 1, 1),
(272, 91, 2, 0),
(273, 91, 3, 0),
(274, 92, 1, 1),
(275, 92, 2, 0),
(276, 92, 3, 0),
(277, 93, 1, 1),
(278, 93, 2, 0),
(279, 93, 3, 0),
(280, 94, 1, 1),
(281, 94, 2, 0),
(282, 94, 3, 0),
(283, 95, 1, 1),
(284, 95, 2, 0),
(285, 95, 3, 0),
(286, 96, 1, 1),
(287, 96, 2, 0),
(288, 96, 3, 0),
(289, 97, 1, 1),
(290, 97, 2, 0),
(291, 97, 3, 0),
(292, 98, 1, 1),
(293, 98, 2, 0),
(294, 98, 3, 0),
(295, 99, 1, 1),
(296, 99, 2, 0),
(297, 99, 3, 0),
(298, 100, 1, 1),
(299, 100, 2, 0),
(300, 100, 3, 0),
(301, 101, 1, 1),
(302, 101, 2, 0),
(303, 101, 3, 0),
(304, 102, 1, 1),
(305, 102, 2, 0),
(306, 102, 3, 0),
(307, 103, 1, 1),
(308, 103, 2, 0),
(309, 103, 3, 0),
(310, 104, 1, 1),
(311, 104, 2, 0),
(312, 104, 3, 0),
(313, 105, 1, 1),
(314, 105, 2, 0),
(315, 105, 3, 0),
(316, 106, 1, 1),
(317, 106, 2, 0),
(318, 106, 3, 0),
(319, 107, 1, 1),
(320, 107, 2, 0),
(321, 107, 3, 0),
(322, 108, 1, 1),
(323, 108, 2, 0),
(324, 108, 3, 0),
(325, 109, 1, 1),
(326, 109, 2, 0),
(327, 109, 3, 0),
(328, 110, 1, 1),
(329, 110, 2, 0),
(330, 110, 3, 0),
(331, 111, 1, 1),
(332, 111, 2, 0),
(333, 111, 3, 0),
(334, 112, 1, 1),
(335, 112, 2, 0),
(336, 112, 3, 0),
(337, 113, 1, 1),
(338, 113, 2, 0),
(339, 113, 3, 0),
(340, 114, 1, 1),
(341, 114, 2, 0),
(342, 114, 3, 0),
(343, 115, 1, 1),
(344, 115, 2, 0),
(345, 115, 3, 0),
(346, 116, 1, 1),
(347, 116, 2, 0),
(348, 116, 3, 0),
(349, 117, 1, 1),
(350, 117, 2, 0),
(351, 117, 3, 0),
(352, 118, 1, 1),
(353, 118, 2, 0),
(354, 118, 3, 0),
(355, 119, 1, 1),
(356, 119, 2, 0),
(357, 119, 3, 0),
(358, 120, 1, 1),
(359, 120, 2, 0),
(360, 120, 3, 0),
(361, 121, 1, 1),
(362, 121, 2, 0),
(363, 121, 3, 0),
(364, 122, 1, 1),
(365, 122, 2, 0),
(366, 122, 3, 0),
(367, 123, 1, 1),
(368, 123, 2, 0),
(369, 123, 3, 0),
(370, 124, 1, 1),
(371, 124, 2, 0),
(372, 124, 3, 0),
(373, 125, 1, 1),
(374, 125, 2, 0),
(375, 125, 3, 0),
(376, 126, 1, 1),
(377, 126, 2, 0),
(378, 126, 3, 0),
(379, 127, 1, 1),
(380, 127, 2, 0),
(381, 127, 3, 0),
(382, 128, 1, 1),
(383, 128, 2, 0),
(384, 128, 3, 0),
(385, 129, 1, 1),
(386, 129, 2, 0),
(387, 129, 3, 0),
(388, 130, 1, 1),
(389, 130, 2, 0),
(390, 130, 3, 0),
(391, 131, 1, 1),
(392, 131, 2, 0),
(393, 131, 3, 0),
(394, 132, 1, 1),
(395, 132, 2, 0),
(396, 132, 3, 0),
(397, 133, 1, 1),
(398, 133, 2, 0),
(399, 133, 3, 0),
(400, 134, 1, 1),
(401, 134, 2, 0),
(402, 134, 3, 0),
(403, 135, 1, 1),
(404, 135, 2, 0),
(405, 135, 3, 0),
(406, 136, 1, 1),
(407, 136, 2, 0),
(408, 136, 3, 0),
(409, 137, 1, 1),
(410, 137, 2, 0),
(411, 137, 3, 0),
(412, 138, 1, 1),
(413, 138, 2, 0),
(414, 138, 3, 0),
(415, 139, 1, 1),
(416, 139, 2, 0),
(417, 139, 3, 0),
(418, 140, 1, 1),
(419, 140, 2, 0),
(420, 140, 3, 0),
(421, 141, 1, 1),
(422, 141, 2, 0),
(423, 141, 3, 0),
(424, 142, 1, 1),
(425, 142, 2, 0),
(426, 142, 3, 0),
(427, 143, 1, 1),
(428, 143, 2, 0),
(429, 143, 3, 0),
(430, 144, 1, 1),
(431, 144, 2, 1),
(432, 144, 3, 1);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `users_groups`
--
ALTER TABLE `users_groups`
ADD CONSTRAINT `fk_users_groups_groups1` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_users_groups_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
/*!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 */;
SET FOREIGN_KEY_CHECKS = 1; | true |
e72da057c1d6248417c8ace1a4962a051ce70b79 | SQL | vndn5419/fromnow | /target/classes/cryptokick.sql | UTF-8 | 6,447 | 3.265625 | 3 | [] | no_license |
/* Drop Tables */
DROP TABLE favorites CASCADE CONSTRAINTS;
DROP TABLE coupon CASCADE CONSTRAINTS;
DROP TABLE rereply CASCADE CONSTRAINTS;
DROP TABLE reply CASCADE CONSTRAINTS;
DROP TABLE sale CASCADE CONSTRAINTS;
DROP TABLE shipping CASCADE CONSTRAINTS;
DROP TABLE viewer CASCADE CONSTRAINTS;
DROP TABLE project CASCADE CONSTRAINTS;
DROP TABLE company CASCADE CONSTRAINTS;
DROP TABLE webadmin CASCADE CONSTRAINTS;
DROP TABLE webmember CASCADE CONSTRAINTS;
/* Create Tables */
CREATE TABLE webadmin
(
-- 관리자 아이디
admin_id varchar2(30) NOT NULL,
-- 관리자 비밀번호
admin_pwd varchar2(30) NOT NULL,
-- 관리자 전화번호
admin_phone varchar2(30) NOT NULL,
-- 관리자 이메일
admin_email varchar2(100),
-- 관리자 이름
admin_name varchar2(30) NOT NULL,
PRIMARY KEY (admin_id)
);
CREATE TABLE webmember
(
-- member 테이블의 pk 값, 회원아이디
--
userid varchar2(30) NOT NULL,
-- firstname
firstname varchar2(50) NOT NULL,
-- lastname
lastname varchar2(50) NOT NULL,
-- 회원 비밀번호
userpwd varchar2(30) NOT NULL,
-- 회원 성별
-- 'male' or 'female'
gender varchar2(20) NOT NULL,
-- 회원 생년월일
birthday date NOT NULL,
-- 회원 주소
phone varchar2(30) NOT NULL,
-- 회원 이메일
email varchar2(100) NOT NULL,
-- 회원 관심분야
hobby varchar2(1000),
image varchar2(2000),
-- country
country varchar2(100) not null,
-- zipcode
zipcode varchar2(100),
province varchar2(100),
-- city
city varchar2(100) not null,
-- address1
address1 varchar2(1000),
-- address2
address2 varchar2(1000),
PRIMARY KEY (userid)
);
CREATE TABLE company
(
-- 회사아이디
co_id varchar2(30) NOT NULL,
-- 회사명
co_name varchar2(50) NOT NULL,
-- 회사비밀번호
co_pwd varchar2(30) NOT NULL,
-- 회사 전화번호
co_phone varchar2(30) NOT NULL,
-- 회사 대표이메일
co_email varchar2(100) NOT NULL,
-- 회사 홈페이지
co_website varchar2(200) NOT NULL,
co_image varchar2(2000),
-- 회사 대표자명
co_ceo_firstname varchar2(50) NOT NULL,
co_ceo_lastname varchar2(50) NOT NULL,
-- co_zipcode
co_country varchar2(100) NOT NULL,
co_zipcode varchar2(100) NOT NULL,
co_province varchar2(100),
-- co_city
co_city varchar2(100) NOT NULL,
co_address1 varchar2(1000),
co_address2 varchar2(1000),
PRIMARY KEY (co_id)
);
CREATE TABLE project
(
project_num number NOT NULL,
project_title varchar2(100) NOT NULL,
project_coverImage varchar2(2000) NOT NULL,
project_content varchar2(3000) NOT NULL,
project_nowfundprice number NOT NULL,
project_goalfundprice number NOT NULL,
project_startdate date NOT NULL,
project_goaldate date NOT NULL,
project_hitcount number DEFAULT 0,
project_location varchar2(100) NOT NULL,
project_category varchar2(100) NOT NULL,
project_video varchar2(2000) NOT NULL,
reward_title varchar2(100) NOT NULL,
reward_price number not null,
reward_description varchar2(2000),
reward_deliverydate date,
project_checked varchar2(10) DEFAULT 'no' NOT NULL,
co_id varchar2(30) NOT NULL,
PRIMARY KEY (project_num),
foreign key(co_id) references company(co_id)
);
CREATE TABLE viewer
(
-- 접속 번호
viewer_num number NOT NULL,
-- 접속 국가 정보
viewer_countryinfo varchar2(100),
-- 접속 도시 정보
viewer_cityinfo varchar2(100),
-- 접속자 ip
viewer_ipinfo varchar2(200),
-- member 테이블의 pk 값, 회원아이디
--
userid varchar2(30),
-- 상품 번호
project_num number NOT NULL,
viewer_date date NOT NULL,
PRIMARY KEY (viewer_num),
foreign key(project_num) references project(project_num),
foreign key(userid) references webmember(userid)
);
CREATE TABLE reply
(
-- 리플 번호
reply_num number NOT NULL,
-- 리플 내용
reply_content varchar2(1000) NOT NULL,
userid varchar2(30) NOT NULL,
-- 상품 번호
project_num number NOT NULL,
reply_date date default sysdate not null,
PRIMARY KEY (reply_num),
foreign key(project_num) references project(project_num),
foreign key(userid) references webmember(userid)
);
CREATE TABLE rereply
(
-- 리리플번호
rereply_num number NOT NULL,
-- 리리플내용
rereply_content varchar2(1000) NOT NULL,
-- 리플 번호
reply_num number NOT NULL,
-- 상품 번호
project_num number NOT NULL,
-- 회사아이디
co_id varchar2(30) NOT NULL,
rereply_date date default sysdate not null,
PRIMARY KEY (rereply_num),
foreign key(co_id) references company(co_id),
foreign key(project_num) references project(project_num),
foreign key(reply_num) references reply(reply_num)
);
CREATE TABLE favorites
(
-- 상품 번호
project_num number NOT NULL,
-- member 테이블의 pk 값, 회원아이디
--
userid varchar2(30) NOT NULL,
foreign key(project_num) references project(project_num),
foreign key(userid) references webmember(userid)
);
CREATE TABLE shipping
(
shipping_num number primary key,
project_num number NOT NULL,
-- member 테이블의 pk 값, 회원아이디
shipping_country varchar2(100),
shipping_price number,
foreign key(project_num) references project(project_num)
);
CREATE TABLE coupon
(
coupon_num number primary key,
coupon_discountrate number not null,
coupon_used varchar2(10) default 'no',
coupon_date date,
coupon_code number not null,
project_num number,
userid varchar2(30),
foreign key(project_num) references project(project_num),
foreign key(userid) references webmember(userid)
);
CREATE TABLE sale
(
-- 판매 정보
sale_num number NOT NULL,
-- 판매 가격 정보
sale_totalprice number NOT NULL,
-- 판매 상품 개수
sale_amount number NOT NULL,
-- member 테이블의 pk 값, 회원아이디
--
userid varchar2(30) NOT NULL,
sale_date date NOT NULL,
-- pk
project_num number NOT NULL,
sale_phone varchar2(30) not null,
sale_email varchar2(100) not null,
sale_firstname varchar2(50) not null,
sale_lastname varchar2(50) not null,
sale_country varchar2(100) not null,
sale_zipcode varchar2(100),
sale_province varchar2(100),
sale_city varchar2(100) not null,
sale_address1 varchar2(1000),
sale_address2 varchar2(1000),
coupon_num number,
PRIMARY KEY (sale_num),
foreign key(project_num) references project(project_num),
foreign key(userid) references webmember(userid),
foreign key(coupon_num) references coupon(coupon_num)
); | true |
61367f36385ab8a8c97f91e9db81b56fc2ccb9a9 | SQL | Kunalgoel123/projectgladiator | /FinalVehicleLoanQuery (1).sql | UTF-8 | 2,990 | 3 | 3 | [] | no_license | create table ApplicantDetails(user_id int identity(1001,1) primary key,f_name varchar(20),m_name varchar(20),l_Name varchar(20),
DOB Date,gender varchar(10),mob varchar(20), email varchar(40),applicant_address_line1 varchar(100),applicant_address_line2 varchar(100),
res_state varchar(40),
city varchar(40),pincode varchar(20),landmark varchar(50),
emp_type varchar(50),yearly_salary varchar(40),other_income varchar(20),maritial_status varchar(10),
admin_login_id varchar(40) constraint fkloandetails2 foreign key references Bank_Admin(admin_login_id))
create table Document_Upload(user_id int constraint fkdocumentupload1 foreign key references ApplicantDetails(user_id),photo varbinary(max),
aadhar_card varbinary(max),pan_card varbinary(max),salary_slip varbinary(max),
admin_login_id varchar(40) constraint fkdocumentupload2 foreign key references Bank_Admin(admin_login_id))
alter table Document_Upload
drop constraint fkdocumentupload2
alter table Existing_Loan
drop constraint fkexisting_loans2
alter table VehicalDetails
drop constraint fkvehicaldetails2
alter table LoanDetails
drop constraint fkloandetails3
alter table LoanDetails
drop column admin_login_id
alter table Existing_Loan
drop column admin_login_id
alter table VehicalDetails
drop column admin_login_id
alter table Document_Upload
drop column admin_login_id
create table Existing_Loan(user_id int constraint fkexisting_loan1 foreign key references ApplicantDetails(user_id),
emi_id int identity(1,1),exising_loanamt varchar(20),
existing_emi varchar(20),exisitng_emi_month_left int,existing_emi_interest float,
admin_login_id varchar(40) constraint fkexisting_loans2 foreign key references Bank_Admin(admin_login_id))
create table VehicalDetails(user_id int constraint fkVehicalDetails1 foreign key references ApplicantDetails(user_id),vehical_id varchar(20) primary key,car_make
varchar(40),car_model varchar(20),Ex_showroom_price varchar(20),onroad_price varchar(20),
admin_login_id varchar(40) constraint fkvehicaldetails2 foreign key references Bank_Admin(admin_login_id))
create table LoanDetails(user_id int constraint fkloandetails1 foreign key references ApplicantDetails(user_id),loan_id varchar(10) primary key,loan_amt
varchar(20),loan_tenure varchar(20),loan_intrest float,loan_emi varchar(10),
)
alter table LoanDetails
add loan_start_date date
drop table UserRegistration
Create table UserRegistration(Firstname varchar(20),Middlename varchar(20),LastName varchar(20),EmailId varchar(20) primary key,Mobile varchar(20),
DOB date,pass varchar(20),admin_login_id varchar(40) constraint fkuserreg foreign key references Bank_Admin(admin_login_id))
create table Bank_Admin(admin_login_id varchar(40) primary key,pass varchar(20))
create table Track_Application(loan_id varchar(10) constraint fktrackapp1 foreign key references LoanDetails(loan_id),admin_login_id varchar(40) constraint fktrackapp2 foreign key references Bank_Admin(admin_login_id),loan_status varchar(10))
| true |
e0707d06233e42a14e1b29788971cdc021ffbbd7 | SQL | SilviaNobrega/AdventureWorksTest | /AdventureWorksTest/HumanResources/Tables/EmployeePayHistory.sql | UTF-8 | 828 | 3.453125 | 3 | [] | no_license | CREATE TABLE [HumanResources].[EmployeePayHistory] (
[BusinessEntityID] INT NOT NULL,
[RateChangeDate] DATETIME NOT NULL,
[Rate] MONEY NOT NULL,
[PayFrequency] TINYINT NOT NULL,
[ModifiedDate] DATETIME CONSTRAINT [DF_EmployeePayHistory_ModifiedDate] DEFAULT (getdate()) NOT NULL,
CONSTRAINT [PK_EmployeePayHistory_BusinessEntityID_RateChangeDate] PRIMARY KEY CLUSTERED ([BusinessEntityID] ASC, [RateChangeDate] ASC),
CONSTRAINT [CK_EmployeePayHistory_PayFrequency] CHECK ([PayFrequency]=(2) OR [PayFrequency]=(1)),
CONSTRAINT [CK_EmployeePayHistory_Rate] CHECK ([Rate]>=(6.50) AND [Rate]<=(200.00)),
CONSTRAINT [FK_EmployeePayHistory_Employee_BusinessEntityID] FOREIGN KEY ([BusinessEntityID]) REFERENCES [HumanResources].[Employee] ([BusinessEntityID])
);
| true |
c793d412edf7072c912df4d5c5bcb66b130af4fc | SQL | Creen/spring-example | /src/main/resources/init-ddl.sql | UTF-8 | 429 | 3.515625 | 4 | [] | no_license | -- DDL
CREATE TABLE IF NOT EXISTS stormtrooper (
stormtrooper_id BIGSERIAL PRIMARY KEY,
stormtrooper_name VARCHAR(255),
stormtrooper_age INT
);
CREATE TABLE IF NOT EXISTS weapon (
weapon_id BIGSERIAL PRIMARY KEY,
weapon_name VARCHAR (255),
stormtrooper_id INT,
CONSTRAINT fk_stormtrooper FOREIGN KEY (stormtrooper_id)
REFERENCES stormtrooper (stormtrooper_id) ON DELETE CASCADE
);
TRUNCATE TABLE stormtrooper CASCADE;
| true |
0ff324b481970c78073eeec4113f3311584259eb | SQL | DemiFr/SD202 | /SQL TP2/tpSQL2_2.sql | UTF-8 | 3,505 | 3.90625 | 4 | [] | no_license | /*
DECLARE
x NUMBER := 1;
BEGIN
WHILE x < 100 LOOP
DELETE FROM ACHATS WHERE nv=x;
x := x + 2;
END LOOP;
END;
/
BEGIN
FOR i IN 1..100 LOOP
IF MOD(i,2) = 0 THEN -- i est pair
UPDATE ACHATS SET QTE=QTE*2 WHERE nv=i;
ELSE
UPDATE ACHATS SET QTE=QTE/2 WHERE nv=i;
END IF;
END LOOP;
END;
/
CREATE TABLE TEMP (Vin NUMBER(3), description VARCHAR2(30),commentaire VARCHAR2(30));
DECLARE
cursor V_CUR is select * from vins
where nv in (select nv from recoltes, producteurs
where region='Alsace' and producteurs.np=recoltes.np)
order by nv;
-- declare record variable that represents a row fetched from the employees table
V_LIGNE VINS%ROWTYPE;
BEGIN
-- open the explicit cursor and use it to fetch data into employee_rec
open V_CUR;
loop
fetch V_CUR into V_Ligne;
exit when V_CUR%NOTFOUND;
IF V_Ligne.mill in (1976, 1978, 1983) THEN
INSERT INTO TEMP
VALUES (V_Ligne.nv, V_Ligne.cru || '(' || to_char(V_Ligne.mill) || ')', 'Récolte exeptionelle !');
ELSE
INSERT INTO TEMP
VALUES (V_Ligne.nv, V_Ligne.cru || '(' || to_char(V_Ligne.mill) || ')', 'RAS !');
END IF;
end loop;
close V_CUR;
END;
/
DECLARE
cursor V_CUR is select * from vins
where nv in (select nv from recoltes, producteurs
where region='Alsace' and producteurs.np=recoltes.np)
order by nv;
BEGIN
for V_Ligne in V_CUR
loop
IF V_Ligne.mill in (1976, 1978, 1983) THEN
INSERT INTO TEMP
VALUES (V_Ligne.nv, V_Ligne.cru || '(' || to_char(V_Ligne.mill) || ')', 'Récolte exeptionelle !');
ELSE
INSERT INTO TEMP
VALUES (V_Ligne.nv, V_Ligne.cru || '(' || to_char(V_Ligne.mill) || ')', 'RAS !');
END IF;
end loop;
END;
/
CREATE OR REPLACE PROCEDURE choix_experts AS
--DECLARE
cursor V_CUR is select * from vins
where nv in (select nv from recoltes, producteurs
where region='Alsace' and producteurs.np=recoltes.np)
order by nv;
BEGIN
for V_Ligne in V_CUR loop
IF V_Ligne.mill in (1976, 1978, 1983) THEN
INSERT INTO TEMP
VALUES (V_Ligne.nv, V_Ligne.cru || '(' || to_char(V_Ligne.mill) || ')', 'Récolte exeptionelle !');
ELSE
INSERT INTO TEMP
VALUES (V_Ligne.nv, V_Ligne.cru || '(' || to_char(V_Ligne.mill) || ')', 'RAS !');
END IF;
end loop;
END;
/
EXECUTE choix_experts;
/
/*
OU
BEGIN
choix_experts;
END;
/
*/
CREATE OR REPLACE FUNCTION recherche_vins (r PRODUCTEURS.REGION%TYPE, annee VINS.MILL%TYPE) RETURN number AS
--DECLARE
-- r PRODUCTEURS.REGION%TYPE;
-- annee VINS.MILL%TYPE;
cursor V_CUR is select * from vins
where nv in (select nv from recoltes, producteurs
where region=r and producteurs.np=recoltes.np)
order by nv;
cpt number:=0;
BEGIN
for V_Ligne in V_CUR
loop
IF V_Ligne.mill = annee THEN
INSERT INTO TEMP
VALUES (V_Ligne.nv, V_Ligne.cru || '(' || to_char(V_Ligne.mill) || ')', 'Recolte exeptionelle !');
cpt:=cpt+1;
END IF;
end loop;
RETURN cpt;
END;
/
SET SERVEROUTPUT ON
EXECUTE dbms_output.enable(1000000);
DECLARE
x number;
BEGIN
x:=recherche_vins('Alsace',1983);
dbms_output.new_line;
dbms_output.put_line(x || ' vins selectionnes ');
END;
/
| true |
45b32886e385b1543c03bcdab4179107265aad55 | SQL | stormning/wform | /src/main/resources/sql/wform-hsqldb.sql | UTF-8 | 4,426 | 3.125 | 3 | [
"Apache-2.0"
] | permissive |
CREATE TABLE T_FORM_FIELD (
FIELD_ID VARCHAR(32) PRIMARY KEY,
MODULE_ID VARCHAR(32),
NAME VARCHAR(64),
DISPLAY VARCHAR(64),
TYPE VARCHAR(63),
SIZE INTEGER,
LAST_UPDATE_DATE TIMESTAMP,
CREATE_TIME TIMESTAMP DEFAULT NOW(),
STATUS INTEGER
);
CREATE TABLE T_FORM_FIELD_ATTRIBUTE (
PAGE_ID VARCHAR(32),
FIELD_NAME VARCHAR(64),
ATTR_NAME VARCHAR(64),
ATTR_VALUE VARCHAR(255),
STATUS INTEGER
);
CREATE TABLE T_FORM_PAGE (
PAGE_ID VARCHAR(32) PRIMARY KEY,
PAGE_NAME VARCHAR(100),
PAGE_TITLE VARCHAR(100),
PAGE_TYPE VARCHAR(10),
IS_MANUAL INTEGER,
TABLE_NAME VARCHAR(30),
SUMMARY VARCHAR(255),
MODULE_ID VARCHAR(32),
LAST_UPDATE_DATE TIMESTAMP,
CREATE_TIME TIMESTAMP DEFAULT NOW(),
STATUS INTEGER
);
CREATE TABLE T_FORM_MODULE (
MODULE_ID VARCHAR(32) PRIMARY KEY,
MODULE_NAME VARCHAR(100),
SUMMARY VARCHAR(255),
LAST_UPDATE_DATE TIMESTAMP(0),
CREATE_TIME TIMESTAMP(0) DEFAULT NOW(),
STATUS INTEGER
);
CREATE TABLE T_FORM_PAGE_FIELD_FORM (
PK_ID VARCHAR(32) PRIMARY KEY,
PAGE_ID VARCHAR(32),
FIELD_ID VARCHAR(32),
ROW_NUM INTEGER,
COLUMN_NUM INTEGER,
COLUMN_SPAN INTEGER,
EDITABLE INTEGER,
FOR_WORKITEM VARCHAR(36),
FOR_WORKFLOW VARCHAR(36)
);
CREATE TABLE T_FORM_PAGE_FIELD_LIST (
PK_ID VARCHAR(32) PRIMARY KEY,
PAGE_ID VARCHAR(32),
FIELD_ID VARCHAR(32),
ROW_NUM INTEGER,
COLUMN_NUM INTEGER,
COLUMN_SPAN INTEGER,
IS_CONDITION INTEGER,
FORMATTER VARCHAR(32)
);
CREATE TABLE T_FORM_FLOW (
PK_ID VARCHAR(32) PRIMARY KEY,
PAGE_ID VARCHAR(32),
PD_KEY VARCHAR(255)
);
CREATE TABLE T_WORK_ITEM (
ITEM_ID VARCHAR(36) PRIMARY KEY,
BIZ_ID VARCHAR(36) NOT NULL,
TITLE VARCHAR(255),
FORM_KEY VARCHAR(255),
TASK_ID VARCHAR(32),
TASK_NAME VARCHAR(32),
CREATE_TIME TIMESTAMP DEFAULT NOW(),
STATUS INTEGER
);
CREATE TABLE T_CHECKBOX_first_page (
BIZ_ID VARCHAR(36),
VALUE VARCHAR(32)
);
CREATE TABLE t_first_group (
PK_ID VARCHAR(36) PRIMARY KEY,
title VARCHAR(255),
note VARCHAR(255),
content VARCHAR(255)
);
INSERT INTO T_FORM_MODULE (MODULE_ID,MODULE_NAME) VALUES ('100101','firstModule');
INSERT INTO T_FORM_FLOW VALUES('1','1001','simpleApprovalProcess');
update T_FORM_FLOW set PD_KEY = 'simpleApprovalProcess' where PK_ID = '1';
INSERT INTO T_FORM_PAGE_FIELD_FORM VALUES('0','1001','0',1,1,1,1,'bizId',null);
INSERT INTO T_FORM_PAGE_FIELD_FORM VALUES('1','1001','1',1,1,1,1,'title',null);
INSERT INTO T_FORM_PAGE_FIELD_FORM VALUES('2','1001','2',1,1,1,1,null,null);
INSERT INTO T_FORM_PAGE_FIELD_FORM VALUES('3','1001','3',2,1,1,1,null,null);
INSERT INTO T_FORM_PAGE_FIELD_FORM VALUES('4','1001','6',2,2,1,1,null,null);
INSERT INTO T_FORM_PAGE_FIELD_LIST VALUES('0','1001','0',1,1,1,1,null);
INSERT INTO T_FORM_PAGE_FIELD_LIST VALUES('1','1001','1',1,1,1,1,'showLink');
INSERT INTO T_FORM_PAGE_FIELD_LIST VALUES('2','1001','2',1,2,1,0,null);
INSERT INTO T_FORM_PAGE_FIELD_LIST VALUES('3','1002','4',1,1,1,0,null);
INSERT INTO T_FORM_PAGE_FIELD_LIST VALUES('4','1002','5',1,1,1,1,'showLink');
INSERT INTO T_FORM_PAGE_FIELD_LIST VALUES('5','1002','7',1,1,1,0,null);
INSERT INTO T_FORM_FIELD VALUES ('0', NULL, 'pk_id', '主键', 'key', 32, '2017-12-16 20:42:50', '2017-12-16 20:42:52', 1);
INSERT INTO T_FORM_FIELD VALUES ('1', NULL, 'title', '标题', 'text', 255, '2017-12-16 20:42:50', '2017-12-16 20:42:52', 1);
INSERT INTO T_FORM_FIELD VALUES ('2', NULL, 'note', '注释', 'text', 255, '2017-12-16 20:43:44', '2017-12-16 20:43:47', 1);
INSERT INTO T_FORM_FIELD VALUES ('3', NULL, 'content', '内容', 'textarea', 255, '2017-12-16 20:43:44', '2017-12-16 20:43:47', 1);
INSERT INTO T_FORM_FIELD VALUES ('6', NULL, 'love', '爱好', 'checkbox', 255, '2017-12-16 20:43:44', '2017-12-16 20:43:47', 1);
INSERT INTO T_FORM_FIELD VALUES ('4', NULL, 'ITEM_ID', '主键', 'key', 32, '2017-12-16 20:42:50', '2017-12-16 20:42:52', 1);
INSERT INTO T_FORM_FIELD VALUES ('5', NULL, 'TITLE', '标题', 'text', 255, '2017-12-16 20:42:50', '2017-12-16 20:42:52', 1);
INSERT INTO T_FORM_FIELD VALUES ('7', NULL, 'TASK_NAME', '当前任务', 'text', 255, '2017-12-16 20:42:50', '2017-12-16 20:42:52', 1);
INSERT INTO T_FORM_PAGE VALUES ('1001', 'first_page', '第一个页面', 'form', 0,'t_auto_1001','测试', '100101', '2017-12-16 20:14:52', '2017-12-16 20:14:54', 1);
INSERT INTO T_FORM_PAGE VALUES ('1002', 'workItem', '待办列表', 'list', 0,'T_WORK_ITEM','待办', '100101', '2017-12-16 20:14:52', '2017-12-16 20:14:54', 1);
| true |
e0e43b67ddcc8f9797b58a6ed0167d57a0facc27 | SQL | firatcell/dataV3_Lesson_2.6_lab | /SQL_Queries_2.6.sql | UTF-8 | 1,846 | 4.625 | 5 | [] | no_license | USE sakila;
/*
In the table actor, which are the actors whose last names are not repeated?
For example if you would sort the data in the table actor by last_name, you would see that there is Christian Arkoyd, Kirsten Arkoyd, and Debbie Arkoyd.
These three actors have the same last name. So we do not want to include this last name in our output.
Last name "Astaire" is present only one time with actor "Angelina Astaire", hence we would want this in our output list.
*/
SELECT DISTINCT SUBSTR(last_name,1) AS last_name
FROM actor
WHERE last_name NOT LIKE 'Arkoyd%'
GROUP BY last_name;
-- Which last names appear more than once?
SELECT SUBSTR(last_name, 1) AS last_name, COUNT(*) as count
FROM actor
GROUP BY last_name
ORDER BY count DESC;
-- Using the rental table, find out how many rentals were processed by each employee.
SELECT staff_id, COUNT(*) AS rental_count
FROM rental
GROUP BY staff_id;
-- Using the film table, find out how many films were released each year.
SELECT release_year, COUNT(*) AS count
FROM film
GROUP BY release_year
ORDER BY release_year ASC;
-- Using the film table, find out for each rating how many films were there.
SELECT rating, COUNT(*) AS count
FROM film
GROUP BY rating
ORDER BY count DESC;
-- What is the mean length of the film for each rating type. Round off the average lengths to two decimal places
SELECT rating, ROUND(AVG(length), 2) AS avg_length
FROM film
GROUP BY rating;
-- Which kind of movies (rating) have a mean duration of more than two hours?
SELECT f.rating, AVG(f.length) AS avg_duration
FROM film f
GROUP BY f.rating
HAVING AVG(f.length) > 120
ORDER BY f.rating;
-- Rank films by length (filter out the rows that have nulls or 0s in length column). In your output, only select the columns title, length, and the rank.
SELECT title, length
FROM film
WHERE length IS NOT NULL AND length > 0
ORDER BY length DESC;
| true |
841efcfb811c7d4c6491f345e6d25a361efe632b | SQL | rs2247/pricing_fork | /src/pricing/operations/alternative_formulas/qap_subsidy.sql | UTF-8 | 422 | 2.53125 | 3 | [] | no_license |
case when university_id in ({fixed_99}) THEN
99.0
else
case when level_id = 1 then
case when {min_qap_1} > original_value*(1-{level_1_subsidy}) then
{min_qap_1}
else
original_value*(1-{level_1_subsidy})
end
else
case when {min_qap_7_lowest} > (original_value - (0.4 * offered_price)) then
{min_qap_7_lowest}
else
(original_value - (0.4 * offered_price))
end
end
end | true |
358a2bbc9b0a31d3d936ac2ce0e18363c186146c | SQL | BrotherhoodCreed/sso | /sso-front/src/main/resources/create/tb_promotion_base_info.sql | UTF-8 | 2,407 | 3.234375 | 3 | [] | no_license | /*
Navicat Premium Data Transfer
Source Server : 本地mysql
Source Server Type : MySQL
Source Server Version : 80022
Source Host : localhost:3306
Source Schema : test
Target Server Type : MySQL
Target Server Version : 80022
File Encoding : 65001
Date: 18/02/2021 17:40:03
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for tb_promotion_base_info
-- ----------------------------
DROP TABLE IF EXISTS `tb_promotion_base_info`;
CREATE TABLE `tb_promotion_base_info` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`activity_code` varchar(32) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '促销编码',
`activity_type` varchar(32) DEFAULT NULL COMMENT '活动类型',
`sales_start_time` datetime DEFAULT NULL COMMENT '促销开始时间',
`sales_end_time` datetime DEFAULT NULL COMMENT '促销结束时间',
`amount` int DEFAULT NULL COMMENT '每台限制张数',
`bill_cycle` varchar(32) DEFAULT NULL COMMENT '回款周期',
`description` varchar(32) DEFAULT NULL COMMENT '活动描述',
`introduction` varchar(32) DEFAULT NULL COMMENT '七字描述',
`channel` varchar(32) DEFAULT NULL COMMENT '团购网站',
`the_way` varchar(32) DEFAULT NULL COMMENT '团购形式',
`shared_activity` varchar(32) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '共享活动',
`selling_price` decimal(10,2) DEFAULT NULL COMMENT '销售单价',
`bill_price` decimal(10,2) DEFAULT NULL COMMENT '回款单价',
`handling_fee` decimal(10,2) DEFAULT NULL COMMENT '手续费',
`tax_rate` decimal(5,2) DEFAULT NULL COMMENT '税率',
`other` varchar(32) DEFAULT NULL COMMENT '其他',
`created_time` varchar(32) DEFAULT NULL COMMENT '创建时间',
`created_user` varchar(32) DEFAULT NULL COMMENT '创建人',
`deleted` tinyint(1) DEFAULT '0' COMMENT '逻辑删除',
`updated_user` datetime DEFAULT NULL COMMENT '修改人',
`updated_time` datetime DEFAULT NULL COMMENT '修改时间',
`submit` varchar(32) DEFAULT NULL COMMENT '提交状态',
`type` varchar(32) DEFAULT NULL COMMENT '单据类型',
`usage_start_time` datetime DEFAULT NULL COMMENT '核销开始时间',
`usage_end_time` datetime DEFAULT NULL COMMENT '核销结束时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='促销基本信息表 ';
SET FOREIGN_KEY_CHECKS = 1;
| true |
5f5e0d2752e947e6949a57f93ee69a0cd4a61562 | SQL | LifestreamVII/ff7php | /ff7php.sql | UTF-8 | 4,118 | 3.375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.3
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1
-- Généré le : jeu. 04 mars 2021 à 01:22
-- Version du serveur : 10.4.14-MariaDB
-- Version de PHP : 7.4.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de données : `ff7php`
--
-- --------------------------------------------------------
--
-- Structure de la table `infantryman`
--
CREATE TABLE `infantryman` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`pv` int(11) NOT NULL,
`atk` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `infantryman`
--
INSERT INTO `infantryman` (`id`, `name`, `pv`, `atk`) VALUES
(1, 'Infantry Man 1', 130, 20);
-- --------------------------------------------------------
--
-- Structure de la table `materias`
--
CREATE TABLE `materias` (
`id` int(11) NOT NULL,
`name` varchar(30) NOT NULL,
`pv` int(11) NOT NULL,
`atk` int(11) NOT NULL,
`color` enum('green','blue') NOT NULL,
`type` enum('atk','heal') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `materias`
--
INSERT INTO `materias` (`id`, `name`, `pv`, `atk`, `color`, `type`) VALUES
(1, 'Fire', 0, 50, 'green', 'atk'),
(2, 'Fire2', 0, 100, 'green', 'atk'),
(3, 'Fire3', 0, 180, 'green', 'atk'),
(4, 'Restore', 60, 0, 'green', 'heal');
-- --------------------------------------------------------
--
-- Structure de la table `materias_owned`
--
CREATE TABLE `materias_owned` (
`char_id` int(11) NOT NULL,
`mat_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `materias_owned`
--
INSERT INTO `materias_owned` (`char_id`, `mat_id`) VALUES
(1, 4),
(2, 1),
(3, 1),
(3, 2),
(3, 3),
(3, 4);
-- --------------------------------------------------------
--
-- Structure de la table `soldier`
--
CREATE TABLE `soldier` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`pv` int(11) NOT NULL,
`atk` int(11) NOT NULL,
`selsprite` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `soldier`
--
INSERT INTO `soldier` (`id`, `name`, `pv`, `atk`, `selsprite`) VALUES
(1, 'Cloud', 200, 40, 'c1.png'),
(2, 'SOLDIER 2nd Class', 150, 30, 'c2.png'),
(3, 'Sephiroth', 500, 120, 'c3.png'),
(4, 'Zack', 220, 60, 'c4.png');
--
-- Index pour les tables déchargées
--
--
-- Index pour la table `infantryman`
--
ALTER TABLE `infantryman`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `materias`
--
ALTER TABLE `materias`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `materias_owned`
--
ALTER TABLE `materias_owned`
ADD PRIMARY KEY (`char_id`,`mat_id`),
ADD KEY `mat_id` (`mat_id`);
--
-- Index pour la table `soldier`
--
ALTER TABLE `soldier`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT pour les tables déchargées
--
--
-- AUTO_INCREMENT pour la table `infantryman`
--
ALTER TABLE `infantryman`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT pour la table `materias`
--
ALTER TABLE `materias`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT pour la table `soldier`
--
ALTER TABLE `soldier`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- Contraintes pour les tables déchargées
--
--
-- Contraintes pour la table `materias_owned`
--
ALTER TABLE `materias_owned`
ADD CONSTRAINT `materias_owned_ibfk_1` FOREIGN KEY (`char_id`) REFERENCES `soldier` (`id`),
ADD CONSTRAINT `materias_owned_ibfk_2` FOREIGN KEY (`mat_id`) REFERENCES `materias` (`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 |
7ffb6c2e50c7e92a2c7e28bb4b900af5a155a8b5 | SQL | zoltanec/optmgn | /dcms/sql/structure.sql | UTF-8 | 1,281 | 2.578125 | 3 | [] | no_license | DROP TABLE IF EXISTS mmg_comments_meta;
CREATE TABLE mmg_comments_meta (object_hash CHAR(32) NOT NULL DEFAULT '',/*идентификатор*/
object_id CHAR(60) NOT NULL DEFAULT '',/*путь к объекту*/
first INT UNSIGNED NOT NULL DEFAULT 0,/*первый комментарий*/
readonly BOOL NOT NULL DEFAULT FALSE, /*комментарии только для просмотра*/
editable BOOL NOT NULL DEFAULT TRUE, /*можно ли редактировать комментарии у данного объекта*/
lastchange TIMESTAMP,/*время добавления последнего комментария*/
comments INT UNSIGNED NOT NULL DEFAULT 0,/*количество сообщений в базе данных*/
PRIMARY KEY (object_hash));
DROP TABLE IF EXISTS mmg_site_log;
ALTER TABLE mmg_lng_messages ADD column javascript BOOL NOT NULL DEFAULT FALSE; | true |
a35c9927286f5e6a43ee800fb628ca5fa851d218 | SQL | palladiumkenya/openmrs-module-kenyaemrupgradehelper | /api/src/main/resources/SQLQueries/fill_orderer_and_order_encounter.sql | UTF-8 | 4,051 | 3.703125 | 4 | [] | no_license | DELIMITER $$
DROP PROCEDURE IF EXISTS sp_process_drug_orders$$
CREATE PROCEDURE sp_process_drug_orders(IN providerName VARCHAR(100))
BEGIN
DECLARE no_more_rows BOOLEAN;
DECLARE record_uuid VARCHAR(100);
DECLARE v_row_count INT(11);
DECLARE userID INT(11);
DECLARE encounterTypeID INT(11);
DECLARE formID INT(11);
DECLARE existing_drug_orders CURSOR FOR
SELECT uuid FROM orders;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET no_more_rows = TRUE;
OPEN existing_drug_orders;
SET v_row_count = FOUND_ROWS();
SELECT user_id INTO userID from users where username=providerName;
SELECT encounter_type_id INTO encounterTypeID from encounter_type where uuid="7df67b83-1b84-4fe2-b1b7-794b4e9bfcc3";
SELECT form_id INTO formID from form where uuid="888dbabd-1c18-4653-82c2-e753415ab79a";
IF v_row_count > 0 THEN
get_enrollment_record: LOOP
FETCH existing_drug_orders INTO record_uuid;
IF no_more_rows THEN
CLOSE existing_drug_orders;
LEAVE get_enrollment_record;
END IF;
CALL sp_create_order_encounter(record_uuid, userID, encounterTypeID, formID);
END LOOP get_enrollment_record;
ELSE
update orders set discontinued_by=userID where discontinued=1 and discontinued_by is null;
update orders set discontinued_date=curdate() where discontinued=1 and discontinued_date is null;
SELECT "NO ROWS WERE FOUND";
END IF;
END
$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS sp_create_order_encounter$$
CREATE PROCEDURE sp_create_order_encounter(IN recordUUID VARCHAR(100), IN providerID INT(11), IN encounterTypeID INT(11) , IN formID INT(11))
BEGIN
DECLARE exec_status INT(11) DEFAULT 1;
DECLARE creatorID INT(11);
DECLARE patientID INT(11);
DECLARE encounterDate DATETIME;
DECLARE encounterID INT(11);
DECLARE discontinued INT(11);
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
SET exec_status = -1;
ROLLBACK;
END;
-- perform all procedure calls within a transaction
START TRANSACTION;
SELECT creator, patient_id, date_created, discontinued INTO creatorID, patientID, encounterDate, discontinued from orders where uuid=recordUUID;
insert into encounter (encounter_type, patient_id, form_id, encounter_datetime, creator, date_created)
values (encounterTypeID, patientID, formID, encounterDate, creatorID, encounterDate) ;
SET encounterID = LAST_INSERT_ID();
UPDATE orders set orderer=providerID, encounter_id=encounterID where uuid=recordUUID;
IF discontinued = 1 THEN
UPDATE orders set discontinued_date=CURDATE(), discontinued_by=providerID where uuid=recordUUID;
END IF;
COMMIT;
END;
$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS sp_effect_db_changes_on_orders$$
CREATE PROCEDURE sp_effect_db_changes_on_orders()
BEGIN
ALTER TABLE `order_type`
ADD COLUMN `java_class_name` VARCHAR(255) DEFAULT NULL,
ADD COLUMN `parent` INT(11) DEFAULT NULL;
UPDATE `order_type` SET `java_class_name` = 'org.openmrs.TestOrder' WHERE name ='LAB TEST ORDERS';
UPDATE order_type SET java_class_name = 'org.openmrs.DrugOrder' WHERE name='Drug Order';
-- UPDATE drug_order set route=160240; -- previous orders never filled this one. should be run after upgrade is complete since route was introduced in later versions
-- this is required for the upgrade
insert into global_property(property, property_value, description, uuid)
values("order.drugDosingUnitsConceptUuid", "162384AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "Drug dosing units concept", 'a8ff078c-9b1b-11e8-98d0-529269fb1459');
-- set all null dosing unit and frequencies appropriately. This will avert upgrade from stalling
UPDATE drug_order SET frequency='OD' where frequency is null OR UPPER(frequency)='NULL';
UPDATE drug_order SET units='tab' where units is null OR UPPER(units)='NULL';
END
$$
DELIMITER ;
-- Procedure for upgrading
-- Create a user with provider role using the name : upgradeManager
call sp_effect_db_changes_on_orders();
call sp_process_drug_orders("upgradeManager");
| true |
a35a2ecd828d3cf03ee4c0cc056a51b85836eb07 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/high/day22/select0902.sql | UTF-8 | 266 | 2.828125 | 3 | [] | no_license |
SELECT sen.name
FROM SENSOR sen, SENSOR_TYPE st, COVERAGE_INFRASTRUCTURE ci
WHERE sen.SENSOR_TYPE_ID=st.id AND st.name='WiFiAP' AND sen.id=ci.SENSOR_ID AND ci.INFRASTRUCTURE_ID=ANY(array['4002','6028','5224','5214','2059','5086','5100_3','2100_1','1412','4088'])
| true |
693d376f9814a9000cd0c054b09efb2cc05e3a17 | SQL | crst/kmeans-sql | /monitor.sql | UTF-8 | 378 | 3.75 | 4 | [
"MIT"
] | permissive | SELECT
cc.cluster_id,
count(*) AS num_points,
avg(sqrt(((p.x1 - cc.x1)^2 * (p.x2 - cc.x2)^2))) AS avg_distance_to_center
FROM kmeans_demo.clusters c
JOIN kmeans_demo.points p USING (point_id)
JOIN kmeans_demo.cluster_centers cc USING (cluster_id)
WHERE cc.iteration = (SELECT max(iteration) FROM kmeans_demo.cluster_centers)
GROUP BY cc.cluster_id
ORDER BY cc.cluster_id;
| true |
ab255586c3be02933ee2d7fe28117ca09c80c1a0 | SQL | lucaskawasaki/spring-angular-algaworks-heroku | /src/main/resources/db/migration/V02__criar_e_registrar_pessoas.sql | UTF-8 | 2,006 | 3.265625 | 3 | [] | no_license | CREATE TABLE pessoa(
ID BIGINT(20) PRIMARY KEY AUTO_INCREMENT,
nome VARCHAR(50) NOT NULL,
ativo BOOLEAN NOT NULL,
logradouro VARCHAR(100),
numero VARCHAR(10),
complemento VARCHAR(100),
bairro VARCHAR(100),
cep VARCHAR(10),
cidade VARCHAR(100),
estado VARCHAR(2)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado)
values ('Neymar Junior', true, 'Av. Champs Elysees', '3000', 'Apto 55', 'Centro', '12.222.444', 'Paris', 'SP');
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado)
values ('Thiago Neves', true, 'Av. Cruzeiro', '2013', 'Apto 44', 'Bairro da Rapousa', '12.333.555', 'Belo Horizonte', 'MG');
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado)
values ('Daniel Alvez', true, 'Av. Paulista', '2007', 'Apto 33', 'Bairro do Morumbi', '12.444.666', 'São Paulo', 'SP');
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado)
values ('Ronaldo Total', true, 'Av. Corinthians ', '2007', 'Apto 33', 'Bairro do Sao Jorge', '12.444.666', 'São Paulo', 'SP');
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado)
values ('Alexandre Pato', false, 'Av. Internacional ', '2011', 'Apto 78', 'Bairro do Beira Rio', '12.444.879', 'Porto Alegre', 'RS');
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado)
values ('Paolo Maldini', true, 'Av. Milan ', '2045', 'Apto 56', 'Bairro do Milan', '12.444.412', 'Milano', 'RJ');
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado)
values ('Zinidine Zidane', false, 'Av. Real Madrid ', '4578', 'Apto 78', 'Bairro do Merengue', '12.789.412', 'Madrid', 'SP');
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado)
values ('Philipe Coutinho', true, 'Av. Barcelona ', '457', 'Apto 78', 'Bairro do Munich', '12.456.412', 'Rio de Janeiro', 'RJ'); | true |
b3df05ce355436b49108e6715c69560eefb54f0b | SQL | lgcarrier/AFW | /5.2.3/Database/Constraints/AFW_13_RESRC_FK4.sql | UTF-8 | 190 | 2.65625 | 3 | [
"MIT"
] | permissive | SET DEFINE OFF;
ALTER TABLE AFW_13_RESRC ADD (
CONSTRAINT AFW_13_RESRC_FK4
FOREIGN KEY (REF_DOSR_VIRTL)
REFERENCES AFW_13_DOSR_VIRTL (SEQNC)
ON DELETE CASCADE
ENABLE VALIDATE)
/
| true |
fe2046813ed82c74b0dbc96b999c76a8c5e459f1 | SQL | dosmanthus/leetcode | /001-200/181_EmployeesEarningMoreThanTheirManagers.sql | UTF-8 | 195 | 3.125 | 3 | [] | no_license | # Write your MySQL query statement below
# 413 ms
SELECT e1.Name as Employee
FROM Employee as e1, Employee as e2
WHERE e1.ManagerId IS NOT NULL
AND e1.ManagerId = e2.Id AND e1.Salary > e2.Salary
| true |
e8de19e58d975189503138bd0a46151e43c169c8 | SQL | skidipap/fastapi-lms | /migrations/models/0_20210706160612_init.sql | UTF-8 | 766 | 2.53125 | 3 | [] | no_license | -- upgrade --
CREATE TABLE IF NOT EXISTS "basemodel" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS "user" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
"username" VARCHAR(100) NOT NULL,
"email" VARCHAR(100) NOT NULL UNIQUE,
"password" VARCHAR(200),
"is_active" INT NOT NULL DEFAULT 0
);
CREATE TABLE IF NOT EXISTS "aerich" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"version" VARCHAR(255) NOT NULL,
"app" VARCHAR(20) NOT NULL,
"content" JSON NOT NULL
);
| true |
fd54ff45dc0eb7766bc2252ebf1d2acb17ac2284 | SQL | MiyamotoTa/actix_web_sample | /migrations/2020-09-06-113404_create_users_table/up.sql | UTF-8 | 411 | 3.359375 | 3 | [] | no_license | CREATE TABLE `users` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE UNIQUE index users_email_uindex ON `users` (`email`); | true |
d7709686bd3e8df1f95a1dd6ebaaec555bddcec3 | SQL | MartinaAG/Web-Project | /db_export.sql | UTF-8 | 3,171 | 2.828125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 06, 2019 at 11:01 PM
-- Server version: 10.1.38-MariaDB
-- PHP Version: 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 */;
--
-- Database: `webproject`
--
CREATE DATABASE IF NOT EXISTS `webproject` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `webproject`;
-- --------------------------------------------------------
--
-- Table structure for table `feedbacks`
--
DROP TABLE IF EXISTS `feedbacks`;
CREATE TABLE IF NOT EXISTS `feedbacks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`stars` int(11) NOT NULL,
`content` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `templates`
--
DROP TABLE IF EXISTS `templates`;
CREATE TABLE IF NOT EXISTS `templates` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`number` int(11) NOT NULL,
`script` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `templates`
--
INSERT INTO `templates` (`id`, `number`, `script`) VALUES
(1, 1, 'addSection(\'one\', 1, \'docMain\');\r\n addSection(\'two\', 2, \'docMain\');\r\n document.getElementById(\"docHeader\").style.backgroundColor = \'rgb(152, 206, 90)\';\r\n document.getElementById(\"docFooter\").style.backgroundColor = \'rgb(152, 206, 90)\';'),
(2, 2, 'addSection(\'three\', 3, \'docMain\');\r\n addSection(\'three\', 3, \'docMain\');\r\n addSection(\'three\', 3, \'docMain\');\r\n document.getElementById(\"docHeader\").style.backgroundColor = \'rgb(106, 99, 241)\';\r\n document.getElementById(\"docMain\").style.backgroundColor = \'rgb(255, 215, 235)\';\r\n document.getElementById(\"docFooter\").style.backgroundColor = \'rgb(106, 99, 241)\';'),
(3, 3, 'addSection(\'three-two-row\', 3, \'docMain\');\r\n addSection(\'three\', 3, \'docMain\');\r\n\r\n document.getElementById(\"docHeader\").style.backgroundColor = \'rgb(0, 0, 255)\';\r\n document.getElementById(\"docMain\").style.backgroundColor = \'rgb(172, 214, 255)\';\r\n document.getElementById(\"docFooter\").style.backgroundColor = \'rgb(0, 0, 255)\';'),
(4, 4, 'addSection(\'right-three-two-column\', 3, \'docMain\');\r\n addSection(\'right-three-two-column\', 3, \'docMain\');\r\n document.getElementById(\"docHeader\").style.backgroundColor = \'rgb(92, 218, 224)\';\r\n document.getElementById(\"docMain\").style.backgroundColor = \'rgb(219, 255, 255)\';\r\n document.getElementById(\"docFooter\").style.backgroundColor = \'rgb(92, 218, 224)\';');
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 |
43239b8fa0a3a1a753b06e141fa9e318ebe4d4ad | SQL | ccappetta/scratch | /taskr_proc_createtbl_task_comments.sql | UTF-8 | 507 | 3.265625 | 3 | [] | no_license | DROP procedure if exists proc_createtbl_task_comments;
create procedure proc_createtbl_task_comments(IN dbname varchar(128))
BEGIN
SET @theSQL=CONCAT('CREATE TABLE if not exists ', dbname, '.task_comments
(
comment_id int auto_increment
primary key,
comment_body varchar(9999) null,
commenter varchar(255) null,
task_id varchar(20) null,
comment_time timestamp null
);');
PREPARE stmt1 from @theSQL;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
END;
| true |
26b73d5e79eac4ee9b7f604b32a629e9c57aee2e | SQL | rtimbro185/syr_mads_ist659_database_admin_management | /final_project/sql/a4b_hierarchy_db_qa-selects.sql | UTF-8 | 1,132 | 3.40625 | 3 | [] | no_license | /*
IST 659 Data Admin Concepts &Db Mgmt
Date: 9/30/2018
Project Deliverable 2: Select Statements to Answer Data Questions
*/
-- As a Department Supervisor, what Application KPIs do I Own?
SELECT Department FROM DepartmentSupervisors WHERE Department_Supervisor = 'Ryan Timbrook'
SELECT Team FROM DepartmentTeams WHERE Department = 'Voice Services'
SELECT APP FROM TeamApplications WHERE Team in(SELECT Team FROM DepartmentTeams WHERE Department = 'Voice Services')
SELECT DISTINCT KPI FROM KPI_APP WHERE APP in(SELECT APP FROM TeamApplications WHERE Team in(SELECT Team FROM DepartmentTeams WHERE Department = 'Voice Services'))
-- As a Team Lead, what Application KPIs do I Own?
SELECT Team FROM TeamLeads WHERE Team_Lead = 'Kristy Gillis'
SELECT APP FROM TeamApplications WHERE Team in(SELECT Team FROM TeamLeads WHERE Team_Lead = 'Kristy Gillis')
SELECT DISTINCT KPI FROM KPI_APP WHERE APP in(SELECT APP FROM TeamApplications WHERE Team in(SELECT Team FROM TeamLeads WHERE Team_Lead = 'Kristy Gillis'))
-- Who are the Department Supervisors?
SELECT * FROM DepartmentSupervisors
-- Who are the Department Employees?
SELECT * FROM DepartmentEmployees | true |
f9f46321d91ef27595d151fa980e2e37eaca10ee | SQL | emr6050/template_forms | /interface/forms/redirect_questionnaire/table.sql | UTF-8 | 3,243 | 2.828125 | 3 | [] | no_license | /*
* create a custom table for the form
*
* This table NEEDS a UNIQUE name
*/
CREATE TABLE IF NOT EXISTS `form_redir_questionnaire` (
/* these fields are common to all forms and should remain intact */
id bigint(20) NOT NULL auto_increment,
date datetime default NULL,
pid bigint(20) default NULL,
user varchar(255) default NULL,
groupname varchar(255) default NULL,
authorized tinyint(4) default NULL,
activity tinyint(4) default NULL,
/* these fields are customized to this form */
relationship varchar(255) default NULL,
relationshp_other varchar(255) default NULL,
child_age varchar(5) default NULL,
ethnicity varchar(255) default NULL,
eth_blk varchar(5) default NULL,
eth_wht varchar(5) default NULL,
eth_asn varchar(5) default NULL,
eth_his varchar(5) default NULL,
eth_nam varchar(5) default NULL,
eth_nis varchar(5) default NULL,
eth_other varchar(5) default NULL,
week_time varchar(255) default NULL,
week_other varchar(255) default NULL,
insured varchar(255) default NULL,
ins_other varchar(255) default NULL,
primary_care varchar(5) default NULL,
overall_health varchar(255) default NULL,
screened varchar(5) default NULL,
screen_no varchar(255) default NULL,
screen_doc varchar(255) default NULL,
screen_teach varchar(255) default NULL,
screen_fam varchar(255) default NULL,
screen_other varchar(255) default NULL,
screen_note varchar(255) default NULL,
serv_birth varchar(5) default NULL,
serv_occ varchar(5) default NULL,
serv_phys varchar(5) default NULL,
serv_speech varchar(5) default NULL,
serv_head varchar(5) default NULL,
serv_mental varchar(5) default NULL,
serv_special varchar(5) default NULL,
serv_home varchar(5) default NULL,
serv_home_note varchar(255) default NULL,
serv_other varchar(5) default NULL,
serv_other_note varchar(255) default NULL,
zip_code varchar(10) default NULL,
adult_gender varchar(255) default NULL,
gender_note varchar(255) default NULL,
adult_age varchar(5) default NULL,
ad_ethnicity varchar(255) default NULL,
ad_eth_blk varchar(5) default NULL,
ad_eth_wht varchar(5) default NULL,
ad_eth_asn varchar(5) default NULL,
ad_eth_his varchar(5) default NULL,
ad_eth_nam varchar(5) default NULL,
ad_eth_nis varchar(5) default NULL,
ad_eth_other varchar(255) default NULL,
rel_status varchar(255) default NULL,
work_status varchar(255) default NULL,
education varchar(255) default NULL,
income varchar(255) default NULL,
basic_costs varchar(255) default NULL,
support varchar(255) default NULL,
comm_call varchar(255) default NULL,
comm_res varchar(255) default NULL,
parent_abil varchar(255) default NULL,
agencies varchar(255) default NULL,
parent_talk varchar(255) default NULL,
/* end of custom form fields */
PRIMARY KEY (id)
) ENGINE=InnoDB;
| true |
f5db02c04ead65f56781a3511688d40ff83004dc | SQL | gjohnston9/humor-genome | /cleanup/get_category_names_for_specific_joke.sql | UTF-8 | 216 | 3.296875 | 3 | [] | no_license | SELECT j.joke_text, c.jokecategory_name
FROM JokesCleaned as j
INNER JOIN Joke2Categories as j2c on j2c.joke_id=j.joke_id
INNER JOIN JokeCategories as c on c.jokecategory_id=j2c.jokecategory_id
WHERE j.joke_id=835; | true |
056031cb3d2ca62099aef2bb4d2a918ac592a73d | SQL | andimiya/SELECT-todo-FROM-list | /todo_app.sql | UTF-8 | 1,750 | 3.90625 | 4 | [] | no_license | \c Andrea;
DROP USER IF EXISTS "michael";
CREATE USER "michael" WITH ENCRYPTED PASSWORD 'stonebreaker';
DROP DATABASE IF EXISTS "todo_app";
CREATE DATABASE "todo_app";
\c todo_app;
CREATE TABLE "tasks" (
id SERIAL NOT NULL PRIMARY KEY,
title varchar(255) NOT NULL,
description text NULL,
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now(),
updated_at TIMESTAMP WITHOUT TIME ZONE NULL,
completed BOOLEAN NOT NULL DEFAULT FALSE);
ALTER TABLE "tasks"
DROP COLUMN "completed";
ALTER TABLE "tasks"
ADD COLUMN "completed_at" TIMESTAMP NULL DEFAULT NULL;
ALTER TABLE "tasks"
ALTER COLUMN "updated_at" SET NOT NULL;
ALTER TABLE "tasks"
ALTER COLUMN "updated_at" SET DEFAULT now();
INSERT INTO "tasks" (title, description, created_at, updated_at, completed_at) VALUES ('Study SQL', 'Complete this exercies', now(), now(), NULL);
INSERT INTO "tasks" (title, description) VALUES ('Study PostgreSQL', 'Read all the documentation');
SELECT * FROM "tasks"; -- Come back to this one!
-- WHERE "completed_at" = NULL;
UPDATE "tasks"
SET "completed_at" = now() WHERE id = 1;
SELECT * FROM "tasks"
WHERE "completed_at" IS NULL;
SELECT * FROM "tasks"
ORDER BY "created_at" DESC;
INSERT INTO "tasks" (title, description) VALUES ('mistake 1', 'a test entry');
INSERT INTO "tasks" (title, description) VALUES ('mistake 2', 'a test entry');
INSERT INTO "tasks" (title, description) VALUES ('third mistake', 'a test entry');
SELECT "title" FROM "tasks"
WHERE "title" LIKE '%mistake%';
DELETE FROM "tasks"
WHERE "title" LIKE '%mistake 1%';
SELECT "title",
"description"
FROM "tasks"
WHERE "title" LIKE '%mistake%';
DELETE FROM "tasks"
WHERE "title" LIKE '%mistake%';
SELECT * FROM "tasks"
ORDER BY "title" ASC; | true |
f84491244fa0dd476b95fceac4692d3a0251b842 | SQL | obelisco99/practicas_gbd | /practica_37/practica37.sql | UTF-8 | 1,071 | 3.515625 | 4 | [] | no_license | SELECT EQUIPO_CASA, EQUIPO_FUERA, (GOLES_CASA||'-'||GOLES_FUERA)
AS goles, CASE
WHEN GOLES_CASA>GOLES_FUERA THEN 'Victoria local'
WHEN GOLES_FUERA>GOLES_CASA THEN 'Victoria visitante'
WHEN GOLES_FUERA=GOLES_CASA THEN 'Empate' END AS resultado
FROM PARTIDOS_COMPLETOS;
-----------------------------------------------------------------
SELECT * FROM PARTIDOS_COMPLETOS WHERE fecha>sysdate
AND TO_CHAR(FECHA,'DAY')='Sábado'
AND extract(hour FROM FECHA)=18 and ESTADIO='San Isidro';
-----------------------------------------------------------------
SELECT EQUIPO_CASA FROM PARTIDOS_COMPLETOS
WHERE EQUIPO_CASA=CIUDAD_CASA
ORDER BY length(EQUIPO_CASA) DESC;
-----------------------------------------------------------------
SELECT EQUIPO_FUERA FROM PARTIDOS_COMPLETOS WHERE instr(EQUIPO_CASA, 'o')>4;
-----------------------------------------------------------------
SELECT EQUIPO_FUERA, EQUIPO_CASA, ESTADIO, AFORO,
to_char(FECHA, 'fmdd "de" month , day hh PM ') AS FECHA
FROM PARTIDOS_COMPLETOS
WHERE sysdate>FECHA
AND regexp_like(AFORO,^[0-9][00]$)
| true |
4bfaa0f2dde809d7c68373f898bd6a038ba26b97 | SQL | JDmajia/mone | /tesla/tesla-quota-server/src/main/resources/sql/init.sql | UTF-8 | 1,814 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2020 Xiaomi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
CREATE TABLE `resource` (
`id` int(32) NOT NULL AUTO_INCREMENT,
`ip` varchar(128) DEFAULT NULL,
`name` varchar(128) DEFAULT NULL,
`host_name` varchar(128) DEFAULT NULL,
`cpu` int(32) DEFAULT NULL,
`remain_cpu` int(32) DEFAULT NULL,
`biz_ids` json DEFAULT NULL,
`labels` json DEFAULT NULL,
`ctime` bigint(64) DEFAULT NULL,
`utime` bigint(64) DEFAULT NULL,
`version` int(32) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
CREATE TABLE `quota` (
`id` int(32) NOT NULL AUTO_INCREMENT,
`resource_id` int(32) DEFAULT NULL,
`biz_id` bigint(64) DEFAULT NULL,
`cpu` int(32) DEFAULT NULL,
`ip` varchar(128) DEFAULT NULL,
`ctime` bigint(64) DEFAULT NULL,
`utime` bigint(64) DEFAULT NULL,
`version` int(32) DEFAULT NULL,
`status` int(32) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8;
CREATE TABLE `quota_request` (
`id` int(32) NOT NULL AUTO_INCREMENT,
`biz_id` bigint(64) DEFAULT NULL,
`num` int(32) DEFAULT NULL,
`cpu` int(32) DEFAULT NULL,
`quotas` json DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8; | true |
b5aa3b77c688ca7adf778c321de3cc726efe5d5f | SQL | ciarangreene84/assure_core | /Assure.Core.Database/CoreFacade/Stored Procedures/AddPolicyDocument.sql | UTF-8 | 328 | 2.8125 | 3 | [] | no_license |
CREATE PROCEDURE [CoreFacade].[AddPolicyDocument]
@PolicyId int,
@DocumentId uniqueidentifier
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
INSERT INTO CoreModel.PolicyDocuments (PolicyId, DocumentId) VALUES (@PolicyId, @DocumentId)
END | true |
83e6fcc613daad91b140d997cb6f766e76c5de6b | SQL | arunbodd/gTRAP_Websearch-Tool | /Queries.sql | UTF-8 | 2,510 | 3.875 | 4 | [] | no_license | ##SQL Queries##
##Create query:
##Gene table
Create table Gene (Gene_Id varchar(20) NOT NULL PRIMARY KEY, Gene_Symbol varchar(30), Chromosome_pos varchar(10), Gene_Name varchar(30), Family_Name varchar(50));
##Transcription table
Create table Transcription( Transciprion_Factor_ID varchar(20) NOT NULL PRIMARY KEY, TF_Name varchar(50), Gene_ID varchar(20) FOREIGN KEY REFERENCES Gene(Gene_ID), Chromosome varchar(10), Start_site varchar(20), End_site varchar(20));
##Splicing table
Create table Splicing(SID varchar(20) NOT NULL PRIMARY KEY,Gene_ID varchar(20) FOREIGN KEY REFERENCES Gene(Gene_ID),Type varchar(20), Position int, length_change varchar(20), Protein_ID varchar(20) FOREIGN KEY REFERENCES Protein(Protein_ID));
##Protein table
Create table protein(Protein_ID varchar(20) NOT NULL PRIMARY KEY, Protein_Name varchar(20), Protein_Sequence varchar(450));
##Modification table
Create table Modification(Protein_ID varchar(20) NOT NULL PRIMARY KEY, Position int, Modification_Name varchar(50), Protein_sequence varchar(450));
##Variation table
Create table variation(Protein_ID varchar(20) FOREIGN KEY REFERENCES Protein(Protein_ID),Position int, Original varchar(100), variant varchar(150), Sequence varchar(450));
##Select Queries
##Selecting only transcription factors with Gene Id:
Select g.Gene_ID, g.Gene_Symbol, g.Gene_Name, tf.Tf_Name, tf.Start_site, tf.End_site from Gene G Transcription TF where TF.GeneId=G.Geneid
##Selecting only Splicing wid Gene Query:
Select g.Gene_Name, g.Gene_ID, g.Gene_Symbol s.SID, s.Type from Gene G Splicing S where S.GeneId=G.GeneId
##Selecting only Modification & Variations with Gene Query:
Select g. gene_Symbol, g.Gene_ID, g.Gene_Name, s.sid, s.type, tf.Transcription_Factor_Name, tf.Transcription_ID, m.modification_name, m.position, p.protein_name, V. original, v. variant, v.position from Gene g, Transcription tf, splicing s, protein p where g.Gene_ID=t.Gene_ID and g.Gene_ID=s.Gene_ID and tf.gene_id=g.gene_id and s.protein_id=p.protein_id and m.Protein_id=p.protein_ID and V.proteinID=p.proteinID
##Selecting only Proteins with Gene Query:
Select g.gene_ID, g.Gene_Name, p.Protein_ID, p.Protein_Name, s.Sid from gene g, protein p, splicing s where g.gene_ID=s.gene_ID and s.protein_ID=p.protein_ID
##COUNT VALUE IN ALL TABLES:
select count (*) from Gene;
select count (*) from Transcription;
select count (*) from Splicing;
select count (*) from Protein;
select count (*) from Modification;
select count (*) from variation;
| true |
9f551ec886758a6d4109d4049e60dbfe86569158 | SQL | dallahdev123/asteriskProjectCallCenter | /asterix.sql | UTF-8 | 3,673 | 3.421875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.9.1
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1
-- Généré le : Dim 17 nov. 2019 à 08:39
-- Version du serveur : 10.4.8-MariaDB
-- Version de PHP : 7.1.33
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de données : `asterix`
--
-- --------------------------------------------------------
--
-- Structure de la table `contact`
--
CREATE TABLE `contact` (
`contactId` int(11) NOT NULL,
`numero` varchar(255) NOT NULL,
`userId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `contact`
--
INSERT INTO `contact` (`contactId`, `numero`, `userId`) VALUES
(1, '+221775548912', 1),
(2, '+221764871230', 1),
(3, '+221784216235', 4),
(4, '+221702369874', 3),
(5, '+221704563214', 2),
(6, '+221769874521', 2);
-- --------------------------------------------------------
--
-- Structure de la table `rendezvous`
--
CREATE TABLE `rendezvous` (
`rendezvousId` int(11) NOT NULL,
`date` date NOT NULL,
`userId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `rendezvous`
--
INSERT INTO `rendezvous` (`rendezvousId`, `date`, `userId`) VALUES
(1, '2019-11-20', 1),
(2, '2019-11-21', 2),
(3, '2019-11-24', 3),
(4, '2019-11-25', 4);
-- --------------------------------------------------------
--
-- Structure de la table `user`
--
CREATE TABLE `user` (
`userId` int(11) NOT NULL,
`prenom` varchar(255) NOT NULL,
`nom` varchar(255) NOT NULL,
`adresse` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `user`
--
INSERT INTO `user` (`userId`, `prenom`, `nom`, `adresse`) VALUES
(1, 'Mamadou', 'Ndiaye', 'Mermoz'),
(2, 'Sidi', 'Diop', 'Bakel'),
(3, 'Rokhaya', 'Gueye', 'Pikine'),
(4, 'Rama', 'Ndiaye', 'Medina');
--
-- Index pour les tables déchargées
--
--
-- Index pour la table `contact`
--
ALTER TABLE `contact`
ADD PRIMARY KEY (`contactId`),
ADD KEY `userId` (`userId`);
--
-- Index pour la table `rendezvous`
--
ALTER TABLE `rendezvous`
ADD PRIMARY KEY (`rendezvousId`),
ADD KEY `userId` (`userId`);
--
-- Index pour la table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`userId`);
--
-- AUTO_INCREMENT pour les tables déchargées
--
--
-- AUTO_INCREMENT pour la table `contact`
--
ALTER TABLE `contact`
MODIFY `contactId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT pour la table `rendezvous`
--
ALTER TABLE `rendezvous`
MODIFY `rendezvousId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT pour la table `user`
--
ALTER TABLE `user`
MODIFY `userId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- Contraintes pour les tables déchargées
--
--
-- Contraintes pour la table `contact`
--
ALTER TABLE `contact`
ADD CONSTRAINT `contact_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`userId`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Contraintes pour la table `rendezvous`
--
ALTER TABLE `rendezvous`
ADD CONSTRAINT `rendezvous_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`userId`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
38c52f0205dddd601f1569521b5bc8cb6850512b | SQL | 532763233/CSMS | /选课管理系统/out/production/选课管理系统/sql.sql | UTF-8 | 5,542 | 3.09375 | 3 | [] | no_license | DROP DATABASE IF EXISTS ccmsdb;
CREATE DATABASE ccmsdb DEFAULT CHARACTER SET utf8;
use ccmsdb;
create table checkpeople (
id int not null primary key auto_increment,
type varchar(20) not null,
name varchar(20) not null,
username varchar(11) not null,
password varchar(11) not null
);
create table admin (
id int not null primary key auto_increment,
name varchar(20) not null,
username varchar(11) not null,
password varchar(11) not null,
telephone varchar(11),
email varchar(20),
date varchar(20),
sex varchar(2),
quest1 varchar(50),
ans1 varchar(50),
quest2 varchar(50),
ans2 varchar(50),
quest3 varchar(50),
ans3 varchar(50),
signature varchar(100)
);
insert into admin(name,username,password) value('老王','wang','123');
insert into admin(name,username,password) value('老李','li','123');
insert into admin(name,username,password) value('老赵','zhao','123');
create table student(
id int not null primary key auto_increment,
name varchar(20) not null,
username varchar(11) not null,
password varchar(11) not null,
telephone varchar(11),
email varchar(20),
date varchar(20),
sex varchar(2),
quest1 varchar(50),
ans1 varchar(50),
quest2 varchar(50),
ans2 varchar(50),
quest3 varchar(50),
ans3 varchar(50),
signature varchar(100)
);
insert into student(name,username,password) value('小明','ming','123');
insert into student(name,username,password) value('小红','hong','123');
insert into student(name,username,password) value('小蓝','lan','123');
create table teacher(
id int not null primary key auto_increment,
name varchar(20) not null,
username varchar(11) not null,
password varchar(11) not null,
telephone varchar(11),
email varchar(20),
date varchar(20),
sex varchar(2),
quest1 varchar(50),
ans1 varchar(50),
quest2 varchar(50),
ans2 varchar(50),
quest3 varchar(50),
ans3 varchar(50),
signature varchar(100)
);
insert into teacher(name,username,password) value('张三','san','123');
insert into teacher(name,username,password) value('李四','si','123');
insert into teacher(name,username,password) value('王五','wu','123');
create table course(
id int not null primary key auto_increment,
c_name varchar(20) not null,
time_start varchar(20) not null,
time_end varchar(20) not null,
t_id int ,
t_name varchar(20),
selectable int,
num int ,
choice bool
);
insert into course value(null,'c语言','2020-03-01','2020-07-01',1,'张三',200,0,true);
insert into course value(null,'java','2020-03-01','2020-07-01',2,'李四',200,0,true);
insert into course value(null,'paython','2020-03-01','2020-07-01',3,'王五',200,0,true);
create table sc(
id int not null primary key auto_increment,
c_name varchar(20) not null,
time_start varchar(20) not null,
time_end varchar(20) not null,
t_id int not null,
t_name varchar(20 ) not null,
s_id int not null,
s_name varchar(20) not null
);
create table apply(
id int not null primary key auto_increment,
a_id int ,
a_name varchar(20),
c_name varchar(20) not null,
time_start varchar(20) not null,
time_end varchar(20) not null,
mold varchar(50),
reason varchar(100)
);
create table log(
id int not null primary key auto_increment,
admin_id int not null,
admin_name varchar(20) not null ,
type varchar(20) not null ,
time varchar(50) not null ,
text varchar(100)
);
insert into log value (null,1,'admin','添加','2020-06-24','加了个寂寞');
insert into log value (null,1,'admin','修改','2020-06-24','改了个寂寞');
insert into log value (null,1,'admin','删除','2020-06-24','删了个寂寞');
insert into log value (null,1,'admin','通过','2020-06-24','过了个寂寞');
insert into log value (null,1,'admin','拒绝','2020-06-24','拒绝个寂寞');
| true |
68eb06c36e01e29173257f6733e8faf7e632d3f5 | SQL | DomoniqueC/DatabaseProject | /Database System/Tables/Abrahan Ramirez/contactdetails.sql | UTF-8 | 359 | 3.109375 | 3 | [] | no_license | /**
*Created by Abrahan Ramirez
*Contact Details Table
*This relation has data about the contact deatails of passengers.
**/
create table Contact_Details(
CnID INT PRIMARY KEY,
Email VARCHAR(16) NOT NULL,
Cell VARCHAR(16) NOT NULL,
Street VARCHAR(64),
State VARCHAR(20) NOT NULL,
CONSTRAINT fk_State FOREIGN KEY(State) REFERENCES State(StID)
);
| true |
8c3040020ae9a605955b2eb0d3b27e1c1840daf6 | SQL | ashugandhi/Business-Analytics-Nanodegree | /2. Intro to SQL/Lesson 1- SQL basics/33-between-due-purchase.sql | UTF-8 | 921 | 4.21875 | 4 | [] | no_license | /*
Udacity's certified program > Business Analytics Nanodegree
SQL practice > Lesson 1 : SQL Basics
Imagine you are a 'Sales Manager' at 'Parch and Posey', you want to see which
of your customers bought paper a while ago and might be due to make a purchase
soon. Lets assume this is January 2017, you probably want to look up customers
who made purchases some where between 3 and 9 months prior (or between April
and October of 2016).
*/
SELECT *
FROM orders
WHERE occurred_at BETWEEN '2015-04-01' AND '2015-10-01'
ORDER BY occurred_at DESC;
/*
Sometimes we can make a cleaner statement using BETWEEN than we can using AND.
Particularly this is true when we are using the same column for different parts
of our AND statement. In the previous video, we probably should have used
BETWEEN.
Instead of writing :
WHERE column >= 6 AND column <= 10
we can instead write, equivalently:
WHERE column BETWEEN 6 AND 10
*/
| true |
6973fd9d5f8ae42c08f0c5f82fde5980ec9a7759 | SQL | joaovperin/DallaHits | /web/META-INF/modelo/BD_Views.sql | UTF-8 | 345 | 3.6875 | 4 | [] | no_license | CREATE OR REPLACE VIEW View_Comandas AS
SELECT
c.idComanda,
c.idCliente,
cl.Nome as 'Cliente',
usu.Nome as 'Usuario',
c.Data, c.ValorTotal
FROM Comanda c
LEFT JOIN
Cliente cl ON c.idCliente = cl.idCliente
LEFT JOIN
Usuario usu ON usu.idUsuario = c.idUsuario; | true |
6cf638ec87e4723c1be72ca99bc3eb635306dd01 | SQL | cpaez-art/paginas | /AutosCUN/autoscun base de datos/autoscun_orden_articulos.sql | UTF-8 | 2,333 | 2.984375 | 3 | [
"MIT"
] | permissive | -- MySQL dump 10.13 Distrib 5.7.12, for Win64 (x86_64)
--
-- Host: localhost Database: autoscun
-- ------------------------------------------------------
-- Server version 5.5.58-MariaDB
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `orden_articulos`
--
DROP TABLE IF EXISTS `orden_articulos`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `orden_articulos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`quantity` int(5) NOT NULL,
PRIMARY KEY (`id`),
KEY `order_id` (`order_id`),
CONSTRAINT `orden_articulos_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orden` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `orden_articulos`
--
LOCK TABLES `orden_articulos` WRITE;
/*!40000 ALTER TABLE `orden_articulos` DISABLE KEYS */;
INSERT INTO `orden_articulos` VALUES (1,6,2,1),(2,6,4,1),(3,6,5,1),(4,7,5,1),(5,8,4,1),(6,9,5,1),(7,10,4,1),(8,11,4,1);
/*!40000 ALTER TABLE `orden_articulos` 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-02-20 18:40:31
| true |
7e86d0f655f3dcc5fa57436aac37b33eccee0501 | SQL | MJlexter/MedicalPlatform | /dbscript/medicalplatform_dr_tb_member_question.sql | UTF-8 | 2,432 | 2.859375 | 3 | [] | no_license | CREATE DATABASE IF NOT EXISTS `medicalplatform` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `medicalplatform`;
-- MySQL dump 10.13 Distrib 5.6.19, for Win64 (x86_64)
--
-- Host: localhost Database: medicalplatform
-- ------------------------------------------------------
-- Server version 5.6.21-enterprise-commercial-advanced-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `dr_tb_member_question`
--
DROP TABLE IF EXISTS `dr_tb_member_question`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dr_tb_member_question` (
`id` int(11) NOT NULL,
`doctor_id` int(11) DEFAULT NULL,
`member_id` int(11) DEFAULT NULL,
`description` varchar(1000) DEFAULT NULL,
`is_male` varchar(1) DEFAULT NULL,
`age` varchar(2) DEFAULT NULL,
`img_1` varchar(255) DEFAULT NULL,
`img_2` varchar(255) DEFAULT NULL,
`img_3` varchar(255) DEFAULT NULL,
`status` varchar(1) DEFAULT NULL,
`remarks` varchar(1000) DEFAULT NULL,
`updated_date` datetime DEFAULT NULL,
`updated_user` int(11) DEFAULT NULL,
`submit_date` datetime DEFAULT NULL,
`member_name` varchar(45) DEFAULT NULL,
`member_mobile` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2015-03-13 17:35:25
| true |
4dde548b90af72c792e98e4fc98673a7553c7149 | SQL | lgcarrier/AFW | /5.2.3/Database/Constraints/AFW_12_GROUP_STAT_UK1.sql | UTF-8 | 145 | 2.609375 | 3 | [
"MIT"
] | permissive | SET DEFINE OFF;
ALTER TABLE AFW_12_GROUP_STAT ADD (
CONSTRAINT AFW_12_GROUP_STAT_UK1
UNIQUE (CODE, REF_PRODT, REF_DOMN)
ENABLE VALIDATE)
/
| true |
59d2b3872510819dfa0ee2d0cffbfc6350f85eef | SQL | yhtgrace/echo | /src/test_echofilter_echoannot2.sql | UTF-8 | 653 | 3.328125 | 3 | [] | no_license | set search_path to mimiciii;
---- Run these first: --
-- echo_filter_vars_mx
-- echo_filtered_mx
DROP MATERIALIZED VIEW IF EXISTS test_echo_fluid2 CASCADE;
CREATE MATERIALIZED VIEW test_echo_fluid2 AS
SELECT ef.*, (fd.chartdate - cast(ef.ed_charttime as date)) as day_wrt_echo, fd.daily_input_ml, fd.daily_output_ml, fd.daily_balance_ml -- ef.row_id, ef.icustay_id
FROM mimiciii.echo_filtered_mx as ef
INNER JOIN mimiciii.fluid_dailybalance fd
ON ef.icustay_id = fd.icustay_id
--INNER JOIN mimiciii.echo_annotations_unique ea
-- ON ef.icustay_id = ea.icustay_id
--order by fd.subject_id, ef.ed_charttime, day_wrt_echo
| true |
1ed3d64c1163ebd32d30229589e97201651d1c39 | SQL | BritoMatheus/task-node-api | /SQLQuery1.sql | UTF-8 | 466 | 3.640625 | 4 | [] | no_license | CREATE TABLE Usuario
(
Id int IDENTITY(1,1) PRIMARY KEY,
Nome varchar(100),
Email varchar(200),
Password varchar(100)
)
CREATE TABLE Task
(
Id int IDENTITY(1,1) PRIMARY KEY,
Descricao varchar(200),
EstimateAt Date NULL,
DoneAt Date null,
UsuarioId int,
Constraint Task_Usuario FOREIGN KEY (UsuarioId) REFERENCES Usuario
)
SELECT * FROM Usuario
INSERT INTO Usuario
(Nome, Email)
VALUES
('Matheus Brito', 'maatheusbrito@hotmail.com')
delete from Usuario where nome <> 'Matheus'
| true |
37bf29cf5d690cbd69effc5c32d9b72eb6107029 | SQL | CUBRID/cubrid-testcases | /sql/_06_manipulation/_01_select/_021_null/cases/1007.sql | UTF-8 | 382 | 3.0625 | 3 | [
"BSD-3-Clause"
] | permissive | --Test null with relational operator
create class t1(c1 int, c2 varchar(20));
insert into t1 values(101, 'aaa');
insert into t1 values(null, 'aaa');
insert into t1 values(null, 'aaa');
insert into t1 values(null, 'aaa');
select * from t1
where c1 > null;
select * from t1
where c1 < null;
select * from t1
where c1 = null;
select * from t1
where c1 <> null;
drop class t1; | true |
d45b077f57ecbd5f3fc9e5d4453483a2cb05c072 | SQL | risingBirdSong/IHPTutCatchall | /blogB/Application/Fixtures.sql | UTF-8 | 1,197 | 2.65625 | 3 | [] | no_license |
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET SESSION AUTHORIZATION DEFAULT;
ALTER TABLE public.posts DISABLE TRIGGER ALL;
INSERT INTO public.posts (id, title, body, created_at) VALUES ('f0a33dbc-f924-466b-a93e-2a2e0f30d0ff', 'posting!!! :)', 'by me !!', '2021-04-04 15:57:56.483348-07');
INSERT INTO public.posts (id, title, body, created_at) VALUES ('79e9e32b-0323-4878-8380-619eb2df35fe', 'AAA', 'aaa', '2021-04-04 19:16:41.046884-07');
INSERT INTO public.posts (id, title, body, created_at) VALUES ('baf12315-e2ba-412e-9a9b-00ef3c850ec9', 'BBB', 'bbbbbb', '2021-04-04 19:16:48.28883-07');
INSERT INTO public.posts (id, title, body, created_at) VALUES ('76c1eb61-6834-499a-9db9-51c83afb7c61', 'CCC', 'ccc', '2021-04-04 19:16:54.616339-07');
ALTER TABLE public.posts ENABLE TRIGGER ALL;
ALTER TABLE public.comments DISABLE TRIGGER ALL;
ALTER TABLE public.comments ENABLE TRIGGER ALL;
| true |
0889d452913ef4106769c58b47c935c321db0ddd | SQL | glennneiger/parcel-analysis | /RealtyTrac/sql/temp_foreclosures_tagged_with_2010_block_groups.sql | UTF-8 | 341 | 3.21875 | 3 | [
"MIT"
] | permissive | -- Foreclosures summarized by year and 2010 block group
SELECT bg.geoid10 AS FIPS, asm.use_code_std, fc.*
INTO _temp_foreclosures_tagged_with_2010_block_groups_
FROM foreclosures_geocoded AS fc
JOIN assessments AS asm ON asm.sa_property_id = fc.sa_property_id
JOIN census2010_block_groups AS bg ON ST_Intersects(bg.geom, fc.geom); | true |
902f800b286491d0760f3333dde821a43ca7349a | SQL | SeverinGabriel/gabrieltransport | /Auftragverwaltung/WebContent/WEB-INF/resources/schema.ddl | ISO-8859-1 | 11,576 | 3.484375 | 3 | [] | no_license |
create table `Resource` (
name varchar(255) not null,
primary key (name)
) ENGINE=InnoDB;
create table `Role` (
name varchar(255) not null,
primary key (name)
) ENGINE=InnoDB;
create table `User` (
username varchar(255) not null,
password tinyblob not null,
primary key (username)
) ENGINE=InnoDB;
create table roleresourcenm (
`resource` varchar(255) not null,
`role` varchar(255) not null,
primary key (`role`, `resource`)
) ENGINE=InnoDB;
create table rolerolenm (
childrole varchar(255) not null,
parentrole varchar(255) not null,
primary key (parentrole, childrole)
) ENGINE=InnoDB;
create table userrolenm (
`user` varchar(255) not null,
`role` varchar(255) not null,
primary key (`role`, `user`)
) ENGINE=InnoDB;
alter table roleresourcenm
add constraint FK_g7kpun69oorakk361y3xe454f
foreign key (`role`)
references `Role` (name);
alter table roleresourcenm
add constraint FK_2nmu0urlnlwb6or7pv4l2b37d
foreign key (`resource`)
references `Resource` (name);
alter table rolerolenm
add constraint FK_2ktivh97rgpc1mqhw7vjsg4g8
foreign key (parentrole)
references `Role` (name);
alter table rolerolenm
add constraint FK_2vftx3kns1if099i5g439ia95
foreign key (childrole)
references `Role` (name);
alter table userrolenm
add constraint FK_5b4vuo6yxfybqc0cf2jjll5kf
foreign key (`role`)
references `Role` (name);
alter table userrolenm
add constraint FK_16evy309uhevxrg5da2w2qow8
foreign key (`user`)
references `User` (username);
create table gabrieltransport.user (
username varchar(255) not null,
password tinyblob not null,
primary key (username)
) ENGINE=InnoDB;
create table gabrieltransport.userrolenm (
user varchar(255) not null,
role varchar(255) not null,
primary key (user, role)
) ENGINE=InnoDB;
alter table gabrieltransport.anhaenger
drop constraint UKrhpn6d2c2u8a6awldvg068gd;
alter table gabrieltransport.anhaenger
add constraint UKrhpn6d2c2u8a6awldvg068gd unique (Nummer);
create table `RESOURCE` (
`NAME` varchar(255) not null,
primary key (`NAME`)
) ENGINE=InnoDB;
create table `ROLE` (
`NAME` varchar(255) not null,
primary key (`NAME`)
) ENGINE=InnoDB;
create table ROLERESOURCENM (
`RESOURCE` varchar(255) not null,
`ROLE` varchar(255) not null,
primary key (`ROLE`, `RESOURCE`)
) ENGINE=InnoDB;
create table ROLEROLENM (
CHILDROLE varchar(255) not null,
PARENTROLE varchar(255) not null,
primary key (PARENTROLE, CHILDROLE)
) ENGINE=InnoDB;
alter table gabrieltransport.anhaenger
add constraint FKmhd7atdc23uhv74xufyumoihe
foreign key (fkTyp)
references gabrieltransport.anhaengertyp (idanhaengertyp);
alter table gabrieltransport.anhaenger
add constraint FKi026kuw3m8jbyi6w410fgpkv
foreign key (fkFunktion)
references gabrieltransport.fahrzeug_funktion (idfunktion);
alter table gabrieltransport.fahrerauftrag
add constraint FKg53d9ohfj5863iqlcwmq47xvq
foreign key (fkauftrag)
references gabrieltransport.auftrag (idAuftrag);
alter table gabrieltransport.fahrerauftrag
add constraint FKbobmsyoclqb1jgew1rblt00kc
foreign key (fkFahrer)
references gabrieltransport.fahrer (idfahrer);
alter table gabrieltransport.fahrerfunktionmap
add constraint FK1jifyfkrc7m0693iqmyiec4ba
foreign key (fkFahrer)
references gabrieltransport.fahrer (idfahrer);
alter table gabrieltransport.fahrerfunktionmap
add constraint FKd0orph1dxtgikfadww4tk64fq
foreign key (fkFunktion)
references gabrieltransport.fahrerfunktion (idfunktion);
alter table gabrieltransport.fahrzeug
add constraint FKt90s8ae65yjbd92arcai3274m
foreign key (AnhaengerTyp)
references gabrieltransport.anhaengertyp (idanhaengertyp);
alter table gabrieltransport.fahrzeug
add constraint FKgkhrh55g5rdlstgc5wuydi4gm
foreign key (Funktion)
references gabrieltransport.fahrzeug_funktion (idfunktion);
alter table gabrieltransport.fahrzeugauftrag
add constraint FKcmwyyxeos2rel7f7k3p2j0qs1
foreign key (fkAnhnger)
references gabrieltransport.anhaenger (idanhaenger);
alter table gabrieltransport.fahrzeugauftrag
add constraint FK3phdamshu2tfjsfkfi7gr3g8l
foreign key (fkAuftrag)
references gabrieltransport.auftrag (idAuftrag);
alter table gabrieltransport.fahrzeugauftrag
add constraint FKomu28sg0e4onsngy4fp54c9fm
foreign key (fkFahrzeug)
references gabrieltransport.fahrzeug (idfahrzeug);
alter table gabrieltransport.userrolenm
add constraint FKahstt1iavh8i1xqqio0o9hpss
foreign key (role)
references `ROLE` (`NAME`);
alter table gabrieltransport.userrolenm
add constraint FKsvo9gdqf26n9i7bkdtp5ro67h
foreign key (user)
references gabrieltransport.user (username);
alter table ROLERESOURCENM
add constraint FKan33knkv6vxyubowoou51i24i
foreign key (`ROLE`)
references `ROLE` (`NAME`);
alter table ROLERESOURCENM
add constraint FK8bg4vr1hdj04pnre1ilphwaya
foreign key (`RESOURCE`)
references `RESOURCE` (`NAME`);
alter table ROLEROLENM
add constraint FK5f7bmwos053wnl5yi4ksxwmwo
foreign key (PARENTROLE)
references `ROLE` (`NAME`);
alter table ROLEROLENM
add constraint FKko3y06p19y83p5oa48c1hemrp
foreign key (CHILDROLE)
references `ROLE` (`NAME`);
alter table gabrieltransport.user
add column iduser INT not null;
create table `RESOURCE` (
`NAME` varchar(255) not null,
primary key (`NAME`)
) ENGINE=InnoDB;
create table `ROLE` (
`NAME` varchar(255) not null,
primary key (`NAME`)
) ENGINE=InnoDB;
create table ROLERESOURCENM (
`RESOURCE` varchar(255) not null,
`ROLE` varchar(255) not null,
primary key (`ROLE`, `RESOURCE`)
) ENGINE=InnoDB;
create table ROLEROLENM (
CHILDROLE varchar(255) not null,
PARENTROLE varchar(255) not null,
primary key (PARENTROLE, CHILDROLE)
) ENGINE=InnoDB;
alter table ROLERESOURCENM
add constraint FKan33knkv6vxyubowoou51i24i
foreign key (`ROLE`)
references `ROLE` (`NAME`);
alter table ROLERESOURCENM
add constraint FK8bg4vr1hdj04pnre1ilphwaya
foreign key (`RESOURCE`)
references `RESOURCE` (`NAME`);
alter table ROLEROLENM
add constraint FK5f7bmwos053wnl5yi4ksxwmwo
foreign key (PARENTROLE)
references `ROLE` (`NAME`);
alter table ROLEROLENM
add constraint FKko3y06p19y83p5oa48c1hemrp
foreign key (CHILDROLE)
references `ROLE` (`NAME`);
create table gabrieltransport.user (
iduser INT not null auto_increment,
password tinyblob not null,
username varchar(255) not null,
primary key (iduser)
) ENGINE=InnoDB;
create table gabrieltransport.userrolenm (
user INT not null,
role varchar(255) not null,
primary key (user, role)
) ENGINE=InnoDB;
alter table gabrieltransport.user
drop constraint UK_sb8bbouer5wak8vyiiy4pf2bx;
alter table gabrieltransport.user
add constraint UK_sb8bbouer5wak8vyiiy4pf2bx unique (username);
create table `RESOURCE` (
`NAME` varchar(255) not null,
primary key (`NAME`)
) ENGINE=InnoDB;
create table `ROLE` (
`NAME` varchar(255) not null,
primary key (`NAME`)
) ENGINE=InnoDB;
create table ROLERESOURCENM (
`RESOURCE` varchar(255) not null,
`ROLE` varchar(255) not null,
primary key (`ROLE`, `RESOURCE`)
) ENGINE=InnoDB;
create table ROLEROLENM (
CHILDROLE varchar(255) not null,
PARENTROLE varchar(255) not null,
primary key (PARENTROLE, CHILDROLE)
) ENGINE=InnoDB;
alter table gabrieltransport.userrolenm
add constraint FKahstt1iavh8i1xqqio0o9hpss
foreign key (role)
references `ROLE` (`NAME`);
alter table gabrieltransport.userrolenm
add constraint FKsvo9gdqf26n9i7bkdtp5ro67h
foreign key (user)
references gabrieltransport.user (iduser);
alter table ROLERESOURCENM
add constraint FKan33knkv6vxyubowoou51i24i
foreign key (`ROLE`)
references `ROLE` (`NAME`);
alter table ROLERESOURCENM
add constraint FK8bg4vr1hdj04pnre1ilphwaya
foreign key (`RESOURCE`)
references `RESOURCE` (`NAME`);
alter table ROLEROLENM
add constraint FK5f7bmwos053wnl5yi4ksxwmwo
foreign key (PARENTROLE)
references `ROLE` (`NAME`);
alter table ROLEROLENM
add constraint FKko3y06p19y83p5oa48c1hemrp
foreign key (CHILDROLE)
references `ROLE` (`NAME`);
create table gabrieltransport.user (
iduser INT not null auto_increment,
password tinyblob not null,
username varchar(255) not null,
primary key (iduser)
) ENGINE=InnoDB;
create table gabrieltransport.userrolenm (
user INT not null,
role varchar(255) not null,
primary key (user, role)
) ENGINE=InnoDB;
alter table gabrieltransport.user
drop constraint UK_sb8bbouer5wak8vyiiy4pf2bx;
alter table gabrieltransport.user
add constraint UK_sb8bbouer5wak8vyiiy4pf2bx unique (username);
create table `RESOURCE` (
`NAME` varchar(255) not null,
primary key (`NAME`)
) ENGINE=InnoDB;
create table `ROLE` (
`NAME` varchar(255) not null,
primary key (`NAME`)
) ENGINE=InnoDB;
create table ROLERESOURCENM (
`RESOURCE` varchar(255) not null,
`ROLE` varchar(255) not null,
primary key (`ROLE`, `RESOURCE`)
) ENGINE=InnoDB;
create table ROLEROLENM (
CHILDROLE varchar(255) not null,
PARENTROLE varchar(255) not null,
primary key (PARENTROLE, CHILDROLE)
) ENGINE=InnoDB;
alter table gabrieltransport.userrolenm
add constraint FKahstt1iavh8i1xqqio0o9hpss
foreign key (role)
references `ROLE` (`NAME`);
alter table gabrieltransport.userrolenm
add constraint FKsvo9gdqf26n9i7bkdtp5ro67h
foreign key (user)
references gabrieltransport.user (iduser);
alter table ROLERESOURCENM
add constraint FKan33knkv6vxyubowoou51i24i
foreign key (`ROLE`)
references `ROLE` (`NAME`);
alter table ROLERESOURCENM
add constraint FK8bg4vr1hdj04pnre1ilphwaya
foreign key (`RESOURCE`)
references `RESOURCE` (`NAME`);
alter table ROLEROLENM
add constraint FK5f7bmwos053wnl5yi4ksxwmwo
foreign key (PARENTROLE)
references `ROLE` (`NAME`);
alter table ROLEROLENM
add constraint FKko3y06p19y83p5oa48c1hemrp
foreign key (CHILDROLE)
references `ROLE` (`NAME`);
| true |
d480220155afa8e832bb3688a1c63facc582973a | SQL | amerkrlicbegovic/SQL-lab | /Fin/Funkcije_fin.sql | UTF-8 | 2,285 | 3.859375 | 4 | [] | no_license | --5.5.1 ZADACI ZA VJEŽBU --
--ZADATAK ZA VJEŽBU 35.
--Ispišite ime i prezime te mjesto rođenja studenata kojima ime počinje
--slovom F
SELECT stud.imeStud, stud.prezStud, mjesto.nazMjesto
FROM stud
INNER JOIN mjesto ON stud.pbrRod = mjesto.pbr
WHERE Left(stud.imeStud,1)='F'
--ZADATAK ZA VJEŽBU 36.
--Ispišite ime i prezime nastavnika koji živi u mjestu koje na trećem mjestu
--ima slovo Z.
SELECT nastavnik.imeNastavnik, nastavnik.prezNastavnik, mjesto.nazMjesto
FROM nastavnik
INNER JOIN mjesto ON nastavnik.pbrStan = mjesto.pbr
WHERE SUBSTRING(mjesto.nazMjesto,3,1)='Z'
--ZADATAK ZA VJEŽBU 37.
--Ispišite ime i prezime studenata te imena i prezimena nastavnika koji u
--imenu imaju na petom mjestu isto slovo.
SELECT stud.imeStud, stud.prezStud, nastavnik.imeNastavnik, nastavnik.prezNastavnik
FROM nastavnik
INNER JOIN ispit ON nastavnik.sifNastavnik = ispit.sifNastavnik
INNER JOIN stud ON ispit.mbrStud = stud.mbrStud
WHERE Rtrim(SUBSTRING(stud.imeStud,5,1))=Rtrim(SUBSTRING(Nastavnik.imeNastavnik,5,1))
--ZADATAK ZA VJEŽBU 38.
--Ispišite nazive županija kojima je duljina imena duža od 13 znakova a kraća
--od 20 znakova.
SELECT nazZupanija, LEN(nazZupanija)
FROM zupanija
WHERE LEN(nazZupanija) Between 13 and 20
--ZADATAK ZA VJEŽBU 39.
--Ispišite ime i prezime studenata koji su rođeni u svibnju.
SELECT imeStud, prezStud, datRodStud
FROM stud
WHERE Month(datRodStud)=5
--ZADATAK ZA VJEŽBU 40.
--Ispišite ime i prezime studenata koji su na ispit izašli između 10 i 20 u
--mjesecu.
SELECT stud.imeStud, stud.prezStud, ispit.datIspit
FROM stud
INNER JOIN ispit ON stud.mbrStud = ispit.mbrStud
WHERE DAY(ispit.datIspit) Between 10 and 20
--ZADATAK ZA VJEŽBU 41*.
--Pronađite podatke o onim nastavnicima koji su u lipnju ispitivali studente
--čije je mjesto rođenja isto mjestu gdje stanuje nastavnik. Ispišite ime i
--prezime nastavnika, naziv mjesta gdje stanuje, ime i prezime studenta
SELECT nastavnik.imeNastavnik, nastavnik.prezNastavnik, mjesto.nazMjesto, stud.imeStud, stud.prezStud
FROM stud
INNER JOIN ispit ON stud.mbrStud = ispit.mbrStud
INNER JOIN nastavnik ON ispit.sifNastavnik = nastavnik.sifNastavnik
INNER JOIN mjesto ON nastavnik.pbrStan = mjesto.pbr
WHERE Month(ispit.datIspit) =6
| true |
862613f8939d3c183b36c5c5464b053a652b9f8b | SQL | mebelousov/antlr_psql | /src/test/resources/sql/select/3961e0be.sql | UTF-8 | 289 | 2.84375 | 3 | [
"MIT"
] | permissive | -- file:opr_sanity.sql ln:1087 expect:true
SELECT p1.oid::regprocedure, p2.oid::regprocedure
FROM pg_proc AS p1, pg_proc AS p2
WHERE p1.oid < p2.oid AND p1.proname = p2.proname AND
p1.proisagg AND p2.proisagg AND
array_dims(p1.proargtypes) != array_dims(p2.proargtypes)
ORDER BY 1
| true |
a3aa7838d0ffbab634fcd1d5e1ff88da04f52ce9 | SQL | Symryvvin/mtg | /sql/lang.sql | UTF-8 | 1,029 | 3.09375 | 3 | [] | no_license | CREATE TABLE `magic`.`lang_definition` (
`code` VARCHAR(2) NOT NULL,
`name` VARCHAR(20) NOT NULL,
PRIMARY KEY (`code`),
UNIQUE INDEX `code_UNIQUE` (`code` ASC) VISIBLE,
UNIQUE INDEX `name_UNIQUE` (`name` ASC) VISIBLE);
START TRANSACTION;
INSERT INTO lang_definition (code, name) VALUES ('en', 'English');
INSERT INTO lang_definition (code, name) VALUES ('ru', 'Russian');
INSERT INTO lang_definition (code, name) VALUES ('de', 'German');
INSERT INTO lang_definition (code, name) VALUES ('fr', 'French');
INSERT INTO lang_definition (code, name) VALUES ('it', 'Italian');
INSERT INTO lang_definition (code, name) VALUES ('es', 'Spanish');
INSERT INTO lang_definition (code, name) VALUES ('pt', 'Portuguese (Brazil)');
INSERT INTO lang_definition (code, name) VALUES ('ja', 'Japanese');
INSERT INTO lang_definition (code, name) VALUES ('ko', 'Korean');
INSERT INTO lang_definition (code, name) VALUES ('cs', 'Chinese Simplified');
INSERT INTO lang_definition (code, name) VALUES ('ct', 'Chinese Traditional');
COMMIT;
| true |
89175c0403cf43fc64f7d498e17f8bdc2d5bbad6 | SQL | zhankster/seating | /.sql/Dine_Tables.sql | UTF-8 | 1,265 | 3.078125 | 3 | [] | no_license | CREATE TABLE `table` (
`id` varchar(12) NOT NULL,
`section` varchar(12) DEFAULT NULL,
`seats` int(11) NOT NULL,
`max_seats` int(11) NOT NULL,
`location` varchar(20) DEFAULT NULL,
`description` varchar(100) NOT NULL,
`active` bit DEFAULT 1,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `table` (
`id` varchar(12) NOT NULL,
`section` varchar(12) DEFAULT NULL,
`seats` int(11) NOT NULL,
`max_seats` int(11) NOT NULL,
`location` varchar(20) DEFAULT NULL,
`description` varchar(100) NOT NULL,
`current_seating` int(11) DEFAULT 0,
`active` bit(1) DEFAULT b'1',
`status_change` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`badge_num` varchar(20) DEFAULT NULL,
`first_name` varchar(30) NOT NULL,
`last_name` varchar(30) NOT NULL,
`dept` varchar(50) DEFAULT NULL,
`position` varchar(50) DEFAULT NULL,
`manager` int(11) DEFAULT NULL,
`image` varchar(512) DEFAULT NULL,
`pwd` varchar(256) DEFAULT NULL,
`start_date` datetime NOT NULL DEFAULT current_timestamp(),
`active` bit(1) DEFAULT b'1',
`level` int(11) DEFAULT 1,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
| true |
603356eb3081178b73d3817728c9c4d4fd60d582 | SQL | ramjikanaujia/HackerRank-SQL-Challenges-Solutions | /Advanced Select/New Companies.sql | UTF-8 | 494 | 4.25 | 4 | [] | permissive | # Author: Ramji Kanaujia
SELECT c.company_code,c.founder,
count(distinct lm.lead_manager_code),
count(distinct sm.senior_manager_code),
count(distinct m.manager_code),
count(distinct e.employee_code)
FROM Company c, Lead_Manager lm, Senior_Manager sm, Manager m, Employee e
WHERE
c.company_code=lm.company_code AND
lm.lead_manager_code=sm.lead_manager_code AND
sm.senior_manager_code=m.senior_manager_code AND
m.manager_code=e.manager_code
GROUP BY c.company_code,c.founder
ORDER BY c.company_code ASC | true |
c816fbcdfa7c586c67414cd7ecf980f77648be33 | SQL | radtek/white_szpt | /src/sql/souce建库语句/source_jcj.sql | UTF-8 | 6,037 | 3.15625 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : jwzh
Source Server Version : 50538
Source Host : localhost:3306
Source Database : source_jcj
Target Server Type : MYSQL
Target Server Version : 50538
File Encoding : 65001
Date: 2017-03-24 16:35:08
*/
SET FOREIGN_KEY_CHECKS=0;
DROP Database IF EXISTS `source_jcj`;
CREATE Database `source_jcj`;
use source_jcj;
-- ----------------------------
-- Table structure for t_cjd
-- ----------------------------
DROP TABLE IF EXISTS `t_cjd`;
CREATE TABLE `t_cjd` (
`CJDBH` varchar(255) DEFAULT NULL COMMENT '处警单编号',
`XZQH` varchar(100) DEFAULT NULL,
`SJDBH` varchar(255) DEFAULT NULL COMMENT '受警单编号',
`CJDW` varchar(255) DEFAULT NULL COMMENT '处警单位',
`CJYGH` varchar(255) DEFAULT NULL COMMENT '处警人工号',
`CJYXM` varchar(255) DEFAULT NULL COMMENT '处警人姓名',
`CJCS` varchar(255) DEFAULT NULL,
`CJJSSJ` datetime DEFAULT NULL COMMENT '处警结束时间',
`DDCJSC` int(100) DEFAULT NULL,
`CJSC` int(255) DEFAULT NULL,
`CJDZT` varchar(100) DEFAULT NULL COMMENT '处警单状态',
`CJTH` varchar(255) DEFAULT NULL,
`SJC` datetime DEFAULT NULL,
`CJKSSJ` datetime DEFAULT NULL,
`CJLX` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for t_cjzld
-- ----------------------------
DROP TABLE IF EXISTS `t_cjzld`;
CREATE TABLE `t_cjzld` (
`ZLDBH` varchar(255) DEFAULT NULL COMMENT '指令单编号',
`XZQH` varchar(255) DEFAULT NULL,
`SJDBH` varchar(255) DEFAULT NULL COMMENT '受警单编号',
`CJDBH` varchar(255) DEFAULT NULL COMMENT '处警单编号',
`CJDW` varchar(255) DEFAULT NULL COMMENT '处警单位',
`ZLXDSJ` datetime DEFAULT NULL COMMENT '指令下达时间',
`ZLJSSJ` datetime DEFAULT NULL COMMENT '指令接收时间',
`ZLJSDW` varchar(255) DEFAULT NULL COMMENT '指令接收单位',
`ZLJSRXM` varchar(255) DEFAULT NULL COMMENT '指令接收人姓名',
`CDSJ` datetime DEFAULT NULL COMMENT '出动时间',
`DCSJ` datetime DEFAULT NULL COMMENT '到场时间',
`ZLZT` varchar(255) DEFAULT NULL COMMENT '指令状态',
`FKCSBJ` varchar(255) DEFAULT NULL,
`SJC` datetime DEFAULT NULL COMMENT '时间戳',
`CDWG` varchar(255) DEFAULT NULL,
`ZLDDSJ` datetime DEFAULT NULL COMMENT '指令到达时间',
`ZLJSRGH` varchar(255) DEFAULT NULL COMMENT '指令接收人工号',
`WXFKBJ` varchar(255) DEFAULT NULL,
`IMEI` varchar(255) DEFAULT NULL COMMENT '手机IMEI号',
`ZDFKBJ` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for t_fkd
-- ----------------------------
DROP TABLE IF EXISTS `t_fkd`;
CREATE TABLE `t_fkd` (
`FKDBH` varchar(255) DEFAULT NULL COMMENT '反馈单编号',
`XZQH` varchar(255) DEFAULT NULL,
`SJDBH` varchar(255) DEFAULT NULL COMMENT '受警单编号',
`CJDBH` varchar(255) DEFAULT NULL COMMENT '处警单编号',
`ZLDBH` varchar(255) DEFAULT NULL COMMENT '指令单编号',
`ZLJSSJ` datetime DEFAULT NULL COMMENT '接收指令时间',
`FKLX` varchar(255) DEFAULT NULL COMMENT '反馈类型',
`FKKSSJ` datetime DEFAULT NULL COMMENT '反馈开始时间',
`FKDW` varchar(255) DEFAULT NULL COMMENT '反馈单位',
`FKTH` varchar(255) DEFAULT NULL,
`FKRGH` varchar(255) DEFAULT NULL COMMENT '反馈人工号',
`FKRXM` varchar(255) DEFAULT NULL COMMENT '反馈人姓名',
`FKTXDW` varchar(255) DEFAULT NULL,
`FKBCSJ` varchar(255) DEFAULT NULL COMMENT '反馈保存时间',
`FKSC` varchar(255) DEFAULT NULL,
`FKJSSJ` datetime DEFAULT NULL COMMENT '反馈结束时间',
`FKJSDW` varchar(255) DEFAULT NULL COMMENT '反馈接收单位',
`FKJSRGH` varchar(255) DEFAULT NULL COMMENT '反馈接收人工号',
`FKJSRXM` varchar(255) DEFAULT NULL COMMENT '反馈接收人姓名',
`FKJSTH` varchar(255) DEFAULT NULL,
`FKJSZT` varchar(255) DEFAULT NULL COMMENT '反馈接收状态',
`ZJBZ` varchar(255) DEFAULT NULL,
`SHBZ` varchar(255) DEFAULT NULL,
`CLLX` varchar(255) DEFAULT NULL COMMENT '处理类型',
`GLSJDBH` varchar(255) DEFAULT NULL COMMENT '关联受警单编号',
`AY` varchar(255) DEFAULT NULL COMMENT '案由',
`JQJB` varchar(255) DEFAULT NULL COMMENT '警情级别',
`CLJG` varchar(255) DEFAULT NULL COMMENT '处理结果',
`CJQK` text,
`YYWJ` varchar(255) DEFAULT NULL,
`XZB` varchar(255) DEFAULT NULL COMMENT '经度',
`YZB` varchar(255) DEFAULT NULL COMMENT '纬度',
`SJC` datetime DEFAULT NULL,
`FKWG` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for t_sjd
-- ----------------------------
DROP TABLE IF EXISTS `t_sjd`;
CREATE TABLE `t_sjd` (
`SJDBH` varchar(255) DEFAULT NULL COMMENT '受警单号 ',
`XZQH` varchar(255) DEFAULT NULL,
`JJDWBH` varchar(255) DEFAULT NULL,
`SFDZ` varchar(255) DEFAULT NULL,
`DWBZW` varchar(255) DEFAULT NULL,
`XZB` varchar(255) DEFAULT NULL,
`YZB` varchar(255) DEFAULT NULL,
`SCBJSJ` datetime DEFAULT NULL,
`BJR` varchar(255) DEFAULT NULL,
`LXDH` varchar(255) DEFAULT NULL,
`LXDZ` varchar(255) DEFAULT NULL,
`XQDW` varchar(255) DEFAULT NULL,
`SSFJ` varchar(255) DEFAULT NULL,
`JZ` varchar(255) DEFAULT NULL,
`CLLX` varchar(255) DEFAULT NULL,
`JQJB` varchar(255) DEFAULT NULL,
`AY` varchar(255) DEFAULT NULL,
`GLSJDBH` varchar(255) DEFAULT NULL,
`SJXQ` varchar(500) DEFAULT NULL,
`CJDW` varchar(255) DEFAULT NULL,
`CLJG` varchar(255) DEFAULT NULL,
`SJCLQK` text,
`SJZT` varchar(255) DEFAULT NULL,
`SCSLJSSJ` datetime DEFAULT NULL,
`BJRXB` varchar(255) DEFAULT NULL,
`SFDZFL` varchar(255) DEFAULT NULL,
`SCSLDBH` varchar(255) DEFAULT NULL,
`SFNM` varchar(255) DEFAULT NULL,
`JJYXM` varchar(255) DEFAULT NULL,
`YYWJ` varchar(255) DEFAULT NULL,
`SJC` datetime DEFAULT NULL,
`SFGJZ` varchar(255) DEFAULT NULL,
`SFFKGJZ` varchar(255) DEFAULT NULL,
`LZBH` varchar(255) DEFAULT NULL,
`JJYGH` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
| true |
6da010044c0a0398759adcda323fc900cb3b1d1f | SQL | sivakumar-g-liaison/alloy-conveyor-server | /service-implementation/src/main/db/migration/GATEWAY_DTDM/V2.4.1.20__mbox_DTDM_add_columns_to_processor.sql | UTF-8 | 1,233 | 3.21875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-commercial-license"
] | permissive | --
-- Copyright 2016 Liaison Technologies, Inc.
-- This software is the confidential and proprietary information of
-- Liaison Technologies, Inc. ("Confidential Information"). You shall
-- not disclose such Confidential Information and shall use it only in
-- accordance with the terms of the license agreement you entered into
-- with Liaison Technologies.
--
/**
* Adding new column "MODIFIED_BY" in the table "PROCESSOR"
*/
DECLARE
v_column_exists number := 0;
BEGIN
Select count(*) into v_column_exists
from all_tab_cols
where column_name = 'MODIFIED_BY'
and table_name = 'PROCESSOR'
and owner = 'GATEWAY_OWNR';
if (v_column_exists = 0) then
execute immediate 'ALTER TABLE GATEWAY_OWNR.PROCESSOR ADD MODIFIED_BY VARCHAR2(128)';
end if;
end;
/
/**
* Adding new column "MODIFIED_DATE" in the table "PROCESSOR"
*/
DECLARE
v_column_exists number := 0;
BEGIN
Select count(*) into v_column_exists
from all_tab_cols
where column_name = 'MODIFIED_DATE'
and table_name = 'PROCESSOR'
and owner = 'GATEWAY_OWNR';
if (v_column_exists = 0) then
execute immediate 'ALTER TABLE GATEWAY_OWNR.PROCESSOR ADD MODIFIED_DATE TIMESTAMP WITH TIME ZONE';
end if;
end;
/
| true |
9d7d36c75dc7f65330950d48901a443d5176e22e | SQL | chiranjitengineer/learngit | /OfficeWorks/Vijayshree/25022021/DBQUERY.sql | UTF-8 | 695 | 3.0625 | 3 | [] | no_license |
SELECT FN_ROUNDOFFRS(P_AMOUNT NUMBER, P_ROUNDOFTO NUMBER, P_ROUNDOFTYPE VARCHAR2 DEFAULT 'S')
FROM DUAL
SELECT FN_ROUNDOFFRS(310, 5, CASE WHEN MOD(310,10) >= 5 THEN 'H' ELSE 'L' END)
FROM DUAL
SELECT MOD(315,10) FROM DUAL
WPSWAGESPROCESSTYPE_PHASE
PROC_WPSDAILYPROCESS_TRANSFER
SELECT TOKENNO,ACTUALPAYBLEAMOUNT,FN_ROUNDOFFRS(ACTUALPAYBLEAMOUNT, 5, CASE WHEN MOD(ACTUALPAYBLEAMOUNT,10) >= 5 THEN 'H' ELSE 'L' END) FROM WPSDAILYWAGESDETAILS
CREATE TABLE WPSDAILYWAGESDETAILS_BK AS
SELECT * FROM WPSDAILYWAGESDETAILS
UPDATE WPSDAILYWAGESDETAILS
SET ACTUALPAYBLEAMOUNT = FN_ROUNDOFFRS(ACTUALPAYBLEAMOUNT, 5, CASE WHEN MOD(ACTUALPAYBLEAMOUNT,10) >= 5 THEN 'H' ELSE 'L' END)
WHERE 1=1;
| true |
f5db692e6c91fa63a23e5f2ea0992bac1d599ee8 | SQL | Jbladevr/HW3 | /HW3Create.sql | UTF-8 | 1,319 | 3.15625 | 3 | [] | no_license | CREATE TABLE Flight (FLIGHT_ID INT PRIMARY KEY, DEPARTURES_SCHEDULED INT,DEPARTURES_PERFORMED INT,
PAYLOAD INT, SEATS INT, PASSENGERS INT, FREIGHT INT, MAIL INT, DISTANCE INT,
DISTANCE_GROUP INT, RAMP_TO_RAMP INT, AIR_TIME INT);
CREATE TABLE Timeframe (YEAR INT PRIMARY KEY,QUARTER INT, MONTH INT);
CREATE TABLE Aircraft (AIRCRAFT_TYPE INT,CLASS VARCHAR(2),AIRCRAFT_GROUP INT,AIRCRAFT_CONFIG INT, PRIMARY KEY (AIRCRAFT_TYPE, CLASS));
CREATE TABLE Airport (AIRPORT_ID INT PRIMARY KEY,AIRPORT_SEQ_ID INT,CITY_MARKET_ID INT,ORIGIN_DESTINATION VARCHAR(5),
CITY_NAME VARCHAR(40),STATE_ABR VARCHAR(3),STATE_FIPS INT,STATE_NM VARCHAR(30),WAC INT);
CREATE TABLE Carrier ( UNIQUE_CARRIER_ENTITY VARCHAR(15) PRIMARY KEY,UNIQUE_CARRIER VARCHAR(15),
AIRLINE_ID INT,UNIQUE_CARRIER_NAME VARCHAR(80),REGION VARCHAR(20),CARRIER_GROUP INT );
CREATE TABLE Maintable(FLIGHT_ID INT REFERENCES Flight,UNIQUE_CARRIER_ENTITY VARCHAR(15) REFERENCES Carrier,
ORIGIN_AIRPORT_ID INT REFERENCES Airport,DEST_AIRPORT_ID INT REFERENCES Airport,YEAR INT REFERENCES Timeframe,
AIRCRAFT_TYPE INT, CLASS VARCHAR(2), FOREIGN KEY (AIRCRAFT_TYPE, CLASS) REFERENCES Aircraft(AIRCRAFT_TYPE, CLASS));
| true |
443adfc33fa315ebd3b458eaf6a853fb4e7bac11 | SQL | 59364202/test | /tools/installer/initdata/database/001_public/schema/3028_rainfall_daily.sql | UTF-8 | 3,989 | 3.984375 | 4 | [] | no_license | -- Table: public.rainfall_daily
-- DROP TABLE public.rainfall_daily;
CREATE TABLE public.rainfall_daily
(
id bigserial NOT NULL, -- รหัสข้อมูลปริมาณน้ำฝนจากสถานีโทรมาตรอัตโนมัติ rainfall's serial number
tele_station_id bigint, -- รหัสสถานีโทรมาตร tele station number
rainfall_datetime timestamp with time zone NOT NULL, -- วันที่เก็บปริมาณน้ำฝน Rainfall date
rainfall_value double precision, -- ปริมาณฝนรายวัน เวลา 7:01 - 7:00 Rainfall daily
dataimport_log_id bigint, -- Define import id รหัสของการ Import ข้อมูล importing data's ID
qc_status json, -- สถานะของการตรวจคุณภาพข้อมูล quality control status
created_by bigint, -- ชื่อผู้ใช้งานที่สร้างข้อมูล created user
created_at timestamp with time zone NOT NULL DEFAULT now(), -- วันที่สร้างข้อมูล created date
updated_by bigint, -- ชื่อผู้ใช้งานที่ปรับปรุงข้อมูล updated user
updated_at timestamp with time zone NOT NULL DEFAULT now(), -- วันที่ปรับปรุงข้อมูลล่าสุด updated date
deleted_by bigint, -- ชื่อผู้ใช้งานที่ลบข้อมูล deleted user
deleted_at timestamp with time zone NOT NULL DEFAULT '1970-01-01 07:00:00+07'::timestamp with time zone, -- วันที่ลบข้อมูล deleted date
CONSTRAINT pk_rainfall_daily PRIMARY KEY (id),
CONSTRAINT fk_rainfall_reference_m_tele_s FOREIGN KEY (tele_station_id)
REFERENCES public.m_tele_station (id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT uk_rainfall_daily UNIQUE (tele_station_id, rainfall_datetime, deleted_at),
CONSTRAINT pt_rainfall_daily_rainfall_datetime CHECK (false) NO INHERIT
)
WITH (
OIDS=FALSE
);
COMMENT ON TABLE public.rainfall_daily
IS 'ฝนรายวัน';
COMMENT ON COLUMN public.rainfall_daily.id IS 'รหัสข้อมูลปริมาณน้ำฝนจากสถานีโทรมาตรอัตโนมัติ rainfall''s serial number';
COMMENT ON COLUMN public.rainfall_daily.tele_station_id IS 'รหัสสถานีโทรมาตร tele station number';
COMMENT ON COLUMN public.rainfall_daily.rainfall_datetime IS 'วันที่เก็บปริมาณน้ำฝน Rainfall date';
COMMENT ON COLUMN public.rainfall_daily.rainfall_value IS 'ปริมาณฝนรายวัน เวลา 7:01 - 7:00 Rainfall daily';
COMMENT ON COLUMN public.rainfall_daily.dataimport_log_id IS 'Define import id รหัสของการ Import ข้อมูล importing data''s ID';
COMMENT ON COLUMN public.rainfall_daily.qc_status IS 'สถานะของการตรวจคุณภาพข้อมูล quality control status';
COMMENT ON COLUMN public.rainfall_daily.created_by IS 'ชื่อผู้ใช้งานที่สร้างข้อมูล created user';
COMMENT ON COLUMN public.rainfall_daily.created_at IS 'วันที่สร้างข้อมูล created date';
COMMENT ON COLUMN public.rainfall_daily.updated_by IS 'ชื่อผู้ใช้งานที่ปรับปรุงข้อมูล updated user';
COMMENT ON COLUMN public.rainfall_daily.updated_at IS 'วันที่ปรับปรุงข้อมูลล่าสุด updated date';
COMMENT ON COLUMN public.rainfall_daily.deleted_by IS 'ชื่อผู้ใช้งานที่ลบข้อมูล deleted user';
COMMENT ON COLUMN public.rainfall_daily.deleted_at IS 'วันที่ลบข้อมูล deleted date';
| true |
ec085378e41a5289cd6828957afbdfb1f2d96a77 | SQL | zacharlie/WBR-SEMP | /survey/survey_queries.sql | UTF-8 | 2,243 | 3.921875 | 4 | [] | no_license | set search_path to wbr_survey,public;
/*
attempt at replacing village geometry with voronoi polygons ABANDONED
update survey_villages sv
set geom = st_multi(st_intersection(st_buffer(st_centroid(sv.geom)::geography,500)::geometry,vp.geom)) from voronoipolys vp where st_within(st_centroid(sv.geom),vp.geom);
*/
--replace villages from mergin db
truncate survey_villages;
insert into survey_villages (id,geom,name,scoping_report_id,sample)
(select id,geom,name,scoping_report_id,sample from survey_villages_mergin);
--once-off generate small buffers around villages (they were too big before)
--create voronoi view
--drop view voronoi_villages;
create view voronoi_villages as
with vp as
(select st_VoronoiPolygons(st_collect(st_centroid(geom))) as geom from survey_villages
)
select (st_dump(geom)).path[1] as id, (st_dump(geom)).geom::geometry(Polygon,4326) as geom from vp;
--update polygons for those villages that have points to encompass all the points in the village
with
cv as
(select sv.id,name,count(*), st_multi(st_intersection(st_buffer(st_concavehull(st_collect(st_force2d(wbr.geometry)),0.5)::geography,100)::geometry,vp.geom)) as geom
from sync_main.wbr wbr
join voronoi_villages vp
on st_within(wbr.geometry,vp.geom)
join survey_villages sv
on st_within(st_centroid(sv.geom),vp.geom)
group by sv.name,sv.id,vp.geom),
matches as
(select sv.id from survey_villages sv join cv using(id)
)
--run first with this to set all polygons (without survey points) to small circles
--update survey_villages sv set geom = st_multi(st_buffer(st_centroid(sv.geom)::geography,500)::geometry) from cv where sv.id not in (select id from matches);
--then run this to set all villages with points to the cv polygons
update survey_villages sv set geom = cv.geom from cv where cv.id = sv.id;
--once-off add count column for reporting
alter table survey_villages add column count int;
--update counts based on how how many points in each village polygon
update survey_villages sv set count = 0;
with counts as (
select sv.id,count(*) from sync_main.wbr wbr join survey_villages sv on st_within(wbr.geometry,sv.geom) group by sv.id)
update survey_villages sv set count = counts.count from counts where sv.id = counts.id; | true |
6c90a6a8cf346aee2b864b0baa40fba78d0878f6 | SQL | USTC417/monitor | /web/src/main/resources/monitor.sql | UTF-8 | 2,606 | 3.34375 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : MySQL
Source Server Version : 50537
Source Host : localhost:3306
Source Database : clustermonitor
Target Server Type : MYSQL
Target Server Version : 50537
File Encoding : 65001
Date: 2017-11-16 23:56:02
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for t_client_info
-- ----------------------------
DROP TABLE IF EXISTS `t_client_info`;
CREATE TABLE `monitor`.`<table_name>` (
`id` varchar(50) NOT NULL COMMENT '客户机id',
`client_system` varchar(50) DEFAULT NULL COMMENT '客户机操作系统名称',
`client_name` varchar(50) DEFAULT NULL COMMENT '客户机名称',
`client_ip` varchar(50) DEFAULT NULL COMMENT '客户机ip',
`client_cpu` varchar(20) DEFAULT NULL COMMENT '客户机CPU型号',
`client_storage` float DEFAULT NULL COMMENT '客户机硬盘容量(GB)',
`client_ram` float DEFAULT NULL COMMENT '客户机运行内存(GB)',
`client_log_path` varchar(100) DEFAULT NULL COMMENT '客户机日志在服务器上的存储路径',
`client_create_time` date DEFAULT NULL COMMENT '客户机连接服务器的日期',
`client_update_time` date DEFAULT NULL COMMENT '客户机最近一次更新日期',
`client_status` int(11) DEFAULT NULL COMMENT '客户机状态 0断线 1在线',
PRIMARY KEY (`id`)
) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='' CHECKSUM=0 DELAY_KEY_WRITE=0;
-- ----------------------------
-- Records of t_client_info
-- ----------------------------
-- ----------------------------
-- Table structure for t_conf_info
-- ----------------------------
DROP TABLE IF EXISTS `t_conf_info`;
CREATE TABLE `t_conf_info` (
`conf_name` varchar(20) DEFAULT NULL COMMENT '配置文件名称',
`conf_path` varchar(20) DEFAULT NULL COMMENT '配置文件路径',
`conf_detail` varchar(100) DEFAULT NULL COMMENT '配置文件说明'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_conf_info
-- ----------------------------
-- ----------------------------
-- Table structure for t_user
-- ----------------------------
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '管理员用户唯一标识',
`user_name` varchar(20) DEFAULT NULL COMMENT '管理员名称',
`password` varchar(20) DEFAULT NULL COMMENT '管理员密码',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_user
-- ----------------------------
SET FOREIGN_KEY_CHECKS=1;
| true |
fb10026ef8eb4866b40d8d9694fe59d955d75395 | SQL | Kyungpyo-Kang/study_sourceCode | /DBMS/workspace/day03.sql | UHC | 4,839 | 4.28125 | 4 | [] | no_license | --ɰ ȭ
CREATE TABLE FLOWER(
NAME VARCHAR2(20),
COLOR VARCHAR2(10),
PRICE NUMBER(6),
CONSTRAINT FLOWER_PK PRIMARY KEY(NAME)
);
SELECT * FROM FLOWER;
CREATE TABLE POT(
ID VARCHAR2(10),
COLOR VARCHAR2(20),
SHAPE VARCHAR2(20),
NAME VARCHAR2(20),
CONSTRAINT POT_PK PRIMARY KEY(ID),
CONSTRAINT POT_FK FOREIGN KEY(NAME) REFERENCES FLOWER(NAME)
);
SELECT * FROM POT;
INSERT INTO FLOWER
(NAME, COLOR, PRICE)
VALUES('', '', 5000);
INSERT INTO FLOWER
(NAME, COLOR, PRICE)
VALUES('عٶ', '', 7000);
INSERT INTO FLOWER
(NAME, COLOR, PRICE)
VALUES('ҹ̲', 'Ͼ', 9000);
SELECT * FROM FLOWER;
INSERT INTO POT
(ID, COLOR, SHAPE, NAME)
VALUES('2019123001', '', ' ', 'ҹ̲');
INSERT INTO POT
(ID, COLOR, SHAPE, NAME)
VALUES('2019123002', '', ' ', '');
INSERT INTO POT
(ID, COLOR, SHAPE, NAME)
VALUES('2019123003', '', ' ', 'عٶ');
SELECT * FROM POT;
INSERT INTO POT
(ID, COLOR, SHAPE, NAME)
VALUES('2019123004', 'Ͼ', 'Ǽ', '');
DELETE FROM POT
WHERE ID='2019123002';
DELETE FROM POT
WHERE ID='2019123004';
SELECT * FROM POT;
DELETE FROM FLOWER
WHERE NAME='';
SELECT * FROM FLOWER;
DROP TABLE POT;
DROP TABLE FLOWER;
/*
* OWNER-> PET
ID VC2(20) PIN VC2(20)
-------------- ----------------
NAME VC2(20) NAME VC2(20)
AGE N(3) ID VC2(20)
ADDRESS VC2(40) AGE N(3)
GENDER C(1)
"TYPE" VC2(20)
*
*/
CREATE TABLE OWNER(
ID VARCHAR2(20),
NAME VARCHAR2(20),
AGE NUMBER(3),
ADDRESS VARCHAR2(40),
CONSTRAINT OWNER_PK PRIMARY KEY(ID)
);
SELECT * FROM OWNER;
CREATE TABLE PET(
PIN VARCHAR2(20),
NAME VARCHAR2(20),
ID VARCHAR2(20),
AGE NUMBER(3),
GENDER CHAR(1) DEFAULT 'M' NOT NULL CONSTRAINT CHECK_CHAR CHECK(GENDER IN('M','W')),
"TYPE" VARCHAR2(20),
CONSTRAINT PET_PK PRIMARY KEY(PIN),
CONSTRAINT PET_FK FOREIGN KEY(ID) REFERENCES OWNER(ID)
);
INSERT INTO OWNER
(ID, NAME, AGE, ADDRESS)
VALUES('2019000001', 'ѵ', 20, ' ﵿ');
INSERT INTO OWNER
(ID, NAME, AGE, ADDRESS)
VALUES('2019000002', 'ȫ浿', 30, 'DZ õ');
SELECT * FROM OWNER;
INSERT INTO PET
(PIN, NAME, ID, AGE, GENDER, "TYPE")
VALUES('1912300001', 'ǻ', '2019000001', 3, 'W' , '');
INSERT INTO PET
(PIN, NAME, ID, AGE, GENDER, "TYPE")
VALUES('1912300002', '۸', '2019000001', 5, 'M' , 'Ƽ');
INSERT INTO PET
(PIN, NAME, ID, AGE, GENDER, "TYPE")
VALUES('1912300003', 'ٵ', '2019000002', 10, 'M' , 'ùٰ');
SELECT * FROM PET;
DROP TABLE PET;
DROP TABLE OWNER;
DROP TABLE STUDENT;
DROP TABLE ANIMAL;
--------------------------------------------------------------
--DML
SELECT PLAYER_NAME FROM PLAYER;
--PLAYER ̺ TEAM_ID 'K01' ˻
SELECT * FROM PLAYER
WHERE TEAM_ID = 'K01';
--PLAYER ̺ TEAM_ID 'K01' ƴ ˻
SELECT * FROM PLAYER
WHERE TEAM_ID <> 'K01';
--PLAYER ̺ WEIGHT 70̻̰ 80 ˻
SELECT * FROM PLAYER
WHERE WEIGHT >= 70 AND WEIGHT <= 80;
SELECT * FROM PLAYER
WHERE WEIGHT BETWEEN 70 AND 80;
--PLAYER ̺ TEAM_ID 'K03'̰ HEIGHT 180̸
SELECT * FROM PLAYER
WHERE TEAM_ID = 'K03' AND HEIGHT < 180;
--ǽ
--PLAYER ̺ TEAM_ID 'K06'̰ NICKNAME '' ˻
SELECT * FROM PLAYER
WHERE TEAM_ID = 'K06' AND NICKNAME = '';
--PLAYER ̺ HEIGHT 170̻̰ WEIGHT 80̻ ̸ ˻
SELECT * FROM PLAYER
WHERE HEIGHT >= 170 AND WEIGHT >= 80;
--STADIUM ̺ SEAT_COUNT 30000ʰ̰ 41000 ˻
SELECT * FROM STADIUM
WHERE SEAT_COUNT > 30000 AND SEAT_COUNT <= 41000;
--PLAYER ̺ TEAM_ID 'K02'̰ų 'K07'̰ 'MF' ˻
--AND OR 켱
--WHERE OR AND δ.
SELECT * FROM PLAYER
WHERE (TEAM_ID = 'K02' OR TEAM_ID = 'K07') AND "POSITION" = 'MF';
SELECT * FROM PLAYER
WHERE TEAM_ID IN('K02', 'K07') AND "POSITION" = 'MF';
--PLAYER ̺ TEAM_ID 'K01' ̸ ̸ ٲٱ
UPDATE PLAYER
SET PLAYER_NAME = 'ѵ'
WHERE TEAM_ID = 'K01';
SELECT * FROM PLAYER
WHERE TEAM_ID = 'K01';
--PLAYER ̺ POSITION 'MF' ϱ
DELETE FROM PLAYER
WHERE "POSITION" = 'MF';
SELECT * FROM PLAYER
WHERE "POSITION" = 'MF';
--PLAYER ̺ HEIGHT 180̻ ϱ
DELETE FROM PLAYER
WHERE HEIGHT >= 180;
SELECT * FROM PLAYER
WHERE HEIGHT >= 180;
| true |
023499f22175c19715653b6a9e2bbbcf6c0cebc4 | SQL | jonatanklosko/competitor-base | /data/sql/relations/organized_in.sql | UTF-8 | 361 | 3.328125 | 3 | [] | no_license | SELECT
competition.id AS ':START_ID(Competition-ID)',
country.iso2 AS ':END_ID(Country-ID)',
competition.cityName AS 'city',
CONCAT('{', 'latitude:', latitude / 1000000, ', longitude:', longitude / 1000000 , '}') AS 'location:point',
'ORGANIZED_IN' AS ':TYPE'
FROM Competitions competition
JOIN Countries country ON country.id = competition.countryId
| true |
d13e286900de21772025410791b3bff9f659cac2 | SQL | luke-jordan/pluto-alpha | /templates/rds/0007-create_audience_tables.sql | UTF-8 | 2,552 | 3.796875 | 4 | [] | no_license | create schema if not exists audience_data;
-- Note: condition instructions cannot change, if they change, it is a new audience, so this is immutable
-- is_dynamic indicates if the audience should be refreshed each time it is gathered (e.g., for recurring boost/messages), or not
create table if not exists audience_data.audience (
audience_id uuid not null primary key,
creating_user_id uuid not null,
client_id varchar(50) not null,
creation_time timestamp with time zone not null default current_timestamp,
audience_type varchar (50) not null,
is_dynamic boolean default false,
selection_instruction jsonb not null,
property_conditions jsonb
);
alter table audience_data.audience drop constraint if exists audience_type_check;
alter table audience_data.audience add constraint audience_type_check check (audience_type in ('PRIMARY', 'INTERMEDIATE'));
-- The 'active' column is for dynamic audiences in which someone may drop out but we want to retain record that they were selected
create table if not exists audience_data.audience_account_join (
audience_id uuid not null references audience_data.audience (audience_id),
account_id uuid not null references account_data.core_account_ledger(account_id),
creation_time timestamp with time zone not null default current_timestamp,
updated_time timestamp with time zone not null default current_timestamp,
active boolean default true,
unique (audience_id, account_id)
);
create index if not exists audience_join_audience_id on audience_data.audience_account_join (audience_id);
create index if not exists audience_join_account_id on audience_data.audience_account_join (account_id);
revoke all on schema audience_data from public cascade;
grant usage on schema audience_data to audience_worker;
grant select, insert on audience_data.audience to audience_worker;
grant select, insert, update on audience_data.audience_account_join to audience_worker;
-- So that boost worker and message worker can populate their tables with reference to here
grant usage on schema audience_data to boost_worker;
grant select (audience_id, is_dynamic) on audience_data.audience to boost_worker;
grant select (account_id, audience_id, active) on audience_data.audience_account_join to boost_worker;
grant usage on schema audience_data to message_api_worker;
grant select (audience_id, is_dynamic) on audience_data.audience to message_api_worker;
grant select (account_id, audience_id, active) on audience_data.audience_account_join to message_api_worker;
| true |
a84bb38b453b8fcc34f17e477afc11a1cf1dd8db | SQL | zanozbot/questly | /install/database.sql | UTF-8 | 3,601 | 3.546875 | 4 | [
"MIT"
] | permissive | -- MySQL Script generated by MySQL Workbench
-- 01/03/17 19:34:32
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema questly
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `questly` ;
-- -----------------------------------------------------
-- Schema questly
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `questly` DEFAULT CHARACTER SET utf8 ;
USE `questly` ;
-- -----------------------------------------------------
-- Table `questly`.`users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `questly`.`users` (
`uid` INT NOT NULL AUTO_INCREMENT,
`username` VARCHAR(30) NOT NULL,
`email` VARCHAR(256) NOT NULL,
`password` VARCHAR(30) NOT NULL,
`role` VARCHAR(30) NULL,
PRIMARY KEY (`uid`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `questly`.`questions`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `questly`.`questions` (
`qid` INT NOT NULL AUTO_INCREMENT,
`uid` INT NULL DEFAULT NULL,
`votes` INT NOT NULL DEFAULT 0,
`views` INT NOT NULL DEFAULT 0,
`replies` INT NOT NULL DEFAULT 0,
`title` VARCHAR(128) NOT NULL,
`content` TEXT NOT NULL,
`timestamp` DATETIME NOT NULL,
PRIMARY KEY (`qid`),
INDEX `uid_idx` (`uid` ASC),
CONSTRAINT `uid_question`
FOREIGN KEY (`uid`)
REFERENCES `questly`.`users` (`uid`)
ON DELETE SET NULL
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `questly`.`answers`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `questly`.`answers` (
`aid` INT NOT NULL AUTO_INCREMENT,
`uid` INT NULL DEFAULT NULL,
`qid` INT NOT NULL,
`votes` INT NOT NULL DEFAULT 0,
`content` TEXT NOT NULL,
`timestamp` DATETIME NOT NULL,
PRIMARY KEY (`aid`, `qid`),
INDEX `qid_idx` (`qid` ASC),
INDEX `uid_idx` (`uid` ASC),
CONSTRAINT `qid_answer`
FOREIGN KEY (`qid`)
REFERENCES `questly`.`questions` (`qid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `uid_answer`
FOREIGN KEY (`uid`)
REFERENCES `questly`.`users` (`uid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `questly`.`comments`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `questly`.`comments` (
`cid` INT NOT NULL AUTO_INCREMENT,
`uid` INT NULL DEFAULT NULL,
`qid` INT NULL DEFAULT NULL,
`aid` INT NULL DEFAULT NULL,
`content` TEXT NOT NULL,
PRIMARY KEY (`cid`),
INDEX `aid_idx` (`aid` ASC),
INDEX `qid_idx` (`qid` ASC),
INDEX `uid_idx` (`uid` ASC),
CONSTRAINT `aid_comment`
FOREIGN KEY (`aid`)
REFERENCES `questly`.`answers` (`aid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `qid_comment`
FOREIGN KEY (`qid`)
REFERENCES `questly`.`questions` (`qid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `uid_comment`
FOREIGN KEY (`uid`)
REFERENCES `questly`.`users` (`uid`)
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 |
73e8073a3b53c36d1c9f949ccf3cdfa6459e0516 | SQL | sz1829/nmu | /dropped_trigger/Trigger_insertTourDetails.sql | UTF-8 | 2,628 | 3.796875 | 4 | [] | no_license | CREATE TRIGGER addTourDetails AFTER INSERT ON TourDetails
FOR EACH ROW
BEGIN
SELECT
sale_price,
sale_currency,
exchange_rate,
coupon,
coupon_currency
FROM IndividualTour WHERE indiv_tour_id = NEW.indiv_tour_id INTO
@sale_price,
@sale_currency,
@exchange_rate,
@it_coupon,
@it_coupon_currency;
SET
@td_coupon = NEW.coupon,
@sale_price = IFNULL(@sale_price, 0),
@it_coupon = IFNULL(@it_coupon, 0),
@received = NEW.received;
IF @sale_price = 0 THEN
UPDATE IndividualTour SET sale_currency = NEW.payment_amount_currency, sale_price = NEW.received WHERE indiv_tour_id = NEW.indiv_tour_id;
ELSE
IF @sale_currency = NEW.payment_amount_currency THEN
UPDATE IndividualTour SET sale_price = sale_price + NEW.received WHERE indiv_tour_id = NEW.indiv_tour_id;
ELSE
IF @sale_currency = 'RMB' THEN
SET @sale_price = @sale_price / @exchange_rate;
END IF;
IF NEW.payment_amount_currency = 'RMB' THEN
SET @received = @received / @exchange_rate;
END IF;
UPDATE IndividualTour SET sale_price = @sale_price + @received, sale_currency = 'USD' WHERE indiv_tour_id = NEW.indiv_tour_id;
END IF;
END IF;
IF @it_coupon = 0 THEN
IF NEW.coupon <> 0 THEN
UPDATE IndividualTour SET coupon_currency = NEW.coupon_currency, coupon = NEW.coupon WHERE indiv_tour_id = NEW.indiv_tour_id;
ELSE
UPDATE IndividualTour SET coupon_currency = NEW.payment_amount_currency, coupon = 0 WHERE indiv_tour_id = NEW.indiv_tour_id;
END IF;
ELSE
IF @it_coupon_currency = NEW.coupon_currency THEN
UPDATE IndividualTour SET coupon = coupon + NEW.coupon WHERE indiv_tour_id = NEW.indiv_tour_id;
ELSE
IF @it_coupon_currency = 'RMB' THEN
SET @it_coupon = @it_coupon / @exchange_rate;
END IF;
IF NEW.coupon_currency = 'RMB' THEN
SET @td_coupon = @td_coupon / @exchange_rate;
END IF;
UPDATE IndividualTour SET coupon = @it_coupon + @td_coupon, coupon_currency = 'USD' WHERE indiv_tour_id = NEW.indiv_tour_id;
END IF;
END IF;
SELECT count(DISTINCT payment_type) FROM TourDetails WHERE indiv_tour_id = NEW.indiv_tour_id INTO @payment_type_number;
IF @payment_type_number = 1 THEN
SELECT DISTINCT payment_type FROM TourDetails WHERE indiv_tour_id = NEW.indiv_tour_id INTO @payment_type_one;
UPDATE Transactions SET payment_type = @payment_type_one WHERE indiv_tour_id = NEW.indiv_tour_id;
ELSE
UPDATE Transactions SET payment_type = 'multiple' WHERE indiv_tour_id = NEW.indiv_tour_id;
END IF;
END | true |
13515cd10d6079dfae0e4663f37972515f471856 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/low/day13/select0139.sql | UTF-8 | 191 | 2.8125 | 3 | [] | no_license |
SELECT timeStamp, temperature
FROM ThermometerObservation
WHERE timestamp>'2017-11-12T01:39:00Z' AND timestamp<'2017-11-13T01:39:00Z' AND SENSOR_ID='3cab109f_d355_4778_856d_2807b743c804'
| true |
06a1c2a6e9219c3e130d6b551930457a2537f3d7 | SQL | daczarne/udemy_master_bigquery_internals | /12_materialized_views_in_bigquery/02_partitioned_mv.sql | UTF-8 | 315 | 3.5625 | 4 | [] | no_license | /* Materialized views can use partitions too */
CREATE MATERIALIZED VIEW `bigquery-demo-285417.dataset1.names_mvd`
PARTITION BY date
AS
SELECT
name
, SUM(count) AS total_count
, _PARTITIONDATE AS date
FROM `bigquery-demo-285417.dataset1.demo_part_ingestion`
WHERE _PARTITIONDATE = "2020-02-19"
GROUP BY 1, 3
| true |
6bec0e90662626dfcf2d8415c033abc54b0e78b2 | SQL | san4ever/SQLmaterial | /Assignment day 1.sql | WINDOWS-1250 | 1,171 | 3.1875 | 3 | [] | no_license | -- Inner join
-- perform inner join on Country and region
-- perform inner join on Employee and Job History.
-- perform inner join on Employee , Department and Location.
-- perform inner join on Loactions , Countries and regions.
-- left outer join
-- perform left join on employee and Department
-- perform left join on Employee , Department and Job
-- perform left join on department , locations and Countries.
-- Right join
-- Same combination as left join
-- Uisng keyword
-- perform left join on employee and Department
-- -- perform inner join on Country and region
-- Self Join
--Name of Employees his managers (Employees table)
--Display the first name, last name, and department number for all employees who work in the same department as employee whose last name is Janette King.
--Display the First name and last name , salary for all employees who earn less than employee number 103
--Display the First name and last name , salary amd job Name for all employees who earn less than employee number 102
--Display the First name and last name , salary , job Name & Dept name for all employees who earn less than employee number 101
| true |
fc429743a515294c9c5cb58a6a97437ef3e0262c | SQL | Neslihan-KK/Airport-Project | /Airport_Project.sql | UTF-8 | 1,339 | 3.515625 | 4 | [] | no_license | CREATE SCHEMA airport AUTHORIZATION postgres;
drop table airport.airports cascade;
CREATE TABLE airport.airports
( airport_id integer not null primary key,
airport_name varchar(50),
airport_location varchar(100)
);
select * from airport.airports;
drop table airport.airways cascade;
CREATE TABLE airport.airways
( airway_id integer not null primary key,
airway_name varchar(50)
);
select * from airport.airways;
drop table airport.route cascade;
CREATE TABLE airport.route
( route_id integer not null primary key,
from_airport_id integer,
to_airport_id integer
);
select * from airport.route;
drop table airport.flight_plan cascade;
CREATE TABLE airport.flight_plan
(
flight_plan_id integer not null primary key,
airway_id integer,
route_id integer,
flight_date timestamp,
plane_name varchar(100),
plane_capacity integer,
full_seat_count integer,
ticket_price float
);
select * from airport.flight_plan;
drop table airport.flight_ticket cascade;
CREATE TABLE airport.flight_ticket
(
flight_ticket_id integer not null primary key,
flight_plan_id integer,
ticket_price float,
passenger_tckn bigint,
passenger_name varchar(100),
passenger_surname varchar(100)
);
select * from airport.flight_ticket;
| true |
c821a327961f97206fb6c6df6f81a5e100ec4074 | SQL | ParkerNat/Zoo_Project | /SQLQuery3.sql | UTF-8 | 3,361 | 3.59375 | 4 | [] | no_license | /**** DRILL 1 ****/
SELECT * FROM tbl_habitat;
/**** DRILL 2 ****/
SELECT species_name FROM tbl_species WHERE species_order = '3';
/**** DRILL 3 ****/
SELECT nutrition_type FROM tbl_nutrition WHERE nutrition_cost <= 600;
/**** DRILL 4 ****/
SELECT tbl_species.species_name, tbl_nutrition.nutrition_id FROM tbl_species INNER JOIN tbl_nutrition
ON tbl_species.species_nutrition = tbl_nutrition.nutrition_id WHERE tbl_nutrition.nutrition_id BETWEEN 2202 AND 2206;
/**** DRILL 5 ****/
SELECT species_name AS 'Species Name:' FROM tbl_species;
SELECT nutrition_type AS 'Nutrition Type:' FROM tbl_nutrition;
/**** DRILL 6 ****/
SELECT S.specialist_fname, S.specialist_lname, S.specialist_contact
FROM tbl_species AS SP
INNER JOIN tbl_care AS C ON SP.species_care = C.care_id
INNER JOIN tbl_specialist AS S ON C.care_specialist = S.specialist_id
WHERE species_name = 'penguin'
;
/**** DRILL 7 ****/
USE db_drill_7
CREATE TABLE tbl_persons (
persons_id INT PRIMARY KEY NOT NULL IDENTITY (1,1),
persons_FNAME VARCHAR (50) NOT NULL,
persons_LNAME VARCHAR (50) NOT NULL,
persons_AGE INT
)
;
INSERT INTO tbl_persons
(persons_FNAME, persons_LNAME, persons_AGE)
VALUES
('Maggie', 'Smith', 65);
INSERT INTO tbl_persons
(persons_FNAME, persons_LNAME, persons_AGE)
VALUES
('Celine', 'Dion', 49);
INSERT INTO tbl_persons
(persons_FNAME, persons_LNAME, persons_AGE)
VALUES
('Eric', 'James', 56);
INSERT INTO tbl_persons
(persons_FNAME, persons_LNAME, persons_AGE)
VALUES
('Phil', 'Olsen', 24);
INSERT INTO tbl_persons
(persons_FNAME, persons_LNAME, persons_AGE)
VALUES
('Bonnie', 'Webberly', 37);
SELECT * FROM tbl_persons
INSERT INTO tbl_persons
(persons_FNAME, persons_LNAME, persons_AGE)
VALUES
('Jacqueline', 'Jones', 72),
('Jeanine', 'Apple', 78),
('Maurice', 'Christian', 52);
CREATE TABLE tbl_contact (
contact_id INT PRIMARY KEY NOT NULL IDENTITY (1,1),
contact_Address VARCHAR (50) NOT NULL,
contact_City VARCHAR (50) NOT NULL,
contact_State VARCHAR (50) NOT NULL,
contact_Phone VARCHAR (50) NOT NULL
);
SELECT * FROM tbl_contact;
INSERT INTO tbl_contact
(contact_Address, contact_City, contact_State, contact_Phone)
VALUES
('1581 Main St', 'Vancouver', 'WA', '206-234-0976'),
('7566 Alain St', 'Seattle', 'WA', '206-432-1598'),
('16925 18th ST', 'Littleton', 'CO', '602-340-2248'),
('2468 Speedway AVE', 'Tempe', 'AZ', '621-534-3776'),
('4554 NW 91st AVE', 'Vancouver', 'WA', '206-894-7548'),
('120 Hanover Blvd', 'Muriel', 'ID', '760-123-6966'),
('35825 Broadway AVE', 'Marion', 'IN', '358-654-2587'),
('12715 Evergreen ST', 'Billings', 'MT', '726-877-1628')
;
SELECT * FROM tbl_persons;
SELECT * FROM tbl_contact;
CREATE TABLE tbl_products (
products_id INT PRIMARY KEY IDENTITY (1,1),
Products_Name VARCHAR (50),
Products_Price FLOAT
);
SELECT * FROM tbl_products
INSERT INTO tbl_products
(Products_Name, Products_Price)
VALUES
('Broccoli Crowns', 2.49),
('Cauliflower', 1.99),
('Zucchini', .99),
('Tomatoes', 1.49),
('Onions', .25),
('Garlic', .50)
;
CREATE TABLE tbl_orders (
OrderId INT PRIMARY KEY IDENTITY (1,1),
OrderDate DATETIME,
CustomerID int,
ProductID int
);
SELECT contact_id AS 'Customer ID', contact_Address AS 'Address', contact_City AS 'City', contact_State AS 'State', contact_Phone AS 'Phone:' FROM tbl_contact;
INSERT INTO tbl_orders
(OrderDate, CustomerID, ProductID)
VALUES
(GetDate (),8,4);
| true |
62e2e3f6f868e83bc5f70f8a8fac7ca6ffc7beb7 | SQL | NYPL-Simplified/circulation | /core/migration/20170303-2-recreate-materialize-views.sql | UTF-8 | 14,172 | 3.890625 | 4 | [
"Apache-2.0"
] | permissive | drop materialized view mv_works_editions_datasources_identifiers;
create materialized view mv_works_editions_datasources_identifiers
as
SELECT
distinct works.id AS works_id,
editions.id AS editions_id,
editions.data_source_id,
editions.primary_identifier_id,
editions.sort_title,
editions.permanent_work_id,
editions.sort_author,
editions.medium,
editions.language,
editions.cover_full_url,
editions.cover_thumbnail_url,
editions.series,
editions.series_position,
datasources.name,
identifiers.type,
identifiers.identifier,
works.audience,
works.target_age,
works.fiction,
works.quality,
works.rating,
works.popularity,
works.random,
works.last_update_time,
works.simple_opds_entry,
works.verbose_opds_entry,
licensepools.id AS license_pool_id,
licensepools.open_access_download_url,
licensepools.availability_time
FROM works
JOIN editions ON editions.id = works.presentation_edition_id
JOIN licensepools ON editions.id = licensepools.presentation_edition_id
JOIN datasources ON licensepools.data_source_id = datasources.id
JOIN identifiers on editions.primary_identifier_id = identifiers.id
WHERE works.presentation_ready = true
AND works.simple_opds_entry IS NOT NULL
ORDER BY editions.sort_title, editions.sort_author, licensepools.availability_time;
-- Create a unique index so that searches can look up books by work ID.
create unique index mv_works_editions_work_id on mv_works_editions_datasources_identifiers (works_id);
-- Create an index on everything, sorted by descending availability time, so that sync feeds are fast.
create index mv_works_editions_by_availability on mv_works_editions_datasources_identifiers (availability_time DESC, sort_author, sort_title, works_id);
-- Similarly, an index on everything, sorted by descending update time.
create index mv_works_editions_by_modification on mv_works_editions_datasources_identifiers (last_update_time DESC, sort_author, sort_title, works_id);
-- We need three versions of each index:
--- One that orders by sort_author, sort_title, and works_id
--- One that orders by sort_title, sort_author, and works_id
--- One that orders by availability_time (descending!), sort_title, sort_author, and works_id
-- English adult fiction
create index mv_works_editions_english_adult_fiction_by_author on mv_works_editions_datasources_identifiers (sort_author, sort_title, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language = 'eng';
create index mv_works_editions_english_adult_fiction_by_title on mv_works_editions_datasources_identifiers (sort_title, sort_author, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language = 'eng';
create index mv_works_editions_english_adult_fiction_by_availability on mv_works_editions_datasources_identifiers (availability_time DESC, sort_author, sort_title, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language = 'eng';
-- English adult nonfiction
create index mv_works_editions_english_adult_nonfiction_by_author on mv_works_editions_datasources_identifiers (sort_author, sort_title, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language = 'eng';
create index mv_works_editions_english_adult_nonfiction_by_title on mv_works_editions_datasources_identifiers (sort_title, sort_author, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language = 'eng';
create index mv_works_editions_english_adult_nonfiction_by_availability on mv_works_editions_datasources_identifiers (availability_time DESC, sort_author, sort_title, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language = 'eng';
-- Nonenglish adult fiction
--- These are also ordered by language
create index mv_works_editions_nonenglish_adult_fiction_by_author on mv_works_editions_datasources_identifiers (sort_author, sort_title, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language <> 'eng';
create index mv_works_editions_nonenglish_adult_fiction_by_title on mv_works_editions_datasources_identifiers (sort_title, sort_author, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language <> 'eng';
create index mv_works_editions_nonenglish_adult_fiction_by_availability on mv_works_editions_datasources_identifiers (availability_time DESC, sort_author, sort_title, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language <> 'eng';
-- Nonenglish adult nonfiction
--- These are also ordered by language
create index mv_works_editions_nonenglish_adult_nonfiction_by_author on mv_works_editions_datasources_identifiers (sort_author, sort_title, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language <> 'eng';
create index mv_works_editions_nonenglish_adult_nonfiction_by_title on mv_works_editions_datasources_identifiers (sort_title, sort_author, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language <> 'eng';
create index mv_works_editions_nonenglish_adult_nonfiction_by_availability on mv_works_editions_datasources_identifiers (availability_time DESC, sort_author, sort_title, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language <> 'eng';
-- YA/Children's fiction, regardless of language
create index mv_works_editions_ya_fiction_by_author on mv_works_editions_datasources_identifiers (sort_author, sort_title, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = true;
create index mv_works_editions_ya_fiction_by_title on mv_works_editions_datasources_identifiers (sort_title, sort_author, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = true;
create index mv_works_editions_ya_fiction_by_availability on mv_works_editions_datasources_identifiers (availability_time DESC, sort_author, sort_title, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = true;
-- YA/Children's nonfiction, regardless of language
create index mv_works_editions_ya_nonfiction_by_author on mv_works_editions_datasources_identifiers (sort_author, sort_title, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = false;
create index mv_works_editions_ya_nonfiction_by_title on mv_works_editions_datasources_identifiers (sort_title, sort_author, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = false;
create index mv_works_editions_ya_nonfiction_by_availability on mv_works_editions_datasources_identifiers (availability_time DESC, sort_author, sort_title, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = false;
drop materialized view mv_works_editions_workgenres_datasources_identifiers;
create materialized view mv_works_editions_workgenres_datasources_identifiers
as
SELECT
works.id AS works_id,
editions.id AS editions_id,
editions.data_source_id,
editions.primary_identifier_id,
editions.sort_title,
editions.permanent_work_id,
editions.sort_author,
editions.medium,
editions.language,
editions.cover_full_url,
editions.cover_thumbnail_url,
editions.series,
editions.series_position,
datasources.name,
identifiers.type,
identifiers.identifier,
workgenres.id AS workgenres_id,
workgenres.genre_id,
workgenres.affinity,
works.audience,
works.target_age,
works.fiction,
works.quality,
works.rating,
works.popularity,
works.random,
works.last_update_time,
works.simple_opds_entry,
works.verbose_opds_entry,
licensepools.id AS license_pool_id,
licensepools.open_access_download_url,
licensepools.availability_time
FROM works
JOIN editions ON editions.id = works.presentation_edition_id
JOIN licensepools ON editions.id = licensepools.presentation_edition_id
JOIN datasources ON licensepools.data_source_id = datasources.id
JOIN identifiers on editions.primary_identifier_id = identifiers.id
JOIN workgenres ON works.id = workgenres.work_id
WHERE works.presentation_ready = true
AND works.simple_opds_entry IS NOT NULL
ORDER BY (editions.sort_title, editions.sort_author, licensepools.availability_time);
-- Create a work/genre lookup.
create unique index mv_works_genres_work_id_genre_id on mv_works_editions_workgenres_datasources_identifiers (works_id, genre_id);
-- Create an index on everything, sorted by descending availability time, so that sync feeds are fast.
create index mv_works_genres_by_availability on mv_works_editions_workgenres_datasources_identifiers (availability_time DESC, sort_author, sort_title, works_id);
-- Similarly, an index on everything, sorted by descending update time.
create index mv_works_genres_by_modification on mv_works_editions_workgenres_datasources_identifiers (last_update_time DESC, sort_author, sort_title, works_id);
-- We need three versions of each index:
--- One that orders by sort_author, sort_title, and works_id
--- One that orders by sort_title, sort_author, and works_id
--- One that orders by availability_time (descending!), sort_title, sort_author, and works_id
-- English adult fiction
create index mv_works_genres_english_adult_fiction_by_author on mv_works_editions_workgenres_datasources_identifiers (sort_author, sort_title, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language = 'eng';
create index mv_works_genres_english_adult_fiction_by_title on mv_works_editions_workgenres_datasources_identifiers (sort_title, sort_author, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language = 'eng';
create index mv_works_genres_english_adult_fiction_by_availability on mv_works_editions_workgenres_datasources_identifiers (availability_time DESC, sort_author, sort_title, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language = 'eng';
-- English adult nonfiction
create index mv_works_genres_english_adult_nonfiction_by_author on mv_works_editions_workgenres_datasources_identifiers (sort_author, sort_title, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language = 'eng';
create index mv_works_genres_english_adult_nonfiction_by_title on mv_works_editions_workgenres_datasources_identifiers (sort_title, sort_author, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language = 'eng';
create index mv_works_genres_english_adult_nonfiction_by_availability on mv_works_editions_workgenres_datasources_identifiers (availability_time DESC, sort_author, sort_title, works_id) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language = 'eng';
-- Nonenglish adult fiction
--- These are also ordered by language
create index mv_works_genres_nonenglish_adult_fiction_by_author on mv_works_editions_workgenres_datasources_identifiers (sort_author, sort_title, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language <> 'eng';
create index mv_works_genres_nonenglish_adult_fiction_by_title on mv_works_editions_workgenres_datasources_identifiers (sort_title, sort_author, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language <> 'eng';
create index mv_works_genres_nonenglish_adult_fiction_by_availability on mv_works_editions_workgenres_datasources_identifiers (availability_time DESC, sort_author, sort_title, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = true AND language <> 'eng';
-- Nonenglish adult nonfiction
--- These are also ordered by language
create index mv_works_genres_nonenglish_adult_nonfiction_by_author on mv_works_editions_workgenres_datasources_identifiers (sort_author, sort_title, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language <> 'eng';
create index mv_works_genres_nonenglish_adult_nonfiction_by_title on mv_works_editions_workgenres_datasources_identifiers (sort_title, sort_author, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language <> 'eng';
create index mv_works_genres_nonenglish_adult_nonfiction_by_availability on mv_works_editions_workgenres_datasources_identifiers (availability_time DESC, sort_author, sort_title, works_id, language) WHERE audience in ('Adult', 'Adults Only') AND fiction = false AND language <> 'eng';
-- YA/Children's fiction, regardless of language
create index mv_works_genres_ya_fiction_by_author on mv_works_editions_workgenres_datasources_identifiers (sort_author, sort_title, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = true;
create index mv_works_genres_ya_fiction_by_title on mv_works_editions_workgenres_datasources_identifiers (sort_title, sort_author, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = true;
create index mv_works_genres_ya_fiction_by_availability on mv_works_editions_workgenres_datasources_identifiers (availability_time DESC, sort_author, sort_title, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = true;
-- YA/Children's nonfiction, regardless of language
create index mv_works_genres_ya_nonfiction_by_author on mv_works_editions_workgenres_datasources_identifiers (sort_author, sort_title, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = false;
create index mv_works_genres_ya_nonfiction_by_title on mv_works_editions_workgenres_datasources_identifiers (sort_title, sort_author, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = false;
create index mv_works_genres_ya_nonfiction_by_availability on mv_works_editions_workgenres_datasources_identifiers (availability_time DESC, sort_author, sort_title, language, works_id) WHERE audience in ('Children', 'Young Adult') AND fiction = false;
| true |
7930d589334492fe2dd352424bff9a33153db768 | SQL | bennyrags/horacethedreamer | /database.sql | UTF-8 | 1,085 | 3.96875 | 4 | [] | no_license |
-- USER is a reserved keyword with Postgres
-- You must use double quotes in every query that user is in:
-- ex. SELECT * FROM "user";
-- Otherwise you will have errors!
CREATE TABLE "user" (
"id" SERIAL PRIMARY KEY,
"username" VARCHAR (80) UNIQUE NOT NULL,
"email" VARCHAR (100) UNIQUE NOT NULL,
"first_name" VARCHAR (200) NOT NULL,
"last_name" VARCHAR (200) NOT NULL,
"password" VARCHAR (1000) NOT NULL
);
CREATE TABLE "dreams" (
id SERIAL PRIMARY KEY,
user_id integer REFERENCES "user",
date date NOT NULL,
description character varying(5000) NOT NULL,
score_temp integer NOT NULL,
score_mood integer NOT NULL,
img_url character varying(100)
);
CREATE TABLE themes (
id SERIAL PRIMARY KEY,
theme_name character varying(100) NOT NULL,
theme_description character varying(500),
theme_creation_date date NOT NULL,
user_id integer REFERENCES "user"
);
CREATE TABLE themes_dreams (
theme_id integer REFERENCES themes(id) ON DELETE CASCADE,
dream_id integer REFERENCES dreams(id) ON DELETE CASCADE
); | true |
f5c6d1db2763ff7a99e6ee7d6745cabade2ff664 | SQL | morenite/melody | /db/sql/database_schema.sql | UTF-8 | 17,738 | 3.421875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.0.6
-- http://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Feb 20, 2014 at 03:21 AM
-- Server version: 5.5.32
-- PHP Version: 5.4.20
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `melody_pc`
--
-- --------------------------------------------------------
--
-- Table structure for table `activities`
--
CREATE TABLE IF NOT EXISTS `activities` (
`id_activity` int(11) NOT NULL AUTO_INCREMENT,
`activity_type_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`created` datetime NOT NULL,
PRIMARY KEY (`id_activity`),
KEY `fk_activities_users1_idx` (`user_id`),
KEY `fk_activities_activity_type_enums1_idx` (`activity_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `activity_types`
--
CREATE TABLE IF NOT EXISTS `activity_types` (
`id_activity_type` int(11) NOT NULL,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id_activity_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `announcements`
--
CREATE TABLE IF NOT EXISTS `announcements` (
`id_announcement` int(11) NOT NULL,
`subject` varchar(45) DEFAULT NULL,
`body` text,
`user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id_announcement`),
KEY `fk_announcements_users1_idx` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `attendances`
--
CREATE TABLE IF NOT EXISTS `attendances` (
`id_attendance` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`rehearsal_id` int(11) NOT NULL,
`attendance_status_id` int(11) NOT NULL,
`reason` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id_attendance`),
KEY `fk_attendances_attendance_status_enums1_idx` (`attendance_status_id`),
KEY `fk_attendances_rehearsals1_idx` (`rehearsal_id`),
KEY `fk_attendances_users1_idx` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `attendance_status`
--
CREATE TABLE IF NOT EXISTS `attendance_status` (
`id_attendance_status` int(11) NOT NULL,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id_attendance_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `cash_data`
--
CREATE TABLE IF NOT EXISTS `cash_data` (
`id_cash_data` int(11) NOT NULL AUTO_INCREMENT,
`amount` double DEFAULT NULL,
`confirmed` tinyint(1) DEFAULT NULL,
`payment_date` date DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`admin_id` int(11) DEFAULT NULL,
`created` datetime DEFAULT NULL,
`modified` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id_cash_data`),
KEY `fk_cash_data_users1_idx` (`user_id`),
KEY `fk_cash_data_users2_idx` (`admin_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `events`
--
CREATE TABLE IF NOT EXISTS `events` (
`id_event` int(11) NOT NULL AUTO_INCREMENT,
`event_type_id` int(11) NOT NULL,
`name` varchar(150) DEFAULT NULL,
`date` date DEFAULT NULL,
`start_time` time DEFAULT NULL,
`end_time` time DEFAULT NULL,
`location` varchar(100) DEFAULT NULL,
`organizer` varchar(100) DEFAULT NULL,
`lat` float DEFAULT NULL,
`long` float DEFAULT NULL,
`person_in_charge` int(11) DEFAULT NULL,
PRIMARY KEY (`id_event`),
KEY `fk_events_users1_idx` (`person_in_charge`),
KEY `fk_events_event_type_enums1_idx` (`event_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `event_songs`
--
CREATE TABLE IF NOT EXISTS `event_songs` (
`id_event_songs` int(11) NOT NULL AUTO_INCREMENT,
`event_id` int(11) DEFAULT NULL,
`song_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id_event_songs`),
KEY `fk_event_songs_songs1_idx` (`song_id`),
KEY `fk_event_songs_events1_idx` (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `event_types`
--
CREATE TABLE IF NOT EXISTS `event_types` (
`id_event_type` int(11) NOT NULL,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id_event_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `key_signatures`
--
CREATE TABLE IF NOT EXISTS `key_signatures` (
`id_key_signature` int(11) NOT NULL,
`name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id_key_signature`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `meetings`
--
CREATE TABLE IF NOT EXISTS `meetings` (
`id_meeting` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(45) NOT NULL,
`themes` text NOT NULL,
`body` text NOT NULL,
`scheduled_start_time` datetime DEFAULT NULL,
`scheduled_end_time` datetime DEFAULT NULL,
`user_id` int(11) NOT NULL,
`created` datetime NOT NULL,
`modified` datetime NOT NULL,
PRIMARY KEY (`id_meeting`),
KEY `fk_meetings_users1_idx` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `messages`
--
CREATE TABLE IF NOT EXISTS `messages` (
`id_message` int(11) NOT NULL AUTO_INCREMENT,
`subject` varchar(100) DEFAULT NULL,
`body` text,
`sender` int(11) NOT NULL,
`recipient` int(11) NOT NULL,
`viewed` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id_message`),
KEY `fk_messages_users1_idx` (`recipient`),
KEY `fk_messages_users2_idx` (`sender`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `midi_files`
--
CREATE TABLE IF NOT EXISTS `midi_files` (
`id_midi_file` int(11) NOT NULL AUTO_INCREMENT,
`url` varchar(500) DEFAULT NULL,
`song_id` int(11) DEFAULT NULL,
`voice_type_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id_midi_file`),
KEY `fk_midi_files_songs1_idx` (`song_id`),
KEY `fk_midi_files_voice_type_enums1_idx` (`voice_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `musical_sheets`
--
CREATE TABLE IF NOT EXISTS `musical_sheets` (
`id_musical_sheet` int(11) NOT NULL AUTO_INCREMENT,
`description` text,
`song_id` int(11) DEFAULT NULL,
`file_url` varchar(512) DEFAULT NULL,
`created` datetime NOT NULL,
`modfied` datetime NOT NULL,
PRIMARY KEY (`id_musical_sheet`),
KEY `fk_musical_sheets_songs1_idx` (`song_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `participations`
--
CREATE TABLE IF NOT EXISTS `participations` (
`id_participation` int(11) NOT NULL AUTO_INCREMENT,
`event_id` int(11) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`status` tinyint(1) DEFAULT '0',
`notes` text,
PRIMARY KEY (`id_participation`),
KEY `fk_participants_users1_idx` (`user_id`),
KEY `fk_participants_events1_idx` (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `rehearsals`
--
CREATE TABLE IF NOT EXISTS `rehearsals` (
`id_rehearsal` int(11) NOT NULL AUTO_INCREMENT,
`date` date DEFAULT NULL,
`start_time` time DEFAULT NULL,
`end_time` time DEFAULT NULL,
`event_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id_rehearsal`),
KEY `fk_rehearsals_events1_idx` (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `roles`
--
CREATE TABLE IF NOT EXISTS `roles` (
`id_role` int(11) NOT NULL,
`name` varchar(45) NOT NULL,
`description` text,
PRIMARY KEY (`id_role`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `songs`
--
CREATE TABLE IF NOT EXISTS `songs` (
`id_song` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) DEFAULT NULL,
`arranger` varchar(255) DEFAULT NULL,
`composer` varchar(255) DEFAULT NULL,
`song_category_id` int(11) NOT NULL,
`tempo` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id_song`),
KEY `fk_songs_song_categories1_idx` (`song_category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `song_categories`
--
CREATE TABLE IF NOT EXISTS `song_categories` (
`id_song_category` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`description` text,
PRIMARY KEY (`id_song_category`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
-- --------------------------------------------------------
--
-- Table structure for table `song_key_signatures`
--
CREATE TABLE IF NOT EXISTS `song_key_signatures` (
`id_song_key_signature` int(11) NOT NULL AUTO_INCREMENT,
`song_id` int(11) NOT NULL,
`key_signature_id` int(11) NOT NULL,
PRIMARY KEY (`id_song_key_signature`),
KEY `fk_song_key_signatures_key_signatures1_idx` (`key_signature_id`),
KEY `fk_song_key_signatures_songs1_idx` (`song_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id_user` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`email` varchar(255) NOT NULL,
`phone` varchar(45) DEFAULT NULL,
`mobile_phone` varchar(45) NOT NULL,
`img_url` varchar(255) DEFAULT NULL,
`name` varchar(100) NOT NULL,
`nickname` varchar(45) NOT NULL,
`birthday` date NOT NULL,
`join_date` date NOT NULL,
`voice_type_id` int(11) DEFAULT NULL,
`role_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id_user`),
KEY `fk_users_roles_idx` (`role_id`),
KEY `fk_users_voice_type_enums1_idx` (`voice_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `videos`
--
CREATE TABLE IF NOT EXISTS `videos` (
`id_video` int(11) NOT NULL AUTO_INCREMENT,
`url` varchar(500) DEFAULT NULL,
`song_id` int(11) NOT NULL,
PRIMARY KEY (`id_video`),
KEY `fk_videos_songs1_idx` (`song_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `voice_range_data`
--
CREATE TABLE IF NOT EXISTS `voice_range_data` (
`id_voice_range_datum` int(11) NOT NULL AUTO_INCREMENT,
`ambitus_date` date DEFAULT NULL,
`lower_bound_note` varchar(3) DEFAULT NULL,
`upper_bound_note` varchar(3) DEFAULT NULL,
`timbre` varchar(100) DEFAULT NULL,
`user_id` int(11) NOT NULL,
`assessor_id` int(11) NOT NULL,
PRIMARY KEY (`id_voice_range_datum`),
KEY `fk_voice_range_data_users1_idx` (`user_id`),
KEY `fk_voice_range_data_users2_idx` (`assessor_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `voice_types`
--
CREATE TABLE IF NOT EXISTS `voice_types` (
`id_voice_type` int(11) NOT NULL,
`name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id_voice_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `activities`
--
ALTER TABLE `activities`
ADD CONSTRAINT `fk_activities_activity_type_enums1` FOREIGN KEY (`activity_type_id`) REFERENCES `activity_types` (`id_activity_type`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_activities_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `announcements`
--
ALTER TABLE `announcements`
ADD CONSTRAINT `fk_announcements_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `attendances`
--
ALTER TABLE `attendances`
ADD CONSTRAINT `fk_attendances_attendance_status_enums1` FOREIGN KEY (`attendance_status_id`) REFERENCES `attendance_status` (`id_attendance_status`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_attendances_rehearsals1` FOREIGN KEY (`rehearsal_id`) REFERENCES `rehearsals` (`id_rehearsal`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_attendances_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `cash_data`
--
ALTER TABLE `cash_data`
ADD CONSTRAINT `fk_cash_data_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_cash_data_users2` FOREIGN KEY (`admin_id`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `events`
--
ALTER TABLE `events`
ADD CONSTRAINT `fk_events_event_type_enums1` FOREIGN KEY (`event_type_id`) REFERENCES `event_types` (`id_event_type`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_events_users1` FOREIGN KEY (`person_in_charge`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `event_songs`
--
ALTER TABLE `event_songs`
ADD CONSTRAINT `fk_event_songs_events1` FOREIGN KEY (`event_id`) REFERENCES `events` (`id_event`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_event_songs_songs1` FOREIGN KEY (`song_id`) REFERENCES `songs` (`id_song`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `meetings`
--
ALTER TABLE `meetings`
ADD CONSTRAINT `fk_meetings_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `messages`
--
ALTER TABLE `messages`
ADD CONSTRAINT `fk_messages_users1` FOREIGN KEY (`recipient`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_messages_users2` FOREIGN KEY (`sender`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `midi_files`
--
ALTER TABLE `midi_files`
ADD CONSTRAINT `fk_midi_files_voice_type_enums1` FOREIGN KEY (`voice_type_id`) REFERENCES `voice_types` (`id_voice_type`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_midi_files_songs1` FOREIGN KEY (`song_id`) REFERENCES `songs` (`id_song`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `musical_sheets`
--
ALTER TABLE `musical_sheets`
ADD CONSTRAINT `fk_musical_sheets_songs1` FOREIGN KEY (`song_id`) REFERENCES `songs` (`id_song`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `participations`
--
ALTER TABLE `participations`
ADD CONSTRAINT `fk_participants_events1` FOREIGN KEY (`event_id`) REFERENCES `events` (`id_event`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_participants_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `rehearsals`
--
ALTER TABLE `rehearsals`
ADD CONSTRAINT `fk_rehearsals_events1` FOREIGN KEY (`event_id`) REFERENCES `events` (`id_event`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `songs`
--
ALTER TABLE `songs`
ADD CONSTRAINT `fk_songs_song_categories1` FOREIGN KEY (`song_category_id`) REFERENCES `song_categories` (`id_song_category`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `song_key_signatures`
--
ALTER TABLE `song_key_signatures`
ADD CONSTRAINT `fk_song_key_signatures_key_signatures1` FOREIGN KEY (`key_signature_id`) REFERENCES `key_signatures` (`id_key_signature`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_song_key_signatures_songs1` FOREIGN KEY (`song_id`) REFERENCES `songs` (`id_song`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `users`
--
ALTER TABLE `users`
ADD CONSTRAINT `fk_users_voice_type_enums1` FOREIGN KEY (`voice_type_id`) REFERENCES `voice_types` (`id_voice_type`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_users_roles` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id_role`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `videos`
--
ALTER TABLE `videos`
ADD CONSTRAINT `fk_videos_songs1` FOREIGN KEY (`song_id`) REFERENCES `songs` (`id_song`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `voice_range_data`
--
ALTER TABLE `voice_range_data`
ADD CONSTRAINT `fk_voice_range_data_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_voice_range_data_users2` FOREIGN KEY (`assessor_id`) REFERENCES `users` (`id_user`) ON DELETE NO ACTION ON UPDATE NO ACTION;
/*!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 |
a6190981444e7173eee131c3bf78ae9739908bce | SQL | adzhenalieva/control-work-10 | /api/post.sql | UTF-8 | 1,090 | 3.765625 | 4 | [] | no_license | CREATE SCHEMA `post` DEFAULT CHARACTER SET utf8 ;
USE `post`;
CREATE TABLE `news` (
`id` INT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`description` TEXT NOT NULL,
`image` VARCHAR(255) NULL,
`date` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`));
CREATE TABLE `comments` (
`id` INT NOT NULL AUTO_INCREMENT,
`news_id` INT NOT NULL,
`author` VARCHAR(255) NULL,
`comment` TEXT NOT NULL,
PRIMARY KEY (`id`),
INDEX `news_id_fk_idx` (`news_id` ASC),
CONSTRAINT `news_id_fk`
FOREIGN KEY (`news_id`)
REFERENCES `news` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE);
INSERT INTO `news` (`title`, `description`, `date`)
VALUES ('New kindergarden', 'New kindergarden was opened in Bishkek', '2019-03-28T14:48:00.000Z'), ('V.Putin visited Bishkek', 'The president of RF has visited Bishkek', '2019-03-28T14:48:00.000Z'), ('New hospital', 'New hospital was opened in Bishkek', '2019-03-30T14:48:00.000Z');
INSERT INTO `comments` (`news_id`, `author`, `comment`)
VALUES (1, 'Mario', 'Great news'), (2, 'Leo', 'Nice news'), (3, 'Miki', 'Super');
| true |
3d135f8a05418faef32400f54785beb196f20528 | SQL | bellmit/ws | /0 项目文档/.svn/pristine/33/3314e9551631d015f93fe868fe059e65e9b52c82.svn-base | UTF-8 | 1,120 | 3.34375 | 3 | [] | no_license | CREATE TABLE "LIFE".t_item_param_stock_record (
"ID" NUMBER(8) NOT NULL,
stock_id NUMBER(8) NOT NULL,
remark VARCHAR2(200 BYTE) NOT NULL,
"TYPE" NUMBER(1),
quantity NUMBER(8) DEFAULT 1,
item_color VARCHAR2(50 BYTE),
item_size VARCHAR2(50 BYTE),
item_brand VARCHAR2(50 BYTE),
create_time VARCHAR2(14 BYTE),
CONSTRAINT pk_t_item_param_stock_record PRIMARY KEY ("ID",stock_id)
);
COMMENT ON COLUMN "LIFE".t_item_param_stock_record."ID" IS '流水号';
COMMENT ON COLUMN "LIFE".t_item_param_stock_record.stock_id IS '商品参数编号';
COMMENT ON COLUMN "LIFE".t_item_param_stock_record.remark IS '备注';
COMMENT ON COLUMN "LIFE".t_item_param_stock_record."TYPE" IS '操作类型(0:扣减库存;1:释放库存)';
COMMENT ON COLUMN "LIFE".t_item_param_stock_record.quantity IS '库存量';
COMMENT ON COLUMN "LIFE".t_item_param_stock_record.item_color IS '颜色';
COMMENT ON COLUMN "LIFE".t_item_param_stock_record.item_size IS '尺码';
COMMENT ON COLUMN "LIFE".t_item_param_stock_record.item_brand IS '品牌';
COMMENT ON COLUMN "LIFE".t_item_param_stock_record.create_time IS '操作时间'; | true |
f35fc14acce62c70a6d9aa620433ad66aaa8a9d3 | SQL | galigaribaldi/CursoSQL | /SQL2/Viernes/tablespaces.sql | UTF-8 | 1,873 | 2.90625 | 3 | [] | no_license | --@Autors: Cabrera Garibaldi Hernan Galileo
--@Autors: Medel Sánchez Berenice
--@Fecha: 02/Diciembre/2019
--@Descricpion: Script el cual crea los TableSpaces Necesarios para la base
--Creación de TableSpaces
--TableSpace para libro en PDF
--Se recomienda el uso de adminsitración automatica
prompt Creacion del tableSpace para el PDF del libro
CREATE TABLESPACE libropdf_tb
datafile '/u01/app/oracle/oradata/GAMESBD3/libropdf_tb.dbf' size 100m
extent management local autoallocate
segment space management auto;
--Tablespace para PDF tesis
prompt Creacion del tableSpace para el PDF de la tesis
CREATE TABLESPACE tesispdf_tb
datafile '/u01/app/oracle/oradata/GAMESBD3/tesispdf_tb.dbf' size 100m
extent management local autoallocate
segment space management auto;
--TableSpace para Foto de usuarios
prompt Creacion del tableSpace para el PDF de la foto de usuarios
CREATE TABLESPACE foto_usuarios_tb
datafile '/u01/app/oracle/oradata/GAMESBD3/tesis_tb.dbf' size 400m
extent management local autoallocate
segment space management auto;
-----------Table Spaces Asginados a las tablas que se cree crecerán mas debido a la información que conlleva
prompt Creacion del TableSpace correspondiente a Resgistro
CREATE TABLESPACE recurso_ts
datafile '/u01/app/oracle/oradata/GAMESBD3/registro_tb.dbf' size 400m
extent management local autoallocate
segment space management auto;
--Tablespace correspondiente a los usuarios
prompt Creacion del TableSpace correspondiente a Usuario
CREATE TABLESPACE entidades_tb
datafile '/u01/app/oracle/oradata/GAMESBD3/entidades_tb.dbf' size 400m
extent management local autoallocate
segment space management auto;
--Tablespace correspondiente a los Indices
prompt Creacion del Tablespace correspondiente a Indices
CREATE TABLESPACE indices_ts
datafile '/u01/app/oracle/oradata/GAMESBD3/index_tb.dbf' size 400m
extent management local autoallocate
segment space management auto; | true |
064776735275a9a2a6464a54c2a6485740540925 | SQL | radtek/LS | /Delphi/FDC Library/FDC Standard Applications/Standard VERO Application/Server/fdc_Task_Lst_By_Group.sql | UTF-8 | 184 | 2.859375 | 3 | [] | no_license | create or replace view fdc_Task_Lst_By_Group as
select /*ordered*/
T.*,
UGT.User_Group_ID
from fdc_User_Group_Task UGT,
fdc_Task_Lst T
where T.ID = UGT.Task_ID;
| true |
fa04ee16f609df91a9e0a3ba3a792cfc2a7dfc94 | SQL | Marcus-V-Freitas/SQL_Utils | /Diversos/PesquisarPorNome.sql | ISO-8859-1 | 412 | 3.328125 | 3 | [
"MIT"
] | permissive | SELECT A.NAME, A.XTYPE, B.TEXT
FROM SYSOBJECTS A (nolock)
JOIN SYSCOMMENTS B (nolock)
ON A.ID = B.ID
WHERE B.TEXT LIKE '%INSERT INTO MvNotaFiscalParcelas%' --Palavra a ser buscada
AND A.XTYPE = 'P' -- Tipo onde quer ser pesquisado
ORDER BY A.NAME
--Tipos mais comuns a serem pesquisados
--P - Procedures
--TR - Triggers
--U - Tabelas
--V - Views
--PK - Chave Primria
--F - Chave Estrangeira
--FN - Funo
| true |
3395e57fe851c5823ee588e49fa132da87037882 | SQL | Rickyvit/parcial1_programacion3 | /api/config/forum.sql | UTF-8 | 991 | 3.96875 | 4 | [] | no_license | DROP DATABASE IF EXISTS forum;
CREATE DATABASE IF NOT EXISTS forum;
USE forum;
/*----------------------------*/
CREATE TABLE usuarios(
id INT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL PRIMARY KEY,
usuario VARCHAR(50) UNIQUE NOT NULL,
correo VARCHAR(255) UNIQUE NOT NULL,
clave VARCHAR(255) NOT NULL
)ENGINE=InnoDB;
/*----------------------------*/
CREATE TABLE posts (
id INT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL,
titulo VARCHAR(30) NOT NULL,
contenido VARCHAR(200) NOT NULL,
fecha DATETIME NOT NULL,
usuarios_id INT UNSIGNED NOT NULL,
PRIMARY KEY(id),
FOREIGN KEY (usuarios_id) REFERENCES usuarios(id) ON DELETE CASCADE
)ENGINE=InnoDB;
CREATE TABLE likes (
id INT UNSIGNED UNIQUE AUTO_INCREMENT NOT NULL,
usuarios_id INT UNSIGNED NOT NULL,
posts_id INT UNSIGNED NOT NULL,
PRIMARY KEY(id),
FOREIGN KEY (usuarios_id) REFERENCES usuarios(id) ON DELETE CASCADE,
FOREIGN KEY (posts_id) REFERENCES posts(id) ON DELETE CASCADE
)
| true |
a1261278093cb779ccab5fd1b10d890e6cc7b0a7 | SQL | hyung000620/Study-DataBase | /[Computer-Science] Database Assignment/[Database] Lab #12/lab11-2015118527.sql | UTF-8 | 1,265 | 3.9375 | 4 | [
"MIT"
] | permissive | -- 1) Display the output (in the TYPICAL format by default) of EXPLAIN PLAN for the following query
-- Q: Which join algorithm is used for this query? 72
EXPLAIN PLAN FOR SELECT e1.Fname, e1.Lname FROM EMPLOYEE e1 WHERE e1.Salary = (SELECT MAX(Salary) FROM EMPLOYEE e2);
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
-- 2) Display the output in the BASIC format by default of EXPLAIN PLAN for the following query
-- Q: Which join algorithm is used for this query? SORT
EXPLAIN PLAN FOR SELECT COUNT(*) FROM DEPARTMENT d WHERE d.Dnumber IN (SELECT E.Dno FROM EMPLOYEE E WHERE E.Salary > 20000);
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
-- 3) Display the output in the BASIC format by default of EXPLAIN PLAN for the following query
-- Q: What join algorithms are used for this plan? MERGE JOIN, SORT JOIN, HASH JOIN
-- Q: How many operators are used for this plan? 6 (SELECT STATEMENT, SORT ORDER BY, MERGE JOIN, SORT JOIN, MERGE JOIN, TABLE ACCESS BY INDEX ROWID| PROJECT)
-- Q: Which table is fully scanned in outer loop? PROJECT
EXPLAIN PLAN FOR SELECT /*+ USE_MERGE(EMPLOYEE PROJECT WORKS_ON) */ Fname, Lname FROM EMPLOYEE, PROJECT, WORKS_ON WHERE Ssn = Essn AND Pno = Pnumber AND Pname = 'ProjectX' ORDER BY Lname desc;
SELECT * FROM TABLE(SYS.DBMS_XPLAN.DISPLAY); | true |
11ee117edcd4a7da4fd3ff43111ce984a36ef5b4 | SQL | theguywhodoesthething/SD_Projects | /rest-lab/restLab.sql | UTF-8 | 3,168 | 3.75 | 4 | [] | no_license | -- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema restlab
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `restlab` ;
-- -----------------------------------------------------
-- Schema restlab
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `restlab` DEFAULT CHARACTER SET utf8 ;
USE `restlab` ;
-- -----------------------------------------------------
-- Table `user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `user` ;
CREATE TABLE IF NOT EXISTS `user` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`email` VARCHAR(255) NOT NULL,
`password` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `todo`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `todo` ;
CREATE TABLE IF NOT EXISTS `todo` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`task` VARCHAR(55) NOT NULL,
`description` TEXT NULL,
`completed` TINYINT(1) NULL,
`due_date` VARCHAR(50) NULL,
`complete_date` VARCHAR(50) NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user_id` INT(11) NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_todo_user_idx` (`user_id` ASC),
CONSTRAINT `fk_todo_user`
FOREIGN KEY (`user_id`)
REFERENCES `user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
USE `restlab`;
DELIMITER $$
USE `restlab`$$
DROP TRIGGER IF EXISTS `todo_AFTER_UPDATE` $$
USE `restlab`$$
CREATE DEFINER = CURRENT_USER TRIGGER `restlab`.`todo_AFTER_UPDATE` AFTER UPDATE ON `todo` FOR EACH ROW
BEGIN
END
$$
DELIMITER ;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
-- -----------------------------------------------------
-- Data for table `user`
-- -----------------------------------------------------
START TRANSACTION;
USE `restlab`;
INSERT INTO `user` (`id`, `email`, `password`) VALUES (1, 'example@example.com', 'password');
COMMIT;
-- -----------------------------------------------------
-- Data for table `todo`
-- -----------------------------------------------------
START TRANSACTION;
USE `restlab`;
INSERT INTO `todo` (`id`, `task`, `description`, `completed`, `due_date`, `complete_date`, `created_at`, `updated_at`, `user_id`) VALUES (1, 'chores', 'take out the garbage', 0, NULL, NULL, DEFAULT, DEFAULT, 1);
INSERT INTO `todo` (`id`, `task`, `description`, `completed`, `due_date`, `complete_date`, `created_at`, `updated_at`, `user_id`) VALUES (2, 'baseball', 'hit a homerun', 1, NULL, NULL, DEFAULT, DEFAULT, 1);
INSERT INTO `todo` (`id`, `task`, `description`, `completed`, `due_date`, `complete_date`, `created_at`, `updated_at`, `user_id`) VALUES (3, 'java', 'create an entity', 1, NULL, NULL, DEFAULT, DEFAULT, 1);
COMMIT;
| true |
20331e81756d5f4ccbe254c51c91905dea9fd9f5 | SQL | danbikle/stk_mkt_madlib_logregr | /qry_predictions12.sql | UTF-8 | 1,881 | 3.5625 | 4 | [] | no_license | \set ECHO all
--
-- ~/tv/qry_predictions12.sql
--
-- Look at Bearish predictions:
SELECT
COUNT(tkr) ccount
,ROUND(AVG(ng3),4) avg_ng3
,ROUND(SUM(ng3),4) sum_ng3
,ROUND(AVG(ng3)/STDDEV(ng3),4) sharpe_r
FROM predictions12
WHERE prob<0.45
;
-- Look at Bullish predictions:
SELECT
COUNT(tkr) ccount
,ROUND(AVG(ng3),4) avg_ng3
,ROUND(SUM(ng3),4) sum_ng3
,ROUND(AVG(ng3)/STDDEV(ng3),4) sharpe_r
FROM predictions12
WHERE prob>0.55
;
-- Look at Bearish predictions for each ticker:
SELECT
tkr
,COUNT(tkr) ccount
,ROUND(AVG(ng3),4) avg_ng3
,ROUND(SUM(ng3),4) sum_ng3
,ROUND(AVG(ng3)/STDDEV(ng3),4) sharpe_r
FROM predictions12
WHERE prob<0.45
GROUP BY tkr
HAVING COUNT(tkr) > 9
ORDER BY SUM(ng3)
;
-- Look at Bullish predictions for each ticker:
SELECT
tkr
,COUNT(tkr) ccount
,ROUND(AVG(ng3),4) avg_ng3
,ROUND(SUM(ng3),4) sum_ng3
,ROUND(AVG(ng3)/STDDEV(ng3),4) sharpe_r
FROM predictions12
WHERE prob>0.55
GROUP BY tkr
HAVING COUNT(tkr) > 9
ORDER BY SUM(ng3)
;
-- Classic Accuracy Calculation.
-- True Positives + True Negatives here:
SELECT
COUNT(tkr) ccount
FROM predictions12
WHERE SIGN(prob-0.5) = SIGN(ng3)
;
-- All observations
SELECT COUNT(tkr) FROM predictions12;
-- Accuracy is Count(True Positives) + Count(True Negatives) / Count(All observations)
-- Usually it is near 50%.
-- Confusion Matrix Calculations.
-- True Positives:
SELECT COUNT(tkr) ccount FROM predictions12 WHERE prob>0.5 AND ng3>0;
-- True Negatives:
SELECT COUNT(tkr) ccount FROM predictions12 WHERE prob<0.5 AND ng3<0;
-- False Positives:
SELECT COUNT(tkr) ccount FROM predictions12 WHERE prob>0.5 AND ng3<0;
-- False Negatives:
SELECT COUNT(tkr) ccount FROM predictions12 WHERE prob<0.5 AND ng3>0;
-- end
| true |
2849742ebcceacc387d67d2f86e1c8dd9c1058c3 | SQL | nihed/magnetism | /jive_messenger/vendor/jive_messenger_2_2_branch_r2910/src/database/upgrade/1.1_to_2.0/messenger_postgresql.sql | UTF-8 | 5,585 | 2.765625 | 3 | [] | no_license | -- $RCSfile$
-- $Revision: 395 $
-- $Date: 2004-11-13 14:57:13 -0500 (Sat, 13 Nov 2004) $
-- upgrades from Messenger 1.1.x to 2.0.x
-- jiveUser: Adds new column "username". Removes "nameVisible" & "emailVisible". Changes primary key
ALTER TABLE jiveUser ADD COLUMN username VARCHAR(32) NOT NULL;
ALTER TABLE jiveUser DROP COLUMN nameVisible;
ALTER TABLE jiveUser DROP COLUMN emailVisible;
UPDATE jiveUser,jiveUserID SET jiveUser.username = jiveUserID.username where jiveUserID.objectID = jiveUser.userID;
ALTER TABLE jiveUser DROP PRIMARY KEY;
ALTER TABLE jiveUser ADD CONSTRAINT jiveUser_pk PRIMARY KEY (username);
-- jiveUserProp: Adds new column "username". Changes primary key
ALTER TABLE jiveUserProp ADD COLUMN username VARCHAR(32) NOT NULL;
UPDATE jiveUserProp,jiveUser SET jiveUserProp.username = jiveUser.username where jiveUserProp.userID = jiveUser.userID;
ALTER TABLE jiveUserProp DROP PRIMARY KEY;
ALTER TABLE jiveUserProp ADD CONSTRAINT jiveUserProp_pk PRIMARY KEY (username, name);
-- jiveGroupUser: Adds new column "username". Changes primary key
ALTER TABLE jiveGroupUser ADD COLUMN username VARCHAR(32) NOT NULL;
UPDATE jiveGroupUser,jiveUser SET jiveGroupUser.username = jiveUser.username where jiveGroupUser.userID = jiveUser.userID;
ALTER TABLE jiveGroupUser DROP PRIMARY KEY;
ALTER TABLE jiveGroupUser ADD CONSTRAINT jiveGroupUser_pk PRIMARY KEY (groupID, username, administrator);
-- jivePrivate: Adds new column "username". Changes primary key
ALTER TABLE jivePrivate ADD COLUMN username VARCHAR(32) NOT NULL;
UPDATE jivePrivate,jiveUser SET jivePrivate.username = jiveUser.username where jivePrivate.userID = jiveUser.userID;
ALTER TABLE jivePrivate DROP PRIMARY KEY;
ALTER TABLE jivePrivate ADD CONSTRAINT jivePrivate_pk PRIMARY KEY (username, name, namespace);
-- jiveOffline: Adds new column "username". Changes primary key
ALTER TABLE jiveOffline ADD COLUMN username VARCHAR(32) NOT NULL;
UPDATE jiveOffline ,jiveUser SET jiveOffline.username = jiveUser.username where jiveOffline.userID = jiveUser.userID;
ALTER TABLE jiveOffline DROP PRIMARY KEY;
ALTER TABLE jiveOffline ADD CONSTRAINT jiveOffline_pk PRIMARY KEY (username, messageID);
-- jiveRoster: Adds new column "username". Replaces old index with new one
ALTER TABLE jiveRoster ADD COLUMN username VARCHAR(32) NOT NULL;
UPDATE jiveRoster,jiveUser SET jiveRoster.username = jiveUser.username where jiveRoster.userID = jiveUser.userID;
DROP INDEX jiveRoster_userID_idx;
CREATE INDEX jiveRoster_username_idx ON jiveRoster (username);
-- jiveVCard: Adds new column "username". Changes primary key
ALTER TABLE jiveVCard ADD COLUMN username VARCHAR(32) NOT NULL;
UPDATE jiveVCard ,jiveUser SET jiveVCard.username = jiveUser.username where jiveVCard.userID = jiveUser.userID;
ALTER TABLE jiveVCard DROP PRIMARY KEY;
ALTER TABLE jiveVCard ADD CONSTRAINT jiveVCard_pk PRIMARY KEY (username, name);
-- Drops no longer needed tables
DROP TABLE jiveUserID;
DROP TABLE jiveChatbot;
DROP TABLE jiveDomain;
DROP TABLE jiveUserPerm;
-- Deletes no longer needed entries
DELETE FROM jiveID where idType = 0;
DELETE FROM jiveID where idType = 1;
DELETE FROM jiveID where idType = 2;
DELETE FROM jiveID where idType = 13;
DELETE FROM jiveID where idType = 14;
-- Finally remove "userID" column
ALTER TABLE jiveUserProp DROP COLUMN userID;
ALTER TABLE jiveUser DROP COLUMN userID;
ALTER TABLE jiveGroupUser DROP COLUMN userID;
ALTER TABLE jivePrivate DROP COLUMN userID;
ALTER TABLE jiveOffline DROP COLUMN userID;
ALTER TABLE jiveRoster DROP COLUMN userID;
ALTER TABLE jiveVCard DROP COLUMN userID;
-- Create new tables
CREATE TABLE jiveProperty (
name VARCHAR(100) NOT NULL,
propValue VARCHAR(4000) NOT NULL,
CONSTRAINT jiveProperty_pk PRIMARY KEY (name)
);
-- MUC Tables
CREATE TABLE mucRoom (
roomID INTEGER NOT NULL,
creationDate CHAR(15) NOT NULL,
modificationDate CHAR(15) NOT NULL,
name VARCHAR(50) NOT NULL,
naturalName VARCHAR(255) NOT NULL,
description VARCHAR(255),
canChangeSubject INTEGER NOT NULL,
maxUsers INTEGER NOT NULL,
publicRoom INTEGER NOT NULL,
moderated INTEGER NOT NULL,
invitationRequired INTEGER NOT NULL,
canInvite INTEGER NOT NULL,
password VARCHAR(50) NULL,
canDiscoverJID INTEGER NOT NULL,
logEnabled INTEGER NOT NULL,
subject VARCHAR(100) NULL,
rolesToBroadcast INTEGER NOT NULL,
lastActiveDate CHAR(15) NULL,
inMemory INTEGER NOT NULL,
CONSTRAINT mucRoom__pk PRIMARY KEY (name)
);
CREATE INDEX mucRoom_roomID_idx ON mucRoom(roomID);
CREATE TABLE mucAffiliation (
roomID INTEGER NOT NULL,
jid VARCHAR(3000) NOT NULL,
affiliation INTEGER NOT NULL,
CONSTRAINT mucAffiliation__pk PRIMARY KEY (roomID,jid)
);
CREATE TABLE mucMember (
roomID INTEGER NOT NULL,
jid TEXT NOT NULL,
nickname VARCHAR(255) NULL,
CONSTRAINT mucMember__pk PRIMARY KEY (roomID,jid)
);
CREATE TABLE mucConversationLog (
roomID INTEGER NOT NULL,
sender TEXT NOT NULL,
nickname VARCHAR(255) NULL,
time CHAR(15) NOT NULL,
subject VARCHAR(255) NULL,
body TEXT NULL
);
-- Unique ID entry for mucRoom
INSERT INTO jiveID (idType, id) VALUES (23, 1); | true |
8825c46bc740fcd1f6def03043dc764e3c7e58ab | SQL | joakimjocka/student-management-system | /Kong Jie SQL project/DATABASE FILES/student_management/Queries/Majors and its courses.sql | UTF-8 | 122 | 2.6875 | 3 | [] | no_license | select majors_info.Major_name,course_info.Course_name
from majors_info,course_info
where course_info.MID=majors_info.MID | true |
2cd2d3604c899e82420471d04d8df66f6177176d | SQL | KM-96/CSCI-585-Database-Systems-Homeworks | /Homework2/Q4_V1.sql | UTF-8 | 1,088 | 3.6875 | 4 | [] | no_license | /*
* Used live SQL to run the following commands
* https://livesql.oracle.com/apex/f?p=590%3A1000%3A0
* Database: Oracle: Version 19.5.0.0.0
*/
/*
* I have written two different queries that do the same job of deleting the names that have 'NULL' for SameFam and another family member in the db.
*/
CREATE TABLE JUNK_EMAIL (
NAME VARCHAR2(10),
ADDRESS VARCHAR2(20),
ID INT,
SAMEFAM INT
);
INSERT INTO JUNK_EMAIL VALUES('Alice', 'A', 10, NULL);
INSERT INTO JUNK_EMAIL VALUES('Bob', 'B', 15, NULL);
INSERT INTO JUNK_EMAIL VALUES('Carmen', 'C', 22, NULL);
INSERT INTO JUNK_EMAIL VALUES('Diego', 'A', 9, 10);
INSERT INTO JUNK_EMAIL VALUES('Ella', 'B', 3, 15);
INSERT INTO JUNK_EMAIL VALUES('Farkhad', 'D', 11, NULL);
DELETE FROM JUNK_EMAIL WHERE ID IN (
SELECT ID FROM JUNK_EMAIL WHERE SAMEFAM IS NULL
INTERSECT
SELECT SAMEFAM FROM JUNK_EMAIL WHERE SAMEFAM IS NOT NULL
);
/* OR */
/*
DELETE FROM JUNK_EMAIL WHERE ID IN (
SELECT JE1.ID FROM JUNK_EMAIL JE1
INNER JOIN
JUNK_EMAIL JE2 ON JE1.ID = JE2.SAMEFAM
);
*/ | true |
613725d79ac6a6c7ee0dafd2f48c14b4d12c9de3 | SQL | marancibia/oracle-db-examples | /json-relational-duality/DualityViewTutorial.sql | UTF-8 | 24,321 | 3.328125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | /*
** Copyright (c) 2023 Oracle and/or its affiliates
** The Universal Permissive License (UPL), Version 1.0
**
** Subject to the condition set forth below, permission is hereby granted to any
** person obtaining a copy of this software, associated documentation and/or data
** (collectively the "Software"), free of charge and under any and all copyright
** rights in the Software, and any and all patent rights owned or freely
** licensable by each licensor hereunder covering either (i) the unmodified
** Software as contributed to or provided by such licensor, or (ii) the Larger
** Works (as defined below), to deal in both
**
** (a) the Software, and
** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
** one is included with the Software (each a "Larger Work" to which the Software
** is contributed by such licensors),
**
** without restriction, including without limitation the rights to copy, create
** derivative works of, display, perform, and distribute the Software and make,
** use, sell, offer for sale, import, export, have made, and have sold the
** Software and the Larger Work(s), and to sublicense the foregoing rights on
** either these or other terms.
**
** This license is subject to the following condition:
** The above copyright notice and either this complete permission notice or at
** a minimum a reference to the UPL must be included in all copies or
** substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
*/
-- TITLE
-- Working with JSON Relational Duality Views using SQL.
--
-- DESCRIPTION
-- This tutorial script walks you through examples of working with
-- JSON Relational Duality Views using Formula-1 (auto-racing) season data
-- through SQL.
--
-- PREREQUISITES
-- Ensure that you have Oracle database 23c installed and running on a
-- port. Ensure that the compatible parameter is set to 23.0.0.0.
--
-- USAGE
-- Connect to the database as a regular (non-SYS) user and run this
-- script. The user must have create session and resource privileges.
-- A demo user (janus) can be created using this statement:
-- GRANT CTXAPP, CONNECT, RESOURCE, UNLIMITED TABLESPACE, CREATE ANY
-- DIRECTORY, DROP ANY DIRECTORY, DBA TO janus IDENTIFIED BY janus;
--
-- NOTES
-- Oracle Database 23c Free - Developer Release is the first release of
-- the next-generation Oracle Database, allowing developers a head-start
-- on building applications with innovative 23c features that simplify
-- development of modern data-driven apps. The entire feature set of
-- Oracle Database 23c is planned to be generally available within the
-- next 12 months.
--
-- Please go through the duality view documentation
-- (https://docs.oracle.com/en/database/oracle/oracle-database/23/jsnvu/index.html)
-- to learn more about duality views and their advantages.
-- This tutorial is analogous to the REST (Working with JSON Relational
-- Duality Views using REST) and MongoAPI (Working with JSON-Relational
-- Duality Views using Oracle Database API for MongoDB) tutorials.
-- Additional resources:
-- Duality Views blog (posted October 2022): https://blogs.oracle.com/database/post/json-relational-duality-app-dev?source=:so:ch:or:awr::::OCW23cbeta
-- Oracle CloudWorld 2022 keynote - https://www.youtube.com/watch?v=e8-jBkO1NqY&t=17s
SET ECHO ON
SET FEEDBACK 1
SET NUMWIDTH 10
SET LINESIZE 80
SET TRIMSPOOL ON
SET TAB OFF
SET PAGESIZE 100
SET LONG 20000
prompt
prompt ** Working with JSON Relational Duality Views using SQL **
prompt
-- Do cleanup for previous run (if any).
--
drop view if exists team_dv;
drop view if exists race_dv;
drop view if exists driver_dv;
drop table if exists driver_race_map;
drop table if exists race;
drop table if exists driver;
drop table if exists team;
--------------------------------------------------
-- Step 1: Create JSON Relational Duality Views --
--------------------------------------------------
-- Create base tables for the duality views.
--
CREATE TABLE team
(team_id INTEGER GENERATED BY DEFAULT ON NULL AS IDENTITY,
name VARCHAR2(255) NOT NULL UNIQUE,
points INTEGER NOT NULL,
CONSTRAINT team_pk PRIMARY KEY(team_id));
CREATE TABLE driver
(driver_id INTEGER GENERATED BY DEFAULT ON NULL AS IDENTITY,
name VARCHAR2(255) NOT NULL UNIQUE,
points INTEGER NOT NULL,
team_id INTEGER,
CONSTRAINT driver_pk PRIMARY KEY(driver_id),
CONSTRAINT driver_fk FOREIGN KEY(team_id) REFERENCES team(team_id));
CREATE TABLE race
(race_id INTEGER GENERATED BY DEFAULT ON NULL AS IDENTITY,
name VARCHAR2(255) NOT NULL UNIQUE,
laps INTEGER NOT NULL,
race_date DATE,
podium JSON,
CONSTRAINT race_pk PRIMARY KEY(race_id));
CREATE TABLE driver_race_map
(driver_race_map_id INTEGER GENERATED BY DEFAULT ON NULL AS IDENTITY,
race_id INTEGER NOT NULL,
driver_id INTEGER NOT NULL,
position INTEGER,
CONSTRAINT driver_race_map_uk UNIQUE (race_id, driver_id),
CONSTRAINT driver_race_map_pk PRIMARY KEY(driver_race_map_id),
CONSTRAINT driver_race_map_fk1 FOREIGN KEY(race_id) REFERENCES race(race_id),
CONSTRAINT driver_race_map_fk2 FOREIGN KEY(driver_id) REFERENCES driver(driver_id));
-- Create a trigger on the driver_race_map table to populate
-- the points fields in team and driver based on race results.
--
CREATE OR REPLACE TRIGGER driver_race_map_trigger
BEFORE INSERT ON driver_race_map
FOR EACH ROW
DECLARE
v_points INTEGER;
v_team_id INTEGER;
BEGIN
SELECT team_id INTO v_team_id FROM driver WHERE driver_id = :NEW.driver_id;
IF :NEW.position = 1 THEN
v_points := 25;
ELSIF :NEW.position = 2 THEN
v_points := 18;
ELSIF :NEW.position = 3 THEN
v_points := 15;
ELSIF :NEW.position = 4 THEN
v_points := 12;
ELSIF :NEW.position = 5 THEN
v_points := 10;
ELSIF :NEW.position = 6 THEN
v_points := 8;
ELSIF :NEW.position = 7 THEN
v_points := 6;
ELSIF :NEW.position = 8 THEN
v_points := 4;
ELSIF :NEW.position = 9 THEN
v_points := 2;
ELSIF :NEW.position = 10 THEN
v_points := 1;
ELSE
v_points := 0;
END IF;
UPDATE driver SET points = points + v_points
WHERE driver_id = :NEW.driver_id;
UPDATE team SET points = points + v_points
WHERE team_id = v_team_id;
END;
/
-- Create race view, RACE_DV
--
-- Creation using SQL syntax
CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW race_dv AS
SELECT JSON {'raceId' : r.race_id,
'name' : r.name,
'laps' : r.laps WITH NOUPDATE,
'date' : r.race_date,
'podium' : r.podium WITH NOCHECK,
'result' :
[ SELECT JSON {'driverRaceMapId' : drm.driver_race_map_id,
'position' : drm.position,
UNNEST
(SELECT JSON {'driverId' : d.driver_id,
'name' : d.name}
FROM driver d WITH NOINSERT UPDATE NODELETE
WHERE d.driver_id = drm.driver_id)}
FROM driver_race_map drm WITH INSERT UPDATE DELETE
WHERE drm.race_id = r.race_id ]}
FROM race r WITH INSERT UPDATE DELETE;
-- Creation using GraphQL syntax
/*
CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW race_dv AS
race @insert @update @delete
{
raceId : race_id
name : name
laps : laps @noUpdate
date : race_date
podium : podium @noCheck
result : driver_race_map @insert @update @delete
[
{
driverRaceMapId : driver_race_map_id
position : position
driver @noInsert @update @noDelete @unnest
{
driverId : driver_id
name : name
}
}
]
};
*/
-- Create driver view, DRIVER_DV
--
-- Creation using SQL syntax
CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW driver_dv AS
SELECT JSON {'driverId' : d.driver_id,
'name' : d.name,
'points' : d.points,
UNNEST
(SELECT JSON {'teamId' : t.team_id,
'team' : t.name WITH NOCHECK}
FROM team t WITH NOINSERT NOUPDATE NODELETE
WHERE t.team_id = d.team_id),
'race' :
[ SELECT JSON {'driverRaceMapId' : drm.driver_race_map_id,
UNNEST
(SELECT JSON {'raceId' : r.race_id,
'name' : r.name}
FROM race r WITH NOINSERT NOUPDATE NODELETE
WHERE r.race_id = drm.race_id),
'finalPosition' : drm.position}
FROM driver_race_map drm WITH INSERT UPDATE NODELETE
WHERE drm.driver_id = d.driver_id ]}
FROM driver d WITH INSERT UPDATE DELETE;
-- Creation using GraphQL syntax
/*
CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW driver_dv AS
driver @insert @update @delete
{
driverId : driver_id
name : name
points : points
team @noInsert @noUpdate @noDelete @unnest
{
teamId : team_id
team : name @noCheck
}
race : driver_race_map @insert @update @noDelete
[
{
driverRaceMapId : driver_race_map_id
race @noInsert @noUpdate @noDelete @unnest
{
raceId : race_id
name : name
}
finalPosition : position
}
]
};
*/
-- Create team view, TEAM_DV
--
-- Creation using SQL syntax
CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW team_dv AS
SELECT JSON {'teamId' : t.team_id,
'name' : t.name,
'points' : t.points,
'driver' :
[ SELECT JSON {'driverId' : d.driver_id,
'name' : d.name,
'points' : d.points WITH NOCHECK}
FROM driver d WITH INSERT UPDATE
WHERE d.team_id = t.team_id ]}
FROM team t WITH INSERT UPDATE DELETE;
-- Creation using GraphQL syntax
/*
CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW team_dv AS
team @insert @update @delete
{
teamId : team_id
name : name
points : points
driver : driver @insert @update
[
{
driverId : driver_id
name : name
points : points @noCheck
}
]
};
*/
--------------------------------------------------
-- Step 2: List all documents in a duality view --
--------------------------------------------------
SELECT json_serialize(data PRETTY) FROM driver_dv;
SELECT json_serialize(data PRETTY) FROM race_dv;
SELECT json_serialize(data PRETTY) FROM team_dv;
----------------------------------------
-- Step 3: Populate the duality views --
----------------------------------------
-- Insert a collection of team documents into TEAM_DV.
-- This automatically populates the driver and team table as well as the
-- driver collection.
--
INSERT INTO team_dv VALUES ('{"teamId" : 301,
"name" : "Red Bull",
"points" : 0,
"driver" : [ {"driverId" : 101,
"name" : "Max Verstappen",
"points" : 0},
{"driverId" : 102,
"name" : "Sergio Perez",
"points" : 0} ]}');
INSERT INTO team_dv VALUES ('{"teamId" : 302,
"name" : "Ferrari",
"points" : 0,
"driver" : [ {"driverId" : 103,
"name" : "Charles Leclerc",
"points" : 0},
{"driverId" : 104,
"name" : "Carlos Sainz Jr",
"points" : 0} ]}');
INSERT INTO team_dv VALUES ('{"teamId" : 2,
"name" : "Mercedes",
"points" : 0,
"driver" : [ {"driverId" : 105,
"name" : "George Russell",
"points" : 0},
{"driverId" : 106,
"name" : "Lewis Hamilton",
"points" : 0} ]}');
-- Insert a collection of race documents into RACE_DV.
-- This automatically populates the race table.
--
INSERT INTO race_dv VALUES ('{"raceId" : 201,
"name" : "Bahrain Grand Prix",
"laps" : 57,
"date" : "2022-03-20T00:00:00",
"podium" : {}}');
INSERT INTO race_dv VALUES ('{"raceId" : 202,
"name" : "Saudi Arabian Grand Prix",
"laps" : 50,
"date" : "2022-03-27T00:00:00",
"podium" : {}}');
INSERT INTO race_dv VALUES ('{"raceId" : 203,
"name" : "Australian Grand Prix",
"laps" : 58,
"date" : "2022-04-09T00:00:00",
"podium" : {}}');
COMMIT;
----------------------------------------------------------
-- Step 4: See the effects of populating a duality view --
----------------------------------------------------------
-- Populating a duality view automatically updates data shown in related
-- duality views, by updating their underlying tables. For example, in the
-- previous step documents were inserted into the team_dv duality view. This
-- duality view joins the team table with the driver table, so on insert into
-- this duality view both the team table as well as the driver table are
-- populated. If you now list the contents of the driver_dv duality view, which
-- is based on the driver table, it has documents as well.
--
SELECT json_serialize(data PRETTY) FROM driver_dv;
SELECT json_serialize(data PRETTY) FROM race_dv;
----------------------------------------------------------
-- Step 5: Find documents matching a filter (predicate) --
-- with optional projection of fields and sorting --
----------------------------------------------------------
-- Find race info by raceId.
-- You can use JSON functions, such as json_value or json_exists in predicates
-- when querying duality views. You can also use simplified dot notation in
-- predicates (see Step 9 for an example of this). The json_exists function is
-- more powerful than json_value in terms of the conditions it can express and
-- is used by the REST interface to translate QBEs.
--
SELECT json_serialize(data PRETTY)
FROM race_dv WHERE json_value(data, '$.raceId') = 201;
-- Project specific document fields.
-- In SQL, specific documents fields can be requested using the KEEP operator
-- in json_transform (other fields will be excluded in returned document).
-- Alternatively, you can exclude specific fields from the returned documents
-- using the REMOVE operator in json_transform.
SELECT json_serialize(json_transform(data, KEEP '$.name', '$.team') PRETTY)
FROM driver_dv;
-- Sort returned documents by field value.
-- Returned documents can be sorted, using simplified syntax or json_value.
SELECT json_serialize(json_transform(data, KEEP '$.name', '$.team') PRETTY)
FROM driver_dv ORDER BY json_value(data, '$.team');
--------------------------------------
-- Step 6: Replace a document by ID --
--------------------------------------
-- Announce results for the Bahrain Grand Prix.
-- Note that the "etag" value supplied in the content is used for "out-of-
-- the-box" optimistic locking, to prevent the well-known "lost update" problem
-- that can occur with concurrent operations. During the replace by ID
-- operation, the database checks that the eTag provided in the replacement
-- document matches the latest eTag of the target duality view document. If the
-- eTags do not match, which can occur if another concurrent operation updated
-- the same document, an error is thrown. In case of such an error, you can
-- reread the updated value (including the updated eTag), and retry the replace
-- operation again, adjusting it (if desired) based on the updated value.
-- To see that a replace using an eTag that is not the most recent fails, run
-- the same command again.
--
UPDATE race_dv dv
SET data = ('{_metadata : {"etag" : "2E8DC09543DD25DC7D588FB9734D962B"},
"raceId" : 201,
"name" : "Bahrain Grand Prix",
"laps" : 57,
"date" : "2022-03-20T00:00:00",
"podium" :
{"winner" : {"name" : "Charles Leclerc",
"time" : "01:37:33.584"},
"firstRunnerUp" : {"name" : "Carlos Sainz Jr",
"time" : "01:37:39.182"},
"secondRunnerUp" : {"name" : "Lewis Hamilton",
"time" : "01:37:43.259"}},
"result" : [ {"driverRaceMapId" : 3,
"position" : 1,
"driverId" : 103,
"name" : "Charles Leclerc"},
{"driverRaceMapId" : 4,
"position" : 2,
"driverId" : 104,
"name" : "Carlos Sainz Jr"},
{"driverRaceMapId" : 9,
"position" : 3,
"driverId" : 106,
"name" : "Lewis Hamilton"},
{"driverRaceMapId" : 10,
"position" : 4,
"driverId" : 105,
"name" : "George Russell"} ]}')
WHERE dv.data.raceId = 201;
COMMIT;
-- See the results for the Bahrain Grand Prix.
-- You can use a predicate on the primary key field to query by ID.
--
SELECT json_serialize(data PRETTY)
FROM race_dv dv WHERE dv.data.raceId = 201;
------------------------------------------------------------------------------
-- Step 7: Update specific fields in the document identified by a predicate --
------------------------------------------------------------------------------
-- Update Bahrain GP name with sponsor information.
-- Here we use json_transform to update specific fields. An alternative
-- approach is to use json_mergepatch, which is standardized (RFC 7386), but is
-- limited to simple object field updates and cannot be used for updating
-- specific array elements. The json_transform function, however, can be used
-- to update specific array elements. Note that the "where" clause can have any
-- valid SQL expression, e.g. equality on primary key, some condition using
-- simplified syntax, or JSON function, such as json_value or json_exists.
--
UPDATE race_dv dv
SET data = json_transform(data, SET '$.name' = 'Blue Air Bahrain Grand Prix')
WHERE dv.data.name LIKE 'Bahrain%';
COMMIT;
SELECT json_serialize(data PRETTY)
FROM race_dv WHERE json_value(data, '$.name') LIKE 'Blue Air Bahrain%';
-- Update Bahrain GP name with sponsor information.
-- Here we use json_mergepatch instead of json_transform to perform the same
-- operation. We also use json_exists in the predicate.
--
UPDATE race_dv dv
SET data = json_mergepatch(data, '{"name" : "Blue Air Bahrain Grand Prix"}')
WHERE dv.data.name LIKE 'Blue Air Bahrain%';
COMMIT;
SELECT json_serialize(data PRETTY)
FROM race_dv WHERE json_value(data, '$.name') LIKE 'Blue Air Bahrain%';
---------------------------------------------------------------
-- Step 8: Re-parenting of sub-objects between two documents --
---------------------------------------------------------------
-- Switch Charles Leclerc's and George Russell's teams.
-- This can be done by updating the Mercedes and Ferrari team_dvs. The
-- documents can be updated by simply sending the new list of drivers for both
-- documents in the input.
-- First, show the team documents.
--
SELECT json_serialize(data PRETTY) FROM team_dv dv
WHERE dv.data.name LIKE 'Mercedes%';
SELECT json_serialize(data PRETTY) FROM team_dv dv
WHERE dv.data.name LIKE 'Ferrari%';
-- Then perform the updates.
--
UPDATE team_dv dv
SET data = ('{_metadata : {"etag" : "855840B905C8CAFA99FB9CBF813992E5"},
"teamId" : 2,
"name" : "Mercedes",
"points" : 40,
"driver" : [ {"driverId" : 106,
"name" : "Lewis Hamilton",
"points" : 15},
{"driverId" : 103,
"name" : "Charles Leclerc",
"points" : 25} ]}')
WHERE dv.data.name LIKE 'Mercedes%';
UPDATE team_dv dv
SET data = ('{_metadata : {"etag" : "DA69DD103E8BAE95A0C09811B7EC9628"},
"teamId" : 302,
"name" : "Ferrari",
"points" : 30,
"driver" : [ {"driverId" : 105,
"name" : "George Russell",
"points" : 12},
{"driverId" : 104,
"name" : "Carlos Sainz Jr",
"points" : 18} ]}')
WHERE dv.data.name LIKE 'Ferrari%';
COMMIT;
-- Then show the team documents after the updates:
--
SELECT json_serialize(data PRETTY) FROM team_dv dv
WHERE dv.data.name LIKE 'Mercedes%';
SELECT json_serialize(data PRETTY) FROM team_dv dv
WHERE dv.data.name LIKE 'Ferrari%';
-- Then show the driver documents after the updates:
--
SELECT json_serialize(data PRETTY) FROM driver_dv dv
WHERE dv.data.name LIKE 'Charles Leclerc%';
SELECT json_serialize(data PRETTY) FROM driver_dv dv
WHERE dv.data.name LIKE 'George Russell%';
-------------------------------------------
-- Step 9: Update a non-updateable field --
-------------------------------------------
-- Update team for a driver through driver_dv.
-- This will throw an error.
--
UPDATE driver_dv dv
SET DATA = ('{_metadata : {"etag" : "FCD4CEC63897F60DEA1EC2F64D3CE53A"},
"driverId" : 103,
"name" : "Charles Leclerc",
"points" : 25,
"teamId" : 2,
"team" : "Ferrari",
"race" :
[
{
"driverRaceMapId" : 3,
"raceId" : 201,
"name" : "Blue Air Bahrain Grand Prix",
"finalPosition" : 1
}
]
}')
WHERE dv.data.driverId = 103;
----------------------------------
-- Step 10: Delete by predicate --
----------------------------------
-- Delete the race document for Bahrain GP.
-- The underlying rows are deleted from the race and driver_race_map
-- tables, but not from the driver table because it is marked read-only
-- in the view definition. Note that the "where" clause can have any
-- valid SQL expression, e.g. equality on primary key, some condition using
-- simplified syntax, or JSON function, such as json_value or json_exists.
--
DELETE FROM race_dv dv WHERE dv.data.raceId = 201;
SELECT json_serialize(data PRETTY) FROM race_dv;
SELECT json_serialize(data PRETTY) FROM driver_dv;
COMMIT;
| true |
346100d158b5f5c40a0819c38e43571beac9cf88 | SQL | Bones02/workout-server | /migrations/002.do.create_workouts.sql | UTF-8 | 313 | 2.75 | 3 | [] | no_license | CREATE TABLE workouts (
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
typeId INTEGER REFERENCES types(id) ON DELETE CASCADE NOT NULL,
name TEXT NOT NULL,
modified TIMESTAMP NOT NULL DEFAULT now(),
description TEXT NOT NULL,
calories TEXT NOT NULL,
minutes TEXT NOT NULL
); | true |
e849d9d123e4acacfa0db5e5b34120ca2f3438fd | SQL | nikwalia/schedule-generator | /db/top_class_frequency_procedure.sql | UTF-8 | 464 | 3.78125 | 4 | [
"MIT"
] | permissive | CREATE PROCEDURE GetTopClassFrequency (
IN course_id VARCHAR(10),
OUT best_semester INT
)
BEGIN
IF NOT EXISTS(SELECT c.course_id FROM student_info.courses c WHERE c.course_id = course_id) THEN
SET best_semester = -1;
ELSE
SELECT e.semester_taken
INTO best_semester
FROM student_info.enrollments e
WHERE e.course_id = course_id
GROUP BY e.semester_taken
HAVING COUNT(e.net_id) = MAX(COUNT(e.net_id));
END IF;
END
| true |
2ecbb403a9b37bd3e4326f77964e0aa65d95c02b | SQL | t3mp0ralflux/CSC455 | /assignment 2/insert_data_assign2.sql | UTF-8 | 3,541 | 2.78125 | 3 | [] | no_license | delete from odetails;
delete from parts;
delete from orders;
delete from customers;
delete from employees;
delete from zipcodes;
insert into zipcodes values ('67226', 'Wichita');
insert into zipcodes values ('60606', 'Fort Dodge');
insert into zipcodes values ('50302', 'Kansas City');
insert into zipcodes values ('54444', 'Columbia');
insert into zipcodes values ('66002', 'Liberal');
insert into zipcodes values ('61111', 'Fort Hays');
insert into zipcodes values ('28411', 'Wilmington');
insert into zipcodes values ('28408', 'Wilmington');
insert into employees values ('1000', 'Jones', '67226', '1995-12-12');
insert into employees values ('1001', 'Smith', '60606', '1992-01-01');
insert into employees values ('1002', 'Brown', '50302', '1994-09-01');
insert into employees values ('1003', 'Green', '28411', '2002-09-01');
insert into employees values ('1004', 'Purple', '28411', '2003-01-01');
insert into customers values ('1111', 'Charles', '123 Main St.', '67226', '316-636-5555');
insert into customers values ('2222', 'Bertram', '237 Ash Avenue', '67226', '316-689-5555');
insert into customers values ('3333', 'Barbara', '111 Inwood St.', '60606', '316-111-1234');
insert into customers values ('4444', 'Will', '111 Kenwood St.', '54444', '416-111-1234');
insert into customers values ('5555', 'Bill', '211 Marlwood St.', '28408', '416-111-1235');
insert into customers values ('6666', 'Keely', '211 Pinewood St.', '28411', '416-111-1235');
insert into customers values ('7777', 'Maera', '211 Marlwood St.', '28408', '416-111-1235');
insert into orders values ('1020', '1111', '1000', '1994-12-10', '1994-12-12');
insert into orders values ('1021', '1111', '1000', '1995-01-12', '1995-01-15');
insert into orders values ('1022', '2222', '1001', '1995-02-13', '1995-02-20');
insert into orders values ('1023', '3333', '1000', '2003-02-15', NULL);
insert into orders values ('1024', '4444', '1000', '2003-02-15', '2003-02-16');
insert into orders values ('1025', '5555', '1000', '2003-02-15', '2003-02-16');
insert into parts values ('10506', 'Land Before Time I', '200', '19.99', '20');
insert into parts values ('10507', 'Land Before Time II', '156', '19.99', '20');
insert into parts values ('10508', 'Land Before Time III', '190', '19.99', '20');
insert into parts values ('10509', 'Land Before Time IV', '60', '19.99', '20');
insert into parts values ('10601', 'Sleeping Beauty', '300', '24.99', '20');
insert into parts values ('10701', 'When Harry Met Sally', '120', '19.99', '30');
insert into parts values ('10800', 'Dirty Harry', '140', '14.99', '30');
insert into parts values ('10900', 'Dr. Zhivago', '100', '24.99', '30');
insert into parts values ('10901', 'A Star is Born', '100', '4.99', '30');
insert into parts values ('10902', 'Star Wars', '500', '24.99', '30');
insert into parts values ('10903', 'Lord of the Rings', '100', '34.99', '30');
insert into odetails values ('1020', '10506', '1');
insert into odetails values ('1020', '10800', '1');
insert into odetails values ('1020', '10508', '2');
insert into odetails values ('1020', '10509', '3');
insert into odetails values ('1021', '10601', '4');
insert into odetails values ('1021', '10506', '7');
insert into odetails values ('1022', '10601', '1');
insert into odetails values ('1022', '10701', '1');
insert into odetails values ('1023', '10800', '1');
insert into odetails values ('1023', '10900', '1');
insert into odetails values ('1023', '10506', '2');
insert into odetails values ('1024', '10506', '12');
insert into odetails values ('1025', '10601', '2'); | true |
a52768e4502bc5f2388bd72654814389b2e69ef9 | SQL | Hammam94/HRprogram | /src/com/company/Back_End/database/interviews.sql | UTF-8 | 166 | 2.578125 | 3 | [] | no_license | CREATE TABLE IF NOT EXISTS interviews (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name TEXT NOT NULL,
date_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) | true |
046f638aeacd5bbe59c285677a89f437b56e04e8 | SQL | rashmivi001/Banking-Application-using-Springboot | /OnlineBankingAppDump.sql | UTF-8 | 4,526 | 3.125 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 8.0.15, for Win64 (x86_64)
--
-- Host: localhost Database: mydb
-- ------------------------------------------------------
-- 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 utf8 ;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `admin1`
--
DROP TABLE IF EXISTS `admin1`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `admin1` (
`username` varchar(50) NOT NULL,
`password` varchar(50) DEFAULT NULL,
PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `admin1`
--
LOCK TABLES `admin1` WRITE;
/*!40000 ALTER TABLE `admin1` DISABLE KEYS */;
INSERT INTO `admin1` VALUES ('admin','test'),('ram','test1'),('rash','test');
/*!40000 ALTER TABLE `admin1` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `recipient`
--
DROP TABLE IF EXISTS `recipient`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `recipient` (
`userID` int(11) DEFAULT NULL,
`recID` int(11) NOT NULL AUTO_INCREMENT,
`firstName` varchar(50) DEFAULT NULL,
`lastName` varchar(50) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`phoneNumber` varchar(50) DEFAULT NULL,
`accType` varchar(50) DEFAULT NULL,
`accNumber` varchar(50) DEFAULT NULL,
PRIMARY KEY (`recID`),
KEY `userID` (`userID`),
CONSTRAINT `recipient_ibfk_1` FOREIGN KEY (`userID`) REFERENCES `userdb` (`userID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `recipient`
--
LOCK TABLES `recipient` WRITE;
/*!40000 ALTER TABLE `recipient` DISABLE KEYS */;
INSERT INTO `recipient` VALUES (1,2,'ramya','lramya','ram@gmail.com','9147856','Current','165423'),(3,3,'rashmi','vishwanath','rash@gmail.com','9145623','Current','1555550'),(4,5,'wert','wert','werty@g.co','84512','Savings','852741');
/*!40000 ALTER TABLE `recipient` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `userdb`
--
DROP TABLE IF EXISTS `userdb`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `userdb` (
`userID` int(11) NOT NULL AUTO_INCREMENT,
`userName` varchar(50) NOT NULL,
`password` varchar(50) DEFAULT NULL,
`firstName` varchar(50) DEFAULT NULL,
`lastName` varchar(50) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`phoneNumber` varchar(50) DEFAULT NULL,
`SBAccount` int(11) DEFAULT NULL,
`CAccount` int(11) DEFAULT NULL,
`SBAccBalance` int(11) DEFAULT NULL,
`CAccBalance` int(11) DEFAULT NULL,
PRIMARY KEY (`userID`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `userdb`
--
LOCK TABLES `userdb` WRITE;
/*!40000 ALTER TABLE `userdb` DISABLE KEYS */;
INSERT INTO `userdb` VALUES (1,'channa','chan','fchan','lchan','chan@g.co','9145263',2,2,5000,0),(2,'sdfg','dfg','dfg','werth','fgh@g.com','74185',3,3,0,0),(3,'nandini','nand','firstnandu','lastnandu','nandu@gmail.com','9145263',5,4,0,4501),(4,'sample','sample','firstname','lastname','email@gmail.com','9145862',6,5,480,460);
/*!40000 ALTER TABLE `userdb` 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 2019-04-21 14:15:31
| true |
dbc59df5854c1d1c8d8ccdba8243a607d3eec689 | SQL | woakes070048/Hefest | /scripts/database_create.sql | UTF-8 | 26,491 | 3.15625 | 3 | [] | no_license | DROP SCHEMA IF EXISTS professionals CASCADE;
CREATE SCHEMA professionals;
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS plpython3u;
CREATE TABLE professionals.PersistentTokens (
Series VARCHAR NOT NULL,
Value VARCHAR NOT NULL,
Email VARCHAR NOT NULL,
Date DATE NOT NULL,
IpAddress VARCHAR,
UserAgent VARCHAR NOT NULL,
CONSTRAINT series PRIMARY KEY (Series)
);
CREATE SEQUENCE professionals.items_itemid_seq;
CREATE TABLE professionals.Items (
ItemId INTEGER NOT NULL DEFAULT nextval('professionals.items_itemid_seq'),
CategoryType VARCHAR,
Name VARCHAR NOT NULL,
FullName VARCHAR NOT NULL,
CONSTRAINT itemid PRIMARY KEY (ItemId)
);
ALTER SEQUENCE professionals.items_itemid_seq OWNED BY professionals.Items.ItemId;
CREATE SEQUENCE professionals.tags_tagid_seq;
CREATE TABLE professionals.Tags (
TagId INTEGER NOT NULL DEFAULT nextval('professionals.tags_tagid_seq'),
TagName VARCHAR NOT NULL,
TagLabel VARCHAR NOT NULL,
CONSTRAINT tagid PRIMARY KEY (TagId)
);
ALTER SEQUENCE professionals.tags_tagid_seq OWNED BY professionals.Tags.TagId;
CREATE TABLE professionals.TagsForItems (
TagId INTEGER NOT NULL,
ItemId INTEGER NOT NULL,
CONSTRAINT tagforitemid PRIMARY KEY (TagId, ItemId)
);
CREATE SEQUENCE professionals.professions_professionid_seq;
CREATE TABLE professionals.Professions (
ProfessionId INTEGER NOT NULL DEFAULT nextval('professionals.professions_professionid_seq'),
ItemId INTEGER NOT NULL,
CONSTRAINT professionid PRIMARY KEY (ProfessionId)
);
ALTER SEQUENCE professionals.professions_professionid_seq OWNED BY professionals.Professions.ProfessionId;
CREATE SEQUENCE professionals.servicecategories_servicecategoryid_seq;
CREATE TABLE professionals.ServiceCategories (
ServiceCategoryId INTEGER NOT NULL DEFAULT nextval('professionals.servicecategories_servicecategoryid_seq'),
ItemId INTEGER NOT NULL,
ProfessionId INTEGER NOT NULL,
CONSTRAINT servicecategoryid PRIMARY KEY (ServiceCategoryId)
);
ALTER SEQUENCE professionals.servicecategories_servicecategoryid_seq OWNED BY professionals.ServiceCategories.ServiceCategoryId;
CREATE SEQUENCE professionals.services_serviceid_seq;
CREATE TABLE professionals.Services (
ServiceId INTEGER NOT NULL DEFAULT nextval('professionals.services_serviceid_seq'),
ItemId INTEGER NOT NULL,
ServiceCategoryId INTEGER NOT NULL,
CONSTRAINT serviceid PRIMARY KEY (ServiceId)
);
COMMENT ON TABLE professionals.Services IS 'Usluge';
ALTER SEQUENCE professionals.services_serviceid_seq OWNED BY professionals.Services.ServiceId;
CREATE SEQUENCE professionals.counties_countyid_seq;
CREATE TABLE professionals.Counties (
CountyId INTEGER NOT NULL DEFAULT nextval('professionals.counties_countyid_seq'),
Name VARCHAR NOT NULL,
Path VARCHAR,
CONSTRAINT countyid PRIMARY KEY (CountyId)
);
ALTER SEQUENCE professionals.counties_countyid_seq OWNED BY professionals.Counties.CountyId;
CREATE SEQUENCE professionals.districts_districtid_seq;
CREATE TABLE professionals.Districts (
DistrictId INTEGER NOT NULL DEFAULT nextval('professionals.districts_districtid_seq'),
Name VARCHAR NOT NULL,
Path VARCHAR NOT NULL,
CountyId INTEGER NOT NULL,
CONSTRAINT districtid PRIMARY KEY (DistrictId)
);
ALTER SEQUENCE professionals.districts_districtid_seq OWNED BY professionals.Districts.DistrictId;
CREATE SEQUENCE professionals.localities_localityid_seq;
CREATE TABLE professionals.Localities (
LocalityId INTEGER NOT NULL DEFAULT nextval('professionals.localities_localityid_seq'),
Name VARCHAR NOT NULL,
PostalCode INTEGER,
DistrictId INTEGER NOT NULL,
CountyId INTEGER NOT NULL,
Path VARCHAR NOT NULL,
CONSTRAINT localityid PRIMARY KEY (LocalityId)
);
ALTER SEQUENCE professionals.localities_localityid_seq OWNED BY professionals.Localities.LocalityId;
CREATE SEQUENCE professionals.addresses_addressid_seq;
CREATE TABLE professionals.Addresses (
AddressId INTEGER NOT NULL DEFAULT nextval('professionals.addresses_addressid_seq'),
Lat DOUBLE PRECISION,
Long DOUBLE PRECISION,
LatLong GEOMETRY,
AddressLine VARCHAR,
County VARCHAR,
District VARCHAR,
LocalityId INTEGER,
CONSTRAINT address_id PRIMARY KEY (AddressId)
);
ALTER SEQUENCE professionals.addresses_addressid_seq OWNED BY professionals.Addresses.AddressId;
CREATE SEQUENCE professionals.users_userid_seq;
CREATE TABLE professionals.Users (
UserId INTEGER NOT NULL DEFAULT nextval('professionals.users_userid_seq'),
Name VARCHAR(100) NOT NULL,
Password VARCHAR NOT NULL,
Email VARCHAR(255),
AddressId INTEGER NOT NULL,
BackgroundImage VARCHAR,
LeadImage VARCHAR,
Telephone VARCHAR,
Mobile VARCHAR,
Role VARCHAR NOT NULL,
ActivationKey VARCHAR,
Active BOOLEAN DEFAULT false NOT NULL,
ResetPasswordToken VARCHAR,
ResetPasswordTokenDate DATE,
CONSTRAINT userid PRIMARY KEY (UserId)
);
COMMENT ON COLUMN professionals.Users.LeadImage IS 'The path to the lead image for a professional, that is stored on the file system of the server.';
ALTER SEQUENCE professionals.users_userid_seq OWNED BY professionals.Users.UserId;
CREATE UNIQUE INDEX email_idx
ON professionals.Users
( Email );
CREATE SEQUENCE professionals.professionals_professionalid_seq;
CREATE TABLE professionals.Professionals (
ProfessionalId INTEGER NOT NULL DEFAULT nextval('professionals.professionals_professionalid_seq'),
UserId INTEGER NOT NULL,
OwnerName VARCHAR,
Logo VARCHAR,
Professions VARCHAR,
PageTitle VARCHAR(65),
PageUrl VARCHAR(80),
MetaDescription VARCHAR(160),
ProfileHeadline VARCHAR,
ProfileSubHeadline VARCHAR,
ProfileMoneyShot VARCHAR,
FeaturesHeadline VARCHAR,
FeaturesSubHeadline VARCHAR,
EmployeeCount INTEGER,
Score INTEGER DEFAULT 0 NOT NULL,
YearEstablished INTEGER,
ContactEmail VARCHAR,
Fax VARCHAR,
Website VARCHAR,
ProjectCount INTEGER DEFAULT 0 NOT NULL,
EndorsementCount INTEGER DEFAULT 0 NOT NULL,
Description VARCHAR,
ReviewCount INTEGER DEFAULT 0 NOT NULL,
AvgReview DOUBLE PRECISION DEFAULT 0 NOT NULL,
Verified BOOLEAN DEFAULT false NOT NULL,
SignupDate DATE,
AcceptsCreditCards BOOLEAN,
CONSTRAINT professionalid PRIMARY KEY (ProfessionalId)
);
COMMENT ON COLUMN professionals.Professionals.Logo IS 'Url to logo';
COMMENT ON COLUMN professionals.Professionals.PageTitle IS 'The text that will appear in the browser''s title. Important for SEO reasons and usability.';
COMMENT ON COLUMN professionals.Professionals.PageUrl IS 'User friendly professionals'' profile URL. Important for usability, link sharing and SEO.';
COMMENT ON COLUMN professionals.Professionals.MetaDescription IS 'Meta description for search engines. ';
COMMENT ON COLUMN professionals.Professionals.Score IS 'Score for a proffesional, calculated from several variables, refreshed on change of any variable.';
COMMENT ON COLUMN professionals.Professionals.ProjectCount IS 'Number of projects registered on the platform.';
COMMENT ON COLUMN professionals.Professionals.Description IS 'The popular "About" description.';
COMMENT ON COLUMN professionals.Professionals.ReviewCount IS 'Number of reviews registered on the platform for this professional.';
COMMENT ON COLUMN professionals.Professionals.AvgReview IS 'Average review for a professional.';
COMMENT ON COLUMN professionals.Professionals.Verified IS 'Has the information for this professional been verified.';
ALTER SEQUENCE professionals.professionals_professionalid_seq OWNED BY professionals.Professionals.ProfessionalId;
CREATE UNIQUE INDEX professionals_idx
ON professionals.Professionals
( UserId );
CREATE SEQUENCE professionals.endorsements_endorsementid_seq;
CREATE TABLE professionals.Endorsements (
EndorsementId INTEGER NOT NULL DEFAULT nextval('professionals.endorsements_endorsementid_seq'),
UserId INTEGER NOT NULL,
ProfessionalId INTEGER NOT NULL,
ProfessionId INTEGER NOT NULL,
CONSTRAINT endorsementid PRIMARY KEY (EndorsementId)
);
ALTER SEQUENCE professionals.endorsements_endorsementid_seq OWNED BY professionals.Endorsements.EndorsementId;
CREATE SEQUENCE professionals.features_featureid_seq;
CREATE TABLE professionals.Features (
FeatureId INTEGER NOT NULL DEFAULT nextval('professionals.features_featureid_seq'),
ProfessionalId INTEGER NOT NULL,
Icon VARCHAR NOT NULL,
Headline VARCHAR NOT NULL,
Description VARCHAR NOT NULL,
CONSTRAINT featureid PRIMARY KEY (FeatureId)
);
COMMENT ON COLUMN professionals.Features.Icon IS 'Class of icon next to a feature';
ALTER SEQUENCE professionals.features_featureid_seq OWNED BY professionals.Features.FeatureId;
CREATE SEQUENCE professionals.imagesforprofessionals_imageid_seq;
CREATE TABLE professionals.ImagesForProfessionals (
ImageId INTEGER NOT NULL DEFAULT nextval('professionals.imagesforprofessionals_imageid_seq'),
ProfessionalId INTEGER NOT NULL,
Path VARCHAR NOT NULL,
Description VARCHAR,
CONSTRAINT imageid PRIMARY KEY (ImageId)
);
ALTER SEQUENCE professionals.imagesforprofessionals_imageid_seq OWNED BY professionals.ImagesForProfessionals.ImageId;
CREATE SEQUENCE professionals.projects_projectid_seq;
CREATE TABLE professionals.Projects (
ProjectId INTEGER NOT NULL DEFAULT nextval('professionals.projects_projectid_seq'),
ProfessionalId INTEGER NOT NULL,
UserId INTEGER,
AddressId INTEGER,
Name VARCHAR NOT NULL,
LeadImage VARCHAR,
ImageCount INTEGER DEFAULT 0 NOT NULL,
Description VARCHAR,
Cost INTEGER NOT NULL,
Currency VARCHAR,
DateStarted DATE,
DatePerformed DATE,
ProjectDuration INTEGER,
LikesCount INTEGER DEFAULT 0 NOT NULL,
CommentCount INTEGER DEFAULT 0 NOT NULL,
MetaDescription VARCHAR(160) NOT NULL,
PageUrl VARCHAR(80) NOT NULL,
PageTitle VARCHAR(65) NOT NULL,
CONSTRAINT projectid PRIMARY KEY (ProjectId)
);
COMMENT ON COLUMN professionals.Projects.Currency IS '€,Kn,$,KM';
COMMENT ON COLUMN professionals.Projects.ProjectDuration IS 'In days';
COMMENT ON COLUMN professionals.Projects.MetaDescription IS 'Meta description for search engines. ';
COMMENT ON COLUMN professionals.Projects.PageUrl IS 'User friendly professionals'' profile URL. Important for usability, link sharing and SEO.';
COMMENT ON COLUMN professionals.Projects.PageTitle IS 'The text that will appear in the browser''s title. Important for SEO reasons and usability.';
ALTER SEQUENCE professionals.projects_projectid_seq OWNED BY professionals.Projects.ProjectId;
CREATE TABLE professionals.ImagesForProjects (
ProjectImageId INTEGER NOT NULL,
ProjectId INTEGER NOT NULL,
Path VARCHAR NOT NULL,
ProjectStage VARCHAR,
Description VARCHAR,
CONSTRAINT projectimageid PRIMARY KEY (ProjectImageId)
);
COMMENT ON COLUMN professionals.ImagesForProjects.ProjectStage IS 'Before/After';
CREATE TABLE professionals.ItemsForProjects (
ProjectId INTEGER NOT NULL,
ItemId INTEGER NOT NULL,
ServiceCost DOUBLE PRECISION,
CostUnit VARCHAR,
Description VARCHAR,
CONSTRAINT itemforprojectid PRIMARY KEY (ProjectId, ItemId)
);
CREATE SEQUENCE professionals.testimonials_testimonialid_seq;
CREATE TABLE professionals.Testimonials (
TestimonialId INTEGER NOT NULL DEFAULT nextval('professionals.testimonials_testimonialid_seq'),
ProfessionalId INTEGER NOT NULL,
ImagePath VARCHAR,
Text VARCHAR NOT NULL,
Summary VARCHAR NOT NULL,
PersonName VARCHAR NOT NULL,
PersonCompany VARCHAR,
ProjectId INTEGER,
Date DATE,
OwnersReply VARCHAR,
ReplyDate DATE,
IsSelected BOOLEAN NOT NULL,
CONSTRAINT testimonialid PRIMARY KEY (TestimonialId)
);
COMMENT ON COLUMN professionals.Testimonials.OwnersReply IS 'The reply of the professional who did the job';
COMMENT ON COLUMN professionals.Testimonials.IsSelected IS 'Selected testimonials appear at prominent places in the user interface of the application.';
ALTER SEQUENCE professionals.testimonials_testimonialid_seq OWNED BY professionals.Testimonials.TestimonialId;
CREATE SEQUENCE professionals.professionalsforcounties_countyid_seq;
CREATE TABLE professionals.ProfessionalsForCounties (
ProfessionalId INTEGER NOT NULL,
CountyId INTEGER NOT NULL DEFAULT nextval('professionals.professionalsforcounties_countyid_seq'),
CONSTRAINT professionalforcountyid PRIMARY KEY (ProfessionalId, CountyId)
);
COMMENT ON TABLE professionals.ProfessionalsForCounties IS 'Connects professionals to counties they provide services in.';
ALTER SEQUENCE professionals.professionalsforcounties_countyid_seq OWNED BY professionals.ProfessionalsForCounties.CountyId;
CREATE SEQUENCE professionals.itemsforprofessionals_professionalid_seq;
CREATE SEQUENCE professionals.itemsforprofessionals_itemid_seq;
CREATE TABLE professionals.ItemsForProfessionals (
ProfessionalId INTEGER NOT NULL DEFAULT nextval('professionals.itemsforprofessionals_professionalid_seq'),
ItemId INTEGER NOT NULL DEFAULT nextval('professionals.itemsforprofessionals_itemid_seq'),
ProfessionalDescription VARCHAR,
CONSTRAINT itemsforprofessionalsid PRIMARY KEY (ProfessionalId, ItemId)
);
ALTER SEQUENCE professionals.itemsforprofessionals_professionalid_seq OWNED BY professionals.ItemsForProfessionals.ProfessionalId;
ALTER SEQUENCE professionals.itemsforprofessionals_itemid_seq OWNED BY professionals.ItemsForProfessionals.ItemId;
CREATE SEQUENCE professionals.employees_employeeid_seq;
CREATE TABLE professionals.Employees (
EmployeeId INTEGER NOT NULL DEFAULT nextval('professionals.employees_employeeid_seq'),
ProfessionalId INTEGER NOT NULL,
Name VARCHAR NOT NULL,
Image VARCHAR,
Title VARCHAR,
Role VARCHAR,
CONSTRAINT employeeid PRIMARY KEY (EmployeeId)
);
COMMENT ON TABLE professionals.Employees IS 'Employee of a professional.';
ALTER SEQUENCE professionals.employees_employeeid_seq OWNED BY professionals.Employees.EmployeeId;
CREATE TABLE professionals.CommentsForProjects (
CommentId INTEGER NOT NULL,
ProjectId INTEGER NOT NULL,
UserId INTEGER NOT NULL,
Timestamp TIME NOT NULL,
Content VARCHAR NOT NULL,
CONSTRAINT commentid PRIMARY KEY (CommentId)
);
CREATE SEQUENCE professionals.properties_propertyid_seq;
CREATE TABLE professionals.Properties (
PropertyId INTEGER NOT NULL DEFAULT nextval('professionals.properties_propertyid_seq'),
PropertyType VARCHAR NOT NULL,
Address INTEGER NOT NULL,
UserId INTEGER NOT NULL,
Size DOUBLE PRECISION NOT NULL,
YearBuilt INTEGER NOT NULL,
YearRenovated INTEGER NOT NULL,
EnergyCertificate VARCHAR NOT NULL,
Summary VARCHAR NOT NULL,
Description VARCHAR NOT NULL,
LeadImage VARCHAR NOT NULL,
Permits VARCHAR NOT NULL,
Images VARCHAR NOT NULL,
GroundPlan VARCHAR NOT NULL,
CONSTRAINT propertyid PRIMARY KEY (PropertyId)
);
COMMENT ON COLUMN professionals.Properties.Permits IS 'Vlasnički list, Građevinska, Uporabna';
COMMENT ON COLUMN professionals.Properties.Images IS 'List of image URLs. Best practice for images is to store them on the file system.';
COMMENT ON COLUMN professionals.Properties.GroundPlan IS 'Stored on file sytem as image';
ALTER SEQUENCE professionals.properties_propertyid_seq OWNED BY professionals.Properties.PropertyId;
ALTER TABLE professionals.Services ADD CONSTRAINT items_services_fk
FOREIGN KEY (ItemId)
REFERENCES professionals.Items (ItemId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.ServiceCategories ADD CONSTRAINT items_servicecategory_fk
FOREIGN KEY (ItemId)
REFERENCES professionals.Items (ItemId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.TagsForItems ADD CONSTRAINT items_tagsforitems_fk
FOREIGN KEY (ItemId)
REFERENCES professionals.Items (ItemId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.ItemsForProfessionals ADD CONSTRAINT items_itemsforprofessionals_fk
FOREIGN KEY (ItemId)
REFERENCES professionals.Items (ItemId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.ItemsForProjects ADD CONSTRAINT items_itemsforprojects_fk
FOREIGN KEY (ItemId)
REFERENCES professionals.Items (ItemId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Professions ADD CONSTRAINT items_professions_fk
FOREIGN KEY (ItemId)
REFERENCES professionals.Items (ItemId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.TagsForItems ADD CONSTRAINT tags_tagsforitems_fk
FOREIGN KEY (TagId)
REFERENCES professionals.Tags (TagId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.ServiceCategories ADD CONSTRAINT professions_servicecategory_fk
FOREIGN KEY (ProfessionId)
REFERENCES professionals.Professions (ProfessionId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Endorsements ADD CONSTRAINT professions_endorsements_fk
FOREIGN KEY (ProfessionId)
REFERENCES professionals.Professions (ProfessionId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Services ADD CONSTRAINT servicecategory_services_fk
FOREIGN KEY (ServiceCategoryId)
REFERENCES professionals.ServiceCategories (ServiceCategoryId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Districts ADD CONSTRAINT counties_districts_fk
FOREIGN KEY (CountyId)
REFERENCES professionals.Counties (CountyId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Localities ADD CONSTRAINT counties_localities_fk
FOREIGN KEY (CountyId)
REFERENCES professionals.Counties (CountyId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.ProfessionalsForCounties ADD CONSTRAINT counties_professionalsforcounties_fk
FOREIGN KEY (CountyId)
REFERENCES professionals.Counties (CountyId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Localities ADD CONSTRAINT districts_localities_fk
FOREIGN KEY (DistrictId)
REFERENCES professionals.Districts (DistrictId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Addresses ADD CONSTRAINT localities_addresses_fk
FOREIGN KEY (LocalityId)
REFERENCES professionals.Localities (LocalityId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Properties ADD CONSTRAINT addresses_properties_fk
FOREIGN KEY (Address)
REFERENCES professionals.Addresses (AddressId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Users ADD CONSTRAINT addresses_users_fk
FOREIGN KEY (AddressId)
REFERENCES professionals.Addresses (AddressId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Properties ADD CONSTRAINT users_properties_fk
FOREIGN KEY (UserId)
REFERENCES professionals.Users (UserId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.CommentsForProjects ADD CONSTRAINT users_comments_fk
FOREIGN KEY (UserId)
REFERENCES professionals.Users (UserId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Professionals ADD CONSTRAINT users_professionals_fk
FOREIGN KEY (UserId)
REFERENCES professionals.Users (UserId)
ON DELETE CASCADE
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Projects ADD CONSTRAINT users_projects_fk
FOREIGN KEY (UserId)
REFERENCES professionals.Users (UserId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Endorsements ADD CONSTRAINT users_endorsements_fk
FOREIGN KEY (UserId)
REFERENCES professionals.Users (UserId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Employees ADD CONSTRAINT companies_professionals_fk
FOREIGN KEY (ProfessionalId)
REFERENCES professionals.Professionals (ProfessionalId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.ItemsForProfessionals ADD CONSTRAINT professionals_itemsforprofessionals_fk
FOREIGN KEY (ProfessionalId)
REFERENCES professionals.Professionals (ProfessionalId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.ProfessionalsForCounties ADD CONSTRAINT professionals_professionalsforcounties_fk
FOREIGN KEY (ProfessionalId)
REFERENCES professionals.Professionals (ProfessionalId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Testimonials ADD CONSTRAINT professionals_testimonials_fk
FOREIGN KEY (ProfessionalId)
REFERENCES professionals.Professionals (ProfessionalId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Projects ADD CONSTRAINT professionals_projects_fk
FOREIGN KEY (ProfessionalId)
REFERENCES professionals.Professionals (ProfessionalId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.ImagesForProfessionals ADD CONSTRAINT professionals_imagesforprofessionals_fk
FOREIGN KEY (ProfessionalId)
REFERENCES professionals.Professionals (ProfessionalId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Features ADD CONSTRAINT professionals_features_fk
FOREIGN KEY (ProfessionalId)
REFERENCES professionals.Professionals (ProfessionalId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Endorsements ADD CONSTRAINT professionals_endorsements_fk
FOREIGN KEY (ProfessionalId)
REFERENCES professionals.Professionals (ProfessionalId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.ItemsForProjects ADD CONSTRAINT projects_servicesforprojects_fk
FOREIGN KEY (ProjectId)
REFERENCES professionals.Projects (ProjectId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.ImagesForProjects ADD CONSTRAINT projects_imagesforprojects_fk
FOREIGN KEY (ProjectId)
REFERENCES professionals.Projects (ProjectId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.CommentsForProjects ADD CONSTRAINT projects_comments_fk
FOREIGN KEY (ProjectId)
REFERENCES professionals.Projects (ProjectId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
ALTER TABLE professionals.Testimonials ADD CONSTRAINT projects_testimonials_fk
FOREIGN KEY (ProjectId)
REFERENCES professionals.Projects (ProjectId)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE;
CREATE OR REPLACE FUNCTION professionals.string_to_bits(input_string character varying)
RETURNS character varying AS
$BODY$
in_str = input_string
res_list = []
for c in in_str:
bits = bin(ord(c))[2:]
bits = '00000000'[len(bits):] + bits
res_list.append(bits)
result = ''.join(res_list)
return result
$BODY$
LANGUAGE plpython3u VOLATILE
COST 100;
COMMENT ON FUNCTION professionals.string_to_bits(character varying) IS 'Returns bit representation of a string as string';
CREATE OR REPLACE FUNCTION professionals.id_or_default_sfun_text(_int_state text, _next_data_values text)
RETURNS text AS
$BODY$
if _int_state:
return "MULTIPLE_VALUES"
else:
return _next_data_values
$BODY$
LANGUAGE plpython3u VOLATILE
COST 100;
COMMENT ON FUNCTION professionals.id_or_default_sfun_text(text, text) IS 'sfun function for id_or_default_text aggregate.';
CREATE AGGREGATE professionals.id_or_default_text(text) (
SFUNC=professionals.id_or_default_sfun_text,
STYPE=text
);
CREATE OR REPLACE FUNCTION professionals.id_or_default_sfun_num(_int_state DOUBLE PRECISION, _next_data_values DOUBLE PRECISION)
RETURNS DOUBLE PRECISION AS
$BODY$
if _int_state:
return -1
else:
return _next_data_values
$BODY$
LANGUAGE plpython3u VOLATILE
COST 100;
COMMENT ON FUNCTION professionals.id_or_default_sfun_num(DOUBLE PRECISION, DOUBLE PRECISION) IS 'sfun function for id_or_default_num aggregate.';
CREATE AGGREGATE professionals.id_or_default_num(DOUBLE PRECISION) (
SFUNC=professionals.id_or_default_sfun_num,
STYPE=DOUBLE PRECISION
);
| true |
c89c69befd96fbc8c55abe41e76b14d2bec4ca12 | SQL | rtashev/University-Projects | /library/create_tables_for_librarydb.sql | UTF-8 | 975 | 3.890625 | 4 | [
"MIT"
] | permissive | CREATE TABLE users
(
user_id int NOT NULL AUTO_INCREMENT,
name varchar(30) NOT NULL,
password varchar(100) NOT NULL,
role varchar(30),
enabled boolean,
primary key (user_id)
);
CREATE TABLE books
(
book_id int NOT NULL AUTO_INCREMENT,
name varchar(30) NOT NULL,
isbn varchar(30) NOT NULL unique,
author varchar(50) NOT NULL,
date_released date NOT NULL,
published_by varchar(30) NOT NULL,
primary key (book_id)
);
CREATE TABLE books_lent
(
lent_id int NOT NULL AUTO_INCREMENT,
user_id int NOT NULL,
book_id int NOT NULL,
lent_from date NOT NULL,
lent_until date NOT NULL,
primary key (lent_id),
foreign key (user_id) references users(user_id),
foreign key (book_id) references books(book_id)
);
INSERT INTO users(name,password,role,enabled)
VALUES ('user1','password1','ROLE_USER',1);
INSERT INTO users(name,password,role,enabled)
VALUES ('admin1','admin1','ROLE_ADMIN',1);
SET SQL_SAFE_UPDATES=0;
delete from users
where role = 'ROLE_USER';
SELECT * FROM users; | true |
3135300364643c4d630bcfdcd3848ad4e61983cf | SQL | iFeddy/unla-oo2 | /final-julio/lib/bdCooperativa.sql | UTF-8 | 7,783 | 3.28125 | 3 | [] | no_license | CREATE DATABASE IF NOT EXISTS `bdCooperativa` /*!40100 DEFAULT CHARACTER SET utf8 */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `bdCooperativa`;
-- MySQL dump 10.13 Distrib 8.0.25, for Linux (x86_64)
--
-- Host: localhost Database: bdCooperativa
-- ------------------------------------------------------
-- Server version 8.0.25
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `Almacen`
--
DROP TABLE IF EXISTS `Almacen`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8 */;
CREATE TABLE `Almacen` (
`idAlmacen` int NOT NULL,
`cantDeseable` int NOT NULL,
`cantMinima` int NOT NULL,
PRIMARY KEY (`idAlmacen`),
CONSTRAINT `fk_Almacen_1` FOREIGN KEY (`idAlmacen`) REFERENCES `Stock` (`idStock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Almacen`
--
LOCK TABLES `Almacen` WRITE;
/*!40000 ALTER TABLE `Almacen` DISABLE KEYS */;
INSERT INTO `Almacen` VALUES (1,20,5),(2,10,2),(3,15,7),(4,25,10);
/*!40000 ALTER TABLE `Almacen` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Cliente`
--
DROP TABLE IF EXISTS `Cliente`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8 */;
CREATE TABLE `Cliente` (
`idCliente` int NOT NULL AUTO_INCREMENT,
`apellido` varchar(30) NOT NULL,
`nombre` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
PRIMARY KEY (`idCliente`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Cliente`
--
LOCK TABLES `Cliente` WRITE;
/*!40000 ALTER TABLE `Cliente` DISABLE KEYS */;
INSERT INTO `Cliente` VALUES (1,'Rodriguez','Clara','crodriguez@gmail.com'),(2,'Lopez','Juan','jlopez@gmail.com'),(3,'Fernandez','Lucia','lfernandez@gmail.com');
/*!40000 ALTER TABLE `Cliente` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Lote`
--
DROP TABLE IF EXISTS `Lote`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8 */;
CREATE TABLE `Lote` (
`idLote` int NOT NULL AUTO_INCREMENT,
`fecha` date NOT NULL,
`cantExistente` int NOT NULL,
`cantInicial` int NOT NULL,
`idAlmacen` int NOT NULL,
PRIMARY KEY (`idLote`),
KEY `fk_Lote_1_idx` (`idAlmacen`),
CONSTRAINT `fk_Lote_1` FOREIGN KEY (`idAlmacen`) REFERENCES `Almacen` (`idAlmacen`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Lote`
--
LOCK TABLES `Lote` WRITE;
/*!40000 ALTER TABLE `Lote` DISABLE KEYS */;
INSERT INTO `Lote` VALUES (1,'2021-06-01',5,10,1),(2,'2021-06-08',10,10,1),(3,'2021-06-02',0,5,2),(4,'2021-06-09',3,5,2),(5,'2021-06-16',5,5,2),(6,'2021-06-16',0,10,3),(7,'2021-06-16',0,15,4),(8,'2021-06-17',4,10,3),(9,'2021-06-17',3,15,4),(10,'2021-06-18',10,10,3),(11,'2021-06-18',15,15,4);
/*!40000 ALTER TABLE `Lote` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `NotaPedido`
--
DROP TABLE IF EXISTS `NotaPedido`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8 */;
CREATE TABLE `NotaPedido` (
`idNotaPedido` int NOT NULL AUTO_INCREMENT,
`fecha` date NOT NULL,
`idCliente` int NOT NULL,
`idPedido` int NOT NULL,
`cantidad` tinyint NOT NULL,
`entregado` tinyint NOT NULL,
PRIMARY KEY (`idNotaPedido`),
KEY `fk_Pedido_2_idx` (`idCliente`),
KEY `fk_NotaPedido_1_idx` (`idPedido`),
CONSTRAINT `fk_NotaPedido_1` FOREIGN KEY (`idPedido`) REFERENCES `Pedido` (`idPedido`),
CONSTRAINT `fk_Pedido_2` FOREIGN KEY (`idCliente`) REFERENCES `Cliente` (`idCliente`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `NotaPedido`
--
LOCK TABLES `NotaPedido` WRITE;
/*!40000 ALTER TABLE `NotaPedido` DISABLE KEYS */;
INSERT INTO `NotaPedido` VALUES (1,'2021-06-19',1,1,2,1),(2,'2021-06-20',1,2,3,1),(3,'2021-06-20',1,1,4,0),(4,'2021-06-20',2,1,2,1),(5,'2021-06-20',2,2,3,1),(6,'2021-06-21',2,1,3,0),(9,'2021-06-21',2,4,2,0),(10,'2021-06-21',2,3,2,0),(11,'2021-06-20',1,4,3,0),(12,'2021-06-20',1,3,2,1),(13,'2021-06-20',3,4,3,1),(14,'2021-06-21',3,3,2,0),(15,'2021-06-21',3,2,4,0),(16,'2021-06-21',3,1,5,1);
/*!40000 ALTER TABLE `NotaPedido` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Pedido`
--
DROP TABLE IF EXISTS `Pedido`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8 */;
CREATE TABLE `Pedido` (
`idPedido` int NOT NULL,
PRIMARY KEY (`idPedido`),
CONSTRAINT `fk_Pedido_1` FOREIGN KEY (`idPedido`) REFERENCES `Stock` (`idStock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Pedido`
--
LOCK TABLES `Pedido` WRITE;
/*!40000 ALTER TABLE `Pedido` DISABLE KEYS */;
INSERT INTO `Pedido` VALUES (1),(2),(3),(4);
/*!40000 ALTER TABLE `Pedido` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Producto`
--
DROP TABLE IF EXISTS `Producto`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8 */;
CREATE TABLE `Producto` (
`idProducto` int NOT NULL AUTO_INCREMENT,
`codigo` varchar(6) NOT NULL,
`producto` varchar(30) NOT NULL,
`precio` double NOT NULL,
PRIMARY KEY (`idProducto`),
UNIQUE KEY `codigo_UNIQUE` (`codigo`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Producto`
--
LOCK TABLES `Producto` WRITE;
/*!40000 ALTER TABLE `Producto` DISABLE KEYS */;
INSERT INTO `Producto` VALUES (1,'001','Yerba Mate El Inmigrante',385),(2,'002','Aceite Geraso 1.5 lts',218),(3,'003','Queso Cremos 1kg',520),(4,'004','Dulce batata',185);
/*!40000 ALTER TABLE `Producto` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Stock`
--
DROP TABLE IF EXISTS `Stock`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8 */;
CREATE TABLE `Stock` (
`idStock` int NOT NULL AUTO_INCREMENT,
`idProducto` int NOT NULL,
PRIMARY KEY (`idStock`),
KEY `fk_Stock_1_idx` (`idProducto`),
CONSTRAINT `fk_Stock_1` FOREIGN KEY (`idProducto`) REFERENCES `Producto` (`idProducto`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Stock`
--
LOCK TABLES `Stock` WRITE;
/*!40000 ALTER TABLE `Stock` DISABLE KEYS */;
INSERT INTO `Stock` VALUES (1,1),(2,2),(3,3),(4,4);
/*!40000 ALTER TABLE `Stock` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-07-11 21:40:54
| true |
8c1bb19c72b1bd59b8f1d0d8b3adf8ed3a81332b | SQL | PratikRaut15/speed-elixia-project | /databasescripts/604_nightDrive_travellingReport.sql | UTF-8 | 1,490 | 3.4375 | 3 | [] | no_license | INSERT INTO `dbpatches` (
`patchid` ,
`patchdate` ,
`appliedby` ,
`patchdesc` ,
`isapplied`
)
VALUES ('604', '2018-09-04 12:12:00', 'Manasvi Thakur', 'Night Drive Travellimng Report', '0');
DELIMITER $$
DROP PROCEDURE IF EXISTS `get_vehicle_number_by_vehicleid`$$
CREATE PROCEDURE `get_vehicle_number_by_vehicleid`(
IN vehicleidParam INT,
IN customernoParam INT
)
BEGIN
IF(customernoParam = '' OR customernoParam = '0') THEN
SET customernoParam = NULL;
END IF;
SELECT v.vehicleNo
FROM vehicle as v
WHERE v.customerno=customernoParam AND v.vehicleid =vehicleidParam AND v.isdeleted=0;
END$$
DELIMITER ;
INSERT INTO `reportMaster` (`reportId`, `reportName`, `is_warehouse`, `customerno`, `isdeleted`) VALUES ('20', 'Night Travelling Report', '0', '0', '0');
CREATE TABLE IF NOT EXISTS `night_drive_details` (
`nightDriveDetId` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`start_time` time NOT NULL,
`end_time` time NOT NULL,
`threshold_distance` float NOT NULL,
`customerno` int(11) NOT NULL,
`createdBy` int(11) NOT NULL,
`createdOn` datetime NOT NULL,
`updatedBy` int(11) NOT NULL,
`updatedOn` datetime NOT NULL,
`isDeleted` TINYINT(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `dailyreport`
ADD `night_first_lat` FLOAT NOT NULL AFTER `end_long`,
ADD `night_first_long` FLOAT NOT NULL AFTER `night_first_lat`;
UPDATE dbpatches
SET patchdate = '2018-09-04 12:12:00',isapplied = 1
WHERE patchid = 604;
| true |
029c8d677f784c1b036927373b0413952944e1cf | SQL | Towels/Graph-of-Content | /src/main/resources/sql/load.sql | UTF-8 | 1,503 | 2.765625 | 3 | [] | no_license | INSERT INTO Token VALUES ("a7a263c0-c977-407f-a2eb-7e728cafd264", NOW());
INSERT INTO User VALUES (1, NOW(), "test@mail.xyz", NOW(), "TestUser", "angular", NOW(), "a7a263c0-c977-407f-a2eb-7e728cafd264");
INSERT INTO User VALUES (2, NOW(), "test", NOW(), "TestUser", "angular", NOW(), NULL);
INSERT INTO GraphOfContent VALUES (1);
INSERT INTO Lecture VALUES (1, NOW(), NOW(), "TowelsRule", "Prof. Dr. Washcloth", "Bathroom University", "PUBLIC", 1, 1);
INSERT INTO Lecture VALUES (2, NOW(), NOW(), "Do not forget to bring your Towel", "M. Sc. Towely", "Restroom University", "PRIVATE", 1, 1);
INSERT INTO Lecture VALUES (3, NOW(), NOW(), "Washing Stuff", "Grandma Towels", "Home for the Elderly", "PUBLIC", 1, 1);
INSERT INTO FileObject VALUES (1, NOW(), NOW(), "A picture of a towel", "JPG", "Towel", 1);
INSERT INTO FileObject VALUES (2, NOW(), NOW(), "Some WebTech slides", "PDF", "Webtech Slides", 1);
INSERT INTO FileObject VALUES (3, NOW(), NOW(), "High quality Screenshot", "PNG", "Some pic", 2);
INSERT INTO Node VALUES (1, "CHAPTER", "Chapter 1", 1,1, 1);
INSERT INTO Node VALUES (2, "CHAPTER", "Chapter 2", 1,2, 2);
INSERT INTO Node VALUES (3, "SECTION", "Section 2.1", 2,2, 3);
INSERT INTO GraphOfContent_Node VALUES (1, 1);
INSERT INTO GraphOfContent_Node VALUES (1, 2);
INSERT INTO GraphOfContent_Node VALUES (1, 3);
INSERT INTO DirectedEdge VALUES (1, 1, 2);
INSERT INTO DirectedEdge VALUES (2, 2, 3);
INSERT INTO GraphOfContent_DirectedEdge VALUES (1, 1);
INSERT INTO GraphOfContent_DirectedEdge VALUES (1, 2);
| true |
f9dae2431d60f811c13c339c2d5eda174e247447 | SQL | PreranaChandru/SQL | /LeetCode/1142. User Activity for the Past 30 Days II.sql | UTF-8 | 493 | 4.03125 | 4 | [] | no_license | #SOLUTION 1
SELECT IFNULL(ROUND(COUNT(DISTINCT session_id) / COUNT(DISTINCT user_id), 2), 0) AS average_sessions_per_user
FROM Activity
WHERE activity_date BETWEEN '2019-06-28' AND '2019-07-27';
#SOLUTION 2
SELECT IFNULL(ROUND(AVG(number_of_session), 2),0) AS average_sessions_per_user
FROM (SELECT DISTINCT user_id, COUNT(DISTINCT session_id ) AS number_of_session
FROM Activity
WHERE DATEDIFF('2019-07-27', activity_date) < 30
GROUP BY user_id) AS A; | true |
188d4462638f4e205b345e4d93df9abb2d6107ef | SQL | maxenceroux/airbyte | /airbyte-integrations/bases/base-normalization/integration_tests/normalization_test_output/postgres/test_primary_key_streams/final/airbyte_ctes/test_normalization/non_nested_stream_wi__lting_into_long_names_ab2.sql | UTF-8 | 480 | 2.609375 | 3 | [
"MIT"
] | permissive |
create view "postgres"._airbyte_test_normalization."non_nested_stream_wi__lting_into_long_names_ab2__dbt_tmp" as (
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
select
cast("id" as
varchar
) as "id",
cast("date" as
varchar
) as "date",
_airbyte_emitted_at
from "postgres"._airbyte_test_normalization."non_nested_stream_wi__lting_into_long_names_ab1"
-- non_nested_stream_wi__lting_into_long_names
);
| true |
8b7a7bab4922044b675c532151bff10bebcf952b | SQL | agreenwalrus/Review-Assistant | /trtpo_system.sql | UTF-8 | 2,638 | 3.5625 | 4 | [] | no_license | DROP DATABASE IF EXISTS trtpo_system;
SET NAMES 'utf8';
SET SESSION collation_connection = 'utf8_general_ci';
CREATE DATABASE trtpo_system DEFAULT CHARACTER SET 'utf8';
USE trtpo_system;
CREATE TABLE users(
id_user INTEGER AUTO_INCREMENT,
username VARCHAR(100),
password VARCHAR(100),
id_lecturer INTEGER,
PRIMARY KEY(id_user)
);
CREATE TABLE lecturers(
id_lecturer INTEGER AUTO_INCREMENT,
full_name VARCHAR(100) NOT NULL,
PRIMARY KEY(id_lecturer)
);
CREATE TABLE groups(
id_group INTEGER AUTO_INCREMENT,
group_number VARCHAR(20),
bsuir_api_group_id VARCHAR(20) NOT NULL,
amount_of_test INTEGER NOT NULL,
PRIMARY KEY(id_group)
);
CREATE TABLE groups_subgroups (
id_group_subgroup INTEGER AUTO_INCREMENT,
id_group INTEGER,
id_lecturer INTEGER,
PRIMARY KEY(id_group_subgroup)
);
CREATE TABLE subgroups (
id_subgroup int AUTO_INCREMENT,
id_group_subgroup INTEGER,
subgroup_number varchar(5) NOT NULL,
PRIMARY KEY(id_subgroup),
FOREIGN KEY(id_group_subgroup) REFERENCES groups_subgroups(id_group_subgroup)
);
CREATE TABLE students(
id_student int AUTO_INCREMENT,
full_name varchar(100) NOT NULL,
git_user_name varchar(30) NOT NULL,
git_repo_name varchar(30) NOT NULL,
email varchar(30) NULL,
id_group_subgroup int,
PRIMARY KEY(id_student),
FOREIGN KEY(id_group_subgroup) REFERENCES groups_subgroups(id_group_subgroup)
);
CREATE TABLE absentees(
id_absence INTEGER AUTO_INCREMENT,
id_class INTEGER,
id_student INTEGER,
PRIMARY KEY(id_absence)
);
CREATE TABLE classes(
id_class INTEGER AUTO_INCREMENT,
class_date DATETIME NOT NULL,
id_group_subgroup INTEGER,
PRIMARY KEY(id_class)
);
CREATE TABLE issued_labs(
id_issued_lab INTEGER AUTO_INCREMENT,
id_lab INTEGER ,
id_group_subgroup INTEGER,
id_class_of_issue INTEGER,
coefficient DOUBLE NOT NULL,
id_class_deadline INTEGER,
last_check_date_time DATETIME NOT NULL,
PRIMARY KEY(id_issued_lab)
);
CREATE TABLE labs(
id_lab INTEGER AUTO_INCREMENT,
lab_number INTEGER NOT NULL,
key_word VARCHAR(20) NOT NULL,
PRIMARY KEY(id_lab)
);
CREATE TABLE labs_marks(
id_lab_mark INTEGER AUTO_INCREMENT,
id_student INTEGER,
id_issued_lab INTEGER,
coefficient DOUBLE NOT NULL,
mark INTEGER NOT NULL,
PRIMARY KEY(id_lab_mark)
);
CREATE TABLE tests(
id_test INTEGER AUTO_INCREMENT,
test_number INTEGER NOT NULL,
test_date TIMESTAMP NOT NULL,
PRIMARY KEY(id_test)
);
CREATE TABLE tests_result(
id_test_result INTEGER AUTO_INCREMENT,
id_student INTEGER,
id_test INTEGER,
mark INTEGER NOT NULL,
PRIMARY KEY(id_test_result),
FOREIGN KEY(id_test) REFERENCES tests(id_test)
);
CREATE TABLE bonuses(
id_bonus INTEGER AUTO_INCREMENT,
id_student INTEGER,
bonus INTEGER NOT NULL,
PRIMARY KEY(id_bonus)
);
| true |
4a53ab63d2eaed34f078224ee77549e8cc9985f7 | SQL | TuMercado/TumercadoAdm | /bases/pruebaslocas.sql | UTF-8 | 6,202 | 2.875 | 3 | [] | no_license | -- ------------------------ INSERT -----------------------------------------------
-- insert into persona (ci,nombre,apellido,email,pais,contrasena,calle,numero,tarjeta,calificacion)
-- values (52185428,"ignacio","gallardo","ignaciogallardo@hotmail.com","Uruguay","pass","calera de las huerfanas",4345,1223423,"");
-- insert into telefonopersona (cipersona,telefono) values (52185428,23091329);
-- insert into administrador (idadministrador,ciadministrador,grado) values (1,52185428,"Administrador del sistema");
-- insert into usuario (idusuario,ciusuario,fecha,precio) values (1,52185428,CURDATE(),100);
-- insert into nombreusuario (idusuario,nombreusu) values (1,"GRATIS");
-- insert into publicacion (id,cipersona,nombrepubli,precio,descripcion,categoria,stock,fecha,tipo) values (1,52185428,"Cajones lindos",100,"publicacion muestra 1","Hogar",1,CURDATE(),"permuta");
-- insert into permuta (idpublicacion,calificacion,fecha) values (1,"no califica",CURDATE());
-- insert into persona (ci,nombre,apellido,email,pais,contrasena,calle,numero,tarjeta,calificacion)
-- values (52212360,"matias","gallardo","matiasgallardo@gmail.com","Uruguay","matias","calera de las huerfas",4345,999999,"Mal vendedor");
-- insert into telefonopersona (cipersona,telefono) values (52212360,094697192);
-- insert into usuario (idusuario,ciusuario,fecha,precio) values (2,52212360,"2017-05-28",100);
-- insert into nombreusuario (idusuario,nombreusu) values (2,"PREMIUM 3");
-- insert into publicacion (id,cipersona,nombrepubli,precio,descripcion,categoria,stock,fecha,tipo) values (2,52212360,"Vendo todo soy pobre",3400,"Es todo lo que vendo porque soy pobre y necesito fasito coso","Varios",23,"2017-05-29","Permuta");
-- insert into bajasuspencion (cibajaadministrador,idbajapublicacion,estado,fecha) values (52185428,2,"Sin suspencion",CURDATE());
-- insert into permuta (idpublicacion,calificacion,fecha) values (2,"no calificada aun","2017-05-29");
-- insert into persona (ci,nombre,apellido,email,pais,contrasena,calle,numero,tarjeta,calificacion)
-- values (52212361,"Lucas","Gonzalez","LucasGonzalez@gmail.com","Colombia","contra","calle colombia",523,822828,"Vendedor Recomendado");
-- insert into telefonopersona (cipersona,telefono) values (52212361,094695192);
-- insert into usuario (idusuario,ciusuario,fecha,precio) values (3,52212361,"2017-06-12",300);
-- insert into nombreusuario (idusuario,nombreusu) values (3,"PREMIUM 1");
-- insert into publicacion (id,cipersona,nombrepubli,precio,descripcion,categoria,stock,fecha,tipo)
-- values (3,52212361,"OFERTON COLOMBIA HELADERA SIN USO!!",320,"Esta heladera esta completamente sin uso !NO SE LO PIERDA!","COCINA",1,"2017-06-12","Permuta");
-- insert into permuta (idpublicacion,calificacion,fecha) values (3,"no calificada aun","2017-06-12");
-- insert into sansiona (ciadministradorsan,ciusuariosan,estado,fecha) values (52185428,52212360,"Prohibir realizar transacciones",CURDATE());
-- insert into sancionadmin (ciadministradorsanadmin,idadministradorsan1,idadministradorsan2,estado,fecha) values (52185428,1,2,"suspendido por gil",CURDATE());
-- ---------------------------------- UPDATE y DELETE -----------------------------------------------
-- UPDATE publicacion SET nombrepubli="HELADERA FEITA",precio=1000,descripcion="esto es una publicacion alterada",categoria="jueguitos",stock=3 WHERE id=3;
-- update bajasuspencion set estado="cambio estado" where idbajapublicacion=1;
-- update persona set nombre="nom1",apellido="appe",email="email1",pais="pais1",contrasena="cont",calle="calle1",numero=123,calificacion="cali"
-- where ci=52185428;
-- update administrador set grado where ciadministrador=123123;
-- update sancionadmin set estado="" where idadministradorsan2=2;
-- update sansiona set estado="quitar sancion", fecha=CURDATE() where ciusuariosan=52212360;
-- delete from usuario where idusuario=2;
-- delete from sansiona where ciusuariosan=;
-- -------------- Todas estas para poder eliminar la publicacion correctamente -------------------------------
-- delete from permuta where idpublicacion=3;
-- delete from bajasuspencion where idbajapublicacion=3;
-- delete from publicacion where id=3;
-- --------------- Todas para borrar persona -------------------
-- delete from telefonopersona where cipersona=52212361;
-- delete from nombreusuario where idusuario=3;
-- delete from usuario where ciusuario=52212361;
-- delete from persona where ci=52212361;
-- ------------------------ SELECT ----------------------------------------------
-- select ci,nombre,apellido,email,contrasena,calle,numero,calificacion,cipersona,telefono,grado from persona,telefonopersona,administrador where (persona.ci=telefonopersona.cipersona) and (persona.ci=administrador.ciadministrador);
-- select * from usuario;
-- select ci,persona.nombre,apellido,email,contrasena,calle,numero,calificacion,telefono from persona,telefonopersona,usuario,nombreusuario where (persona.ci=telefonopersona.cipersona) and (persona.ci=usuario.ciusuario) and (nombreusuario.idusuario=usuario.idusuario);
-- select usuario.idusuario,ciusuario,nombre,apellido,email,calle,numero,calificacion,nombreusu from usuario,nombreusuario,persona where (usuario.idusuario=nombreusuario.idusuario) and (persona.ci=usuario.ciusuario);
-- select id,cipersona,nombre,apellido,email,nombrepubli,precio,descripcion,categoria,stock,tipo from publicacion,persona,permuta where cipersona=ci and id=idpublicacion;
-- select * from bajasuspencion;
-- select * from bajasuspencion where idbajapublicacion=2;
-- select usuario.idusuario,ciusuario,nombre,apellido,email,calle,numero,calificacion,nombreusu from
-- usuario,nombreusuario,persona where ((usuario.idusuario=nombreusuario.idusuario) and (persona.ci=usuario.ciusuario)) and usuario.idusuario=3;
-- select usuario.idusuario,ciusuario,nombre,apellido,ci,email,calle,numero,calificacion,nombreusu,estado,sansiona.fecha from
-- usuario,nombreusuario,persona,sansiona where (usuario.idusuario=nombreusuario.idusuario)
-- and (persona.ci=usuario.ciusuario) and usuario.idusuario=2;
-- select * from sansiona where ciusuariosan=52185428;
-- select nombre,apellido,email,grado from administrador,persona where idadministrador=2 and ci=52185420; | true |
c0493227a1d6850e83421b1101bdfa8eaaf4029a | SQL | krzysztofkogut/Database_lab | /lab06/zad-6-5.sql | UTF-8 | 700 | 3.375 | 3 | [] | no_license | /* baza danych: cukiernia
Napisz instrukcje usuwające z bazy danych informacje o: */
/* 1. klientach o nazwisku Matusiak, */
select * from cukiernia.klienci where nazwa like '%Matusiak%';
delete from cukiernia.klienci where nazwa like '%Matusiak%';
/* 2. klientach o identyfikatorze większym niż 91, */
select * from cukiernia.klienci where idklienta>91;
delete from cukiernia.klienci where idklienta>91;
/* 3. czekoladkach, których koszt jest większy lub równy 0.45 lub masa jest większa lub równa 36, lub masa jest równa 0. */
select * from cukiernia.czekoladki where koszt >=0.45 or masa >= 36 or masa=0;
delete from cukiernia.czekoladki where koszt >=0.45 or masa >= 36 or masa=0; | true |
487dce3ea4556c35418636371a8b265e787c254e | SQL | gioferro96/SDM-AccessControl | /database/dumpFinal.sql | UTF-8 | 3,622 | 3.234375 | 3 | [] | no_license | CREATE DATABASE IF NOT EXISTS `patient` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `patient`;
-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64)
--
-- Host: localhost Database: patient
-- ------------------------------------------------------
-- Server version 5.7.28-0ubuntu0.18.04.4
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `data`
--
DROP TABLE IF EXISTS `data`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `data` (
`userid` int(11) NOT NULL,
`uploadDate` date DEFAULT NULL,
`type` varchar(20) DEFAULT NULL,
`info` text,
KEY `userid` (`userid`),
CONSTRAINT `data_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `data`
--
LOCK TABLES `data` WRITE;
/*!40000 ALTER TABLE `data` DISABLE KEYS */;
/*!40000 ALTER TABLE `data` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tempData`
--
DROP TABLE IF EXISTS `tempData`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tempData` (
`userid` int(11) NOT NULL,
`uploaderName` varchar(40) NOT NULL,
`uploadDate` date DEFAULT NULL,
`type` varchar(20) DEFAULT NULL,
`info` text,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tempData`
--
LOCK TABLES `tempData` WRITE;
/*!40000 ALTER TABLE `tempData` DISABLE KEYS */;
/*!40000 ALTER TABLE `tempData` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
`dob` date DEFAULT NULL,
`address` varchar(40) DEFAULT NULL,
`category` varchar(40) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES (20,'MSTHospital',NULL,'Enschede','hospital'),(21,'Best Health Club',NULL,'Henghelo','healthclub');
/*!40000 ALTER TABLE `users` 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 2019-11-27 19:34:39
| true |
433a8c405a991c5f2e31eebf3b7080e6213905aa | SQL | zvika77/zvika_env | /Redshift/Sql/show_wlm_status.sql | UTF-8 | 988 | 3.5 | 4 | [] | no_license | SELECT config.service_class AS queue ,
TRIM (case when class.condition = '' then config.name else class.condition end ) AS description ,
state.num_executing_queries||'/'||config.num_query_tasks AS slots ,
state.num_queued_queries queued ,
config.query_working_mem as "MemPerSlot",
config.query_working_mem * config.num_query_tasks AS "memAllSlots" ,
(config.max_execution_time/1000)::int AS max_time_sec ,
config.user_group_wild_card AS "user_*" ,
config.query_group_wild_card AS "query_*" ,
state.num_executed_queries executed
FROM STV_WLM_CLASSIFICATION_CONFIG CLASS,
STV_WLM_SERVICE_CLASS_CONFIG config,
STV_WLM_SERVICE_CLASS_STATE STATE
WHERE CLASS.action_service_class = config.service_class
AND CLASS.action_service_class = STATE.service_class
AND config.service_class > 4
ORDER BY config.service_class;
| true |
ff10bad18c852cd421b1315ec847dfefe8cd5a59 | SQL | smartaid1980/STOutsource | /src/main/webapp/WEB-INF/sql/update/20190716_strongled_storage/V20190711_02_1.2__alter_a_storage_material_thing.sql | UTF-8 | 1,475 | 2.9375 | 3 | [] | no_license | ALTER TABLE `a_storage_material_thing`
ADD COLUMN `material_sub` VARCHAR(20) NOT NULL DEFAULT '0000' COMMENT '原料分項,無分項者預設0000=批號,同ERP.batchID批號' AFTER `material_id`,
MODIFY COLUMN `remark` VARCHAR(1024) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '產品名稱,等同於 ERP.prodName AKA material_name' AFTER `material_sub`,
ADD COLUMN `bill_from` VARCHAR(20) COMMENT '來源單號=bill_no' AFTER `remark`,
ADD COLUMN `bill_detail` INTEGER UNSIGNED COMMENT '來源細項=bill_detail' AFTER `bill_from`,
ADD COLUMN `code_no` INTEGER UNSIGNED COMMENT '條碼序號' AFTER `bill_detail`,
ADD COLUMN `column1` VARCHAR(20) COMMENT '保留' AFTER `code_no`,
ADD COLUMN `column2` VARCHAR(20) COMMENT '保留' AFTER `column1`,
ADD COLUMN `column3` VARCHAR(20) COMMENT '保留' AFTER `column2`,
ADD COLUMN `delivery_date` VARCHAR(8) COMMENT '出廠日期=delivery_date' AFTER `column3`,
MODIFY COLUMN `exp_date` DATE COMMENT '有效日期' AFTER `delivery_date`,
ADD COLUMN `in_stock` BOOLEAN NOT NULL DEFAULT 0 COMMENT '是否入庫' AFTER `exp_date`,
MODIFY COLUMN `is_new` BOOLEAN NOT NULL DEFAULT 1 COMMENT '是否全新' AFTER `in_stock`,
MODIFY COLUMN `status` INTEGER UNSIGNED NOT NULL DEFAULT 0 COMMENT '保留' AFTER `is_new`,
ADD INDEX `Index_material_sub`(`material_sub`),
ADD INDEX `Index_bill_from`(`bill_from`),
ADD INDEX `Index_code_no`(`code_no`),
DROP FOREIGN KEY `FK_a_storage_material_thing_material_id`; | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.