text stringlengths 6 9.38M |
|---|
--------------------------------------------------------
-- File created - Tuesday-February-21-2012
--------------------------------------------------------
--REM INSERTING into RULESET
Insert into CTUSR.RULESET (RULESET_ID,RULESET_NAME,RULESET_DESCRIPTION) values (1,'processCompleteStandardWindow','The Process... |
SELECT e.EmployeeID, e.FirstName, e.LastName, d.[Name] AS DepartmentName
FROM Employees e
JOIN Departments d ON e.DepartmentID = d.DepartmentID
WHERE d.Name = 'Sales' |
select distinct(DATE_TRUNC ('week', ship_date)) as "week",
sum(order_quantity) * 100 as "Total Units"
from adventureworks_analytics.product_base_and_order_details2
where extract(year from ship_date) IN (2017,2018)
group by 1
order by 1;
|
-- $Id: connect_as_dslmon.sql,v 1.2 2009/07/20 10:59:51 a59603 Exp $
conn dslmon1/tdc@dslmon-test.tdk.dk
WHENEVER SQLERROR EXIT
select 'DSLMON1' "Schema"
from dual
where 1 = decode(user, 'DSLMON1', 1, 'NOT');
WHENEVER SQLERROR CONTINUE
|
/* add_event: date Event.event_name%TYPE -> void
This procedure expects a date for the time of the event and a name, returns
nothing, and has the side effect of adding that event to the event table */
create or replace procedure add_event(
new_event_date date,
new_event_name Event.event_name%TYPE) as... |
create PROC [ERP].[Usp_Upd_AnticipoCompra_Desactivar]
@ID INT,
@UsuarioElimino VARCHAR(250)
AS
BEGIN
UPDATE ERP.AnticipoCompra SET Flag = 0,UsuarioElimino =@UsuarioElimino , FechaActivacion = DATEADD(HOUR, 3, GETDATE()) WHERE ID = @ID
UPDATE ERP.CuentaPagar SET Flag = 0 WHERE ID = (SELECT IdCuentaPagar FROM ... |
DROP DATABASE IF EXISTS simpledoge;
DROP DATABASE IF EXISTS simpledoge_testing;
CREATE USER simpledoge WITH PASSWORD 'testing';
CREATE DATABASE simpledoge;
GRANT ALL PRIVILEGES ON DATABASE simpledoge to simpledoge;
-- Create a testing database to be different than dev
CREATE DATABASE simpledoge_testing;
GRANT ALL PRIVI... |
insert into items (title,description,start_price,bid_increment,start_date,stop_date,buy_it_now) VALUES
('Axe of Ares','given to the mankind by gods','1000000','500000','2019-01-01','2019-12-31','Y'),
('Crown of Wilgelm the Conqueror','once belonged to one of the most powerful rulers in history','10000000','500000... |
insert into sec_authority(rol_id,rsc_id,read_yn,write_yn) values ('ROLE_ADMIN',1,'Y','Y');
insert into sec_authority(rol_id,rsc_id,read_yn,write_yn) values ('ROLE_ADMIN',2,'Y','Y');
insert into sec_authority(rol_id,rsc_id,read_yn,write_yn) values ('ROLE_ADMIN',3,'Y','Y');
insert into sec_authority(rol_id,rsc_id,read_y... |
# After completd Lynda's SQL: Data Reporting and Analysis course.
# I have logged some cool queries I saw in the course
# Between Query
SELECT * FROM actor
WHERE actor_id BETWEEN 1 AND 5;
# Wildcard Query
SELECT * FROM actor
WHERE first_name LIKE 'JA%NE';
# Wildcard Query II
SELECT * FROM actor
WHERE first_name LIK... |
SELECT * FROM ironhack_personnel.applestore;
SELECT DISTINCT prime_genre #distinct Get Rid of Duplicates
FROM applestore;
SELECT prime_genre, rating_count_tot FROM applestore ORDER BY rating_count_tot DESC; #is used to sort the data returned in descending order.
SELECT MIN(prime_genre) AS SmallestPrime_Genre
FROM appl... |
DROP TABLE final_data.cc;
CREATE TABLE final_data.cc_constants AS
WITH dt_data AS (
SELECT CAST(dt AS DATE), lat, lng, 'alley gang/homeless=' || COALESCE(json_data::json->>'any_people_using_property_homeless_childen_gangs', 'false') AS data_label
FROM datasets.alley_lights_out_311
UNION ALL
SELECT CAST(dt AS ... |
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: db:3306
-- Generation Time: May 27, 2020 at 05:44 AM
-- Server version: 5.7.29
-- PHP Version: 7.4.4
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACT... |
WITH
school_user_metrics AS ( #work out current user-related metric values for all individual schools for use in the main query later
SELECT
CAST(school_urn AS STRING) AS urn,
MIN(approval_datetime) AS dsi_signup_date,
#the earliest date that a user is recorded as authorised for TV access in DSI - for s... |
/*
Navicat MySQL Data Transfer
Source Server : 127.0.0.1
Source Server Version : 50624
Source Host : localhost:3306
Source Database : shop
Target Server Type : MYSQL
Target Server Version : 50624
File Encoding : 65001
Date: 2017-08-29 12:34:28
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----... |
CREATE VIEW TZ_ETL_JOB_WORKER AS
SELECT J.JOB_WORKER_CD ,
J.JOB_WORKER_NAME ,
J.JOB_WORKER_DESC,
J.RECORD_STATUS ,
J.JOB_AGENT_CD ,
J.LAST_RUN_NO ,
J.LAST_RUN_STATUS ,
J.LAST_RUN_START_DT + TZ.UTC_minutes * INTERVAL '1 minute' as LAST_RUN_START_DT,
J.LAST_RUN_END_DT + TZ.UTC_minutes * INTERVAL '1 minute... |
declare
my_type mytype;
cursor getItem is
select store1_item multiset union distinct store2_item from item_orders where act_month='january';
begin
open getItem;
fetch getItem into my_type;
if 'trademill' member of my_type then
dbms_output.put_line('True');
end if;
for index_item in my_type.first..my_type.last loop
d... |
select * from KRMS_TERM_SPEC_T where DESC_TXT like 'The answer%' and nmspc_cd = 'KC-PD';
select * from KRMS_TERM_SPEC_T where term_spec_id = 'KC1016';
select * from KRMS_TERM_T where term_spec_id = 'KC1016';
select * from KRMS_FUNC_T where ;
select * from KRMS_FUNC_PARM_T where ;
select * from KRMS_CNTXT_VLD_TERM... |
/*
################################################################################
Migration script to update SNP_TYPE values
Designed for execution with Flyway database migrations tool; this should be
automatically run to completely generate the schema that is out-of-the-box
compatibile with the GOCI model (see
htt... |
/*
APEX Performance - PAGE 110:23
--------------------------------------------------------------------------------------------------
*/
select null lnk
,to_char(view_date) dd
,round(avg(elapsed_time),2) "Avg time"
,round(avg(avg(elapsed_time)) over (order by to_char(view_date,'yymmdd') desc rows betwe... |
CREATE DATABASE IF NOT EXISTS encuestas;
use encuestas;
CREATE TABLE encuesta(
id_encuesta int auto_increment,
sexo char(1),
provincia varchar(50),
salario int,
edad int,
CONSTRAINT pk_id_encuesta PRIMARY KEY(id_encuesta)
);
use encuestas;
create TABLE preguntas(
id_preguntas int auto_incr... |
DROP TABLE IF EXISTS shandang_fanli;
CREATE TABLE IF NOT EXISTS shandang_fanli (
username VARCHAR(128) NOT NULL,
recharge_id VARCHAR(128) NOT NULL,
INDEX(username)
)
CHARACTER SET = utf8
ENGINE = InnoDB;
DELIMITER $$
DROP PROCEDURE IF EXISTS load_shandang_fanli$$
CREATE PROCEDURE load_shandang_fanli ()
BEGIN
SELECT u... |
CREATE OR REPLACE VIEW favoritedocument AS
SELECT DISTINCT
"document",
"researchEntity"
FROM authorship a
JOIN document d ON a.document = d.id
WHERE a.favorite = TRUE |
/*$tempViewSQL*/
SELECT TOP(CONVERT(INT, /*topRow*/)) * FROM
(
SELECT
A.GUARANTEE_OBJECT,
--A.保証人名
A.GUARANTOR_NAME,
--A.保証人コード
A.GUARANTOR_CODE,
--コード名称
B.CODE_NAME AS GUARANTEE_TYPE_NAME,
--D.取引先名
D.CUSTOMER_NAME,
--C.顧客_取引先コード
C.CUSTOMER_CODE,
--D.xxx取引先コード
D.DYNASS_CUSTOMER_CODE,
--A.契約番号
A.CONTRA... |
insert into users( name, surname, patronymic, username, email, password,role_id) values (
'Қуаныш',
'Физалин',
'Физулинович',
'admin',
'admin@gmail.com',
'$2a$10$9uvPhc4vidoR.Zb8kPQ3g.zZQZhJfq9mOETHwBtzdW3ERD.t0sbSi',1);
commit;
insert into users( name, surname, patronymic, username, email, password, role_id) val... |
create table book_shelf(
book_shelf_id serial primary key,
cart_id integer,
user_id integer,
book_id integer
) |
/* to replace the whole view, drop it before
* creating the new view. Run the script
* removing the regular expression for '--'.
* Otherwise, it will try to create a new view
* or update an old view without dropping.
*/
--drop view if exists premodeling.jocojimsjailbooking_hashed_view;
drop view if exists clean.jo... |
-- phpMyAdmin SQL Dump
-- version 4.4.15.5
-- http://www.phpmyadmin.net
--
-- Host: csse-mysql2
-- Generation Time: Sep 23, 2018 at 09:43 AM
-- Server version: 5.6.40
-- PHP Version: 5.4.16
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Database: `seng302-2018-team200-test`
--
-- -----------... |
CREATE TABLE `sessions` (
`session_id` varchar(32) NOT NULL DEFAULT '',
`username` varchar(31) NOT NULL DEFAULT '',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`timezone` varchar(31) NOT NULL DEFAULT '',
`utc_offset` tinyint(2) NOT NULL,... |
# Write your MySQL query statement below
## A quiet student is the one who took at least one exam and did not score the high or the low score.
## Get the list of student_id who score the high or the low score with rank()
## select student_id from Student where id not in the list
with score_rank as
(select
exam_i... |
-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64)
--
-- Host: 127.0.0.1 Database: newlibrary
-- ------------------------------------------------------
-- Server version 8.0.23
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
... |
-- lists all shows contained in hbtn_0d_tvshows
-- without a genre linked.
SELECT tv_shows.title, tv_show_genres.genre_id
FROM tv_shows
LEFT OUTER JOIN tv_show_genres
ON tv_show_genres.show_id = tv_shows.id
WHERE genre_id IS NULL
ORDER BY tv_shows.title ASC, tv_show_genres.genre_id AS... |
CREATE TABLE `ClB_config` (
`config_name` varchar(255) NOT NULL default '',
`config_value` text NOT NULL default '',
`config_method` varchar(6) NOT NULL default 'normal'
);
INSERT INTO `ClB_config` VALUES ('SESSIONS_TABLE', '$prefixsessions', 'define');
INSERT INTO `ClB_config` VALUES ('session_expire', '3600', ... |
DROP TABLE events;
DROP TABLE attachments; |
INSERT INTO `ysy_category` VALUES('1','1','content','1','0','0','0','1','1,2,3,5,162','网站介绍','','','','','about','/html/about/','0','0','array (
\'ishtml\' => \'1\',
\'template_list\' => \'default\',
\'page_template\' => \'page\',
\'meta_title\' => \'\',
\'meta_keywords\' => \'\',
\'meta_description\' => \'... |
SPOOL project.out
/**************************************
CIS 353 - Database Design Project
Daniel Kelch
John O'Brien
Marcus Hughes
Travis Keel
Alen Ramic
**************************************/
SET ECHO ON
DROP TABLE Country CASCADE CONSTRAINT;
DROP TABLE Country CASCADE CONSTRAINT;
DROP TABLE Event CAS... |
-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 21, 2017 at 02:30 PM
-- Server version: 10.1.21-MariaDB
-- PHP Version: 5.6.30
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SE... |
-- drop db if exists
DROP DATABASE IF EXISTS hbtn_0c_0;
|
-- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Nov 22, 2018 at 07:54 AM
-- Server version: 10.1.36-MariaDB
-- PHP Version: 7.2.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OL... |
TABELA DOADORES
TABELA ONGS
TABELA DOACOES
|
select * from ems_equipmenttype
select * from ems_equipmentsubtype
select * from ems_equipmentprod
select * from ems_brand
select a.id 大类编码,a.name 大类名称,b.id 小类编码,b.name 小类名称,c.id 品名编码,c.name 品名名称,c.style 型号
,c.unit 单位,C.SPEC 规格,d.name 品牌,c.quality_month 质保_月,c.depreci_year 折旧年限
from ems_equipmenttype a
inner ... |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Author: gabri
* Created: Dec 5, 2020
*/
INSERT INTO Departamento (nombreSistema) VALUES ("Sistema Gabriel");
INSERT INT... |
drop database gsu_moviedb;
create database gsu_moviedb;
use gsu_moviedb;
create table movie(
movieID int(5) not null,
movieTitle varchar(50) not null,
movieDesc varchar(150),
movieReleaseDate varchar(150),
movieRuntime int(3) check (movieRuntime > 25),
movieCertificate varchar(4) check (movieCe... |
create policy project_creator_update_address on address
for update to app_user using (
exists (
SELECT 1 from project
WHERE project.address_id = address.id
AND project.creator_id = public.get_current_user_id()
)
);
|
--enrolled prior ssis, activate post ssis
SELECT TOP 1000 *
FROM profile.dbo.Profile p
JOIN profile.KeyMap.CustomerKey ck
ON p.ProfileID = ck.ProfileID
JOIN Membership.dbo.Membership m
ON ck.MembershipID = m.MembershipID
JOIN Membership.dbo.MembershipCard mc
ON m.MembershipID = mc.MembershipID
WHERE m.Membersh... |
-- 查詢所有同學的學號、姓名、選課數、總成績
SELECT s.s_id as [ID], s.s_name as [Name], COUNT(sc.s_score) as [Num of course], SUM(sc.s_score) as [Sum of score]
FROM student s left join score sc ON s.s_id = sc.s_id
GROUP BY s.s_id, s.s_name |
-- 특정 조건의 데이터 삭제
delete from sales where sales_id = 2;
-- 테이블(데이터만) 삭제
truncate table employees;
-- 테이블(데이터+테이블구조) 삭제
drop table employees;
-- 데이터베이스(데이터+테이블구조+DB) 삭제
drop database market; |
CREATE USER mastermind
IDENTIFIED BY test
DEFAULT TABLESPACE users
QUOTA 20m ON users;
GRANT create session, create table, create procedure, create type, create view
TO mastermind;
|
--create role ecidade with superuser login password 'ecidade';
create role dbseller with login password 'dbseller';
create role plugin with login password 'plugin';
create role dbportal with login password 'dbportal';
--CREATE DATABASE "e-cidade";
--GRANT ALL PRIVILEGES ON DATABASE "e-cidade" to ecidade;
|
CREATE TABLE public.event_access_type_table
(
id integer NOT NULL DEFAULT,
access_type character varying(500) NOT NULL,
created_by character varying(100) NOT NULL,
created_on timestamp without time zone,
CONSTRAINT event_access_type_table_pkey PRIMARY KEY (id),
CONSTRAINT event_access_type_table... |
select requestnumid as номер_наряда, extnumbers as внешний_номер, 0 as тип_наряда, requestscheduledb as дата_закрытия,
requeststatusname as статус_наряда, executors as исполнитель, 0 as ид_исполнителя,
resourcetype as тип_договора, 0 as тип_услуги, technologyname as технология, actionname as тип_работ,
task_group... |
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SU... |
CREATE TABLE `book_it`.`test`
(
`idtest` INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`idtest`)
);
|
use employees;
EXPLAIN SELECT E.emp_no, CONCAT(first_name, ' ',last_name), from_date, to_date, salary
FROM employees E, salaries S
WHERE E.emp_no=S.emp_no
ORDER BY E.emp_no, from_date
|
DROP SEQUENCE USERS_ID_SEQ;
DROP SEQUENCE DRUG_ID_SEQ;
DROP SEQUENCE DRUG_USER_SUITABILITY_ID_SEQ;
DROP SEQUENCE EFFECT_ID_SEQ;
DROP SEQUENCE USER_LOGIN_ID_SEQ;
DROP SEQUENCE PATIENT_DETAILS_ID_SEQ;
DROP SEQUENCE INCIDENT_ID_SEQ;
DROP SEQUENCE PATIENT_ALLERGIES_ID_SEQ;
DROP SEQUENCE DRUG_ALLERGY_ID_SEQ;
DROP SEQUENCE D... |
CREATE TABLE IF NOT EXISTS field_sensor_data (
farmer_field_visit_id INT REFERENCES farmer_field_visit ON DELETE SET NULL,
record_timestamp TIMESTAMP NOT NULL,
position geography(Point,4326) NOT NULL,
rainfall NUMERIC,
humidity NUMERIC,
temperature NUMERIC,
light_intensity NUMERIC,
UNIQUE (record_timest... |
DROP DATABASE IF EXISTS hospital_801166050;
CREATE DATABASE hospital_801166050;
DROP TABLE IF EXISTS physician;
CREATE TABLE IF NOT EXISTS physician(
id CHAR(6) NOT NULL,
phy_name VARCHAR(30) DEFAULT NULL,
certnum VARCHAR(20),
phone VARCHAR(12) DEFAULT NULL,
field VARCHAR(20),
address varchar(5... |
CREATE DATABASE IF NOT EXISTS project;
use project;
create table patient (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(30) DEFAULT NULL,
`sex` varchar(10) DEFAULT NULL,
`birth_year` int DEFAULT NULL,
`Covid19` int DEFAULT NULL,
`result` double DEFAULT NULL,
`datacolume1` MEDIUMTEXT DEFAULT NULL,
`datacolume2` MEDI... |
-- Составить список авторов с указанием количества изданных книг
-- (в том числе в соавторстве).
SELECT COUNT(books_authors.au_id) AS book_count, CONCAT(au_lname,' ', au_fname) AS author
FROM books_authors,
authors
WHERE authors.au_id = books_authors.au_id
GROUP BY books_authors.au_id
ORDER BY book_count;
-- Опре... |
SELECT *
FROM user
WHERE user_id=:id
|
ALTER TABLE ESKALERINGSVARSEL
ADD CONSTRAINT gjeldende
CHECK ((AVSLUTTET_DATO IS NULL AND GJELDENDE = AKTOR_ID) OR (AVSLUTTET_DATO IS NOT NULL AND GJELDENDE IS NULL)); |
CREATE OR REPLACE FUNCTION zerobyte.DATETIME_TO_ZEROBYTE(d DATETIME)
AS (
zerobyte.INT64_TO_ZEROBYTE(DATETIME_DIFF(d, '1970-01-01', MICROSECOND))
);
|
-- NQ5 : finding new auctions with the most number of bids (every 2 seconds, analyzing the last 10 second if possible)
-- using window duration of 10s, slide of 2s
-- ORIGINAL QUERY :
-- SELECT Rstream(auction)
-- FROM (SELECT B1.auction, count(*) AS num
-- FROM Bid [RANGE 60 MINUTE SLIDE 1 MINUTE] B1
-... |
select *
from TableTest
where id > 1 and id < 3
select *
from TableTest as t1
inner join Test1 as t2 on t1.Id = t2.Id
--where t1.id > 1 and t1.id < 3
select *
from TableTest as t1
right outer join Test1 as t2 on t1.Id = t2.Id
--where t1.id > 1 and t1.id < 3
select *
from TableTest as t1
full outer join Test1 as t... |
--------------------------------------------------------------------------------------------------------------------------------------------------
--- Alter script for adding columns passwordSalt to Login Table and isVisibleToSeason to LookupDepartments table on 6th August 2015---------------
-------------------------... |
-- Fix Awards Day 6
select a.award_number,
d.award_number ,a.award_id,d.award_id
from award a,
award_custom_data d
where a.award_id = d.award_id
and a.award_number in (
'001302-00001','002172-00001','002171-00001','001845-00001','001448-00001','002207-00001','002262-00001','002115-00001','001991-00001','00... |
CREATE PROC ERP.Usp_Del_MovimientoTransferencia
@ID INT
AS
BEGIN
DELETE FROM ERP.MovimientoTransferenciaCuenta WHERE ID = @ID
END |
use posapp;
create table outlets(
id int(10) not null auto_increment,
name varchar(50) not null,
address text not null,
phone varchar(20) not null,
primary key(id)
)engine=InnoDB;
drop table outlets;
desc outlets;
select * from outlets; |
INSERT INTO Student VALUES (1,'ICT', 'mdu@gmail.com', 'Mduduzi','NorthWest','Silinda');
INSERT INTO Student VALUES (2,'DEV', 'sibiya@gmail.com', 'Norah','Limpopo','Sibiya');
INSERT INTO Student VALUES (3,'AGRIC', 'goodness@gmail.com', 'Goodness','WesternCape','Mhlongo');
INSERT INTO Student VALUES (4,'HOSPI', 'violet@g... |
CREATE TABLE `faq` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`order` int(10) UNSIGNED NOT NULL DEFAULT '0',
`question` text NOT NULL,
`answer` text NOT NULL,
`categories` text NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf... |
//script query create table
create table mountain
(
id varchar(255) not null,
mountain_name varchar(30),
photo varchar(50),
description varchar(255),
height int,
full_address varchar(255),
created_date TIMESTAMP,
created_by varchar(30),
updated_date ... |
-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jul 23, 2017 at 04:53 AM
-- Server version: 10.1.13-MariaDB
-- PHP Version: 7.0.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLI... |
-- tables multi
-- depends: 20211004_08_tcYYs-orders-drop-constraints
CREATE TABLE table1 (id SERIAL PRIMARY KEY);
CREATE TABLE table2 (id SERIAL PRIMARY KEY);
CREATE TABLE table3 (id SERIAL PRIMARY KEY);
|
--E-R模型 即E-R图 即实体-联系图
--是指提供了表示实体型 属性和联系的方法,用来描述现实世界的概念模型
--在设计阶段一般使用E-R模型进行建模power designer ,db desinger等工具
--然后才是设计数据库
--多对多时候,需要一个附加表
/*
表间关系:
一对一 一个表中的一条数据能够和另外一个表的唯一一条数据对于 人和常驻地址
一对多 一个表中的数据能够另外一个表中多条数据对于 一个班有多个学生
多对多 一个表中的一条数据能够和另外一个表的多条数据对应,反之也对应 一个学生有多个课程
处理多对多的关系,建立中间表
*/ |
.echo on
.headers on
--Name: Aaron Colclough
--File: TSQL-Lab6-2.sql
--Date: Sept 4, 2018
--1
select c.country
from customers c
union
select s.country
from suppliers s;
--2
select c.city, c.country
from customers c
union
select s.city, s.country
from suppliers s
order by country;
--3
select c.country
from cus... |
/*
################################################################################
Migration script to remove a wrong constraint created in 002
Designed for execution with Flyway database migrations tool; this should be
automatically run to completely generate the schema that is out-of-the-box
compatibile with the G... |
SELECT DISTINCT team.short_name, team.base_location, driver.first_name, driver.country_of_birth, track.circuit_country
FROM Teams team, Drivers driver, Tracks track
WHERE
(team.driver_one=driver.driver_id OR team.driver_two=driver.driver_id)
AND track.lap_recorder=driver.driver_id
AND (track.circuit_count... |
--SOURCE of data Eurostat. Culture and tourism - cities and greater cities. Available online:https://ec.europa.eu/eurostat/data/database (accessed on 10 October 2019).
create table eu_city_tour (year integer, code text, city text, indi text, value numeric);
INSERT INTO eu_city_tour (year, code, city, indi, value)
VA... |
/* Formatted on 21/07/2014 18:44:38 (QP5 v5.227.12220.39754) */
CREATE OR REPLACE FORCE VIEW MCRE_OWN.V_MCRES_WRK_CONTROPARTITE_ITF
(
ID_DPER,
COD_ABI,
COD_CONTROPARTITA,
COD_TIPO,
COD_DIVISA,
VAL_IMPORTO,
COD_FILIALE,
COD_AUTORIZZAZIONE
)
AS
SELECT -- 20121107 ... |
COPY data FROM '/data/data.csv' WITH CSV;
|
CREATE TABLE `employee` (
`employee_id` int NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`mobile` bigint DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`dept_id` int DEFAULT NULL,
`salary` int DEFAULT NULL,
`doj` datetime DEFAULT NULL,
`degree` varchar(100) DEFAULT NULL,
`address` varc... |
CREATE database biblioteca
CREATE TABLE libros (
codigo_libro int(10) primary key,
nombre_libro varchar(30) not null,
autor_libro varchar(30) not null,
tipo_de_libro varchar(30) not null,
estado_del_libro varchar(12) not null
)
CREATE UNIQUE INDEX INDICE1 ON libros (codigo_libro)
CREATE TAB... |
/* Create table tblCustomer */
CREATE TABLE tblCustomer (
CustomerID NUMBER(6),
FirstName VARCHAR2(20) NOT NULL,
LastName VARCHAR2(20) NOT NULL,
Address VARCHAR2(50) NOT NULL,
Zip CHAR(5) NOT NULL,
Phone CHAR(12) NOT NULL,
DOB DATE NOT NULL,
GENDER CHAR(1) NOT NULL
);
/* Add primary_key to the t... |
USE `PrivateSchool`;
-- Read all data fom tables
SELECT * FROM `students`;
SELECT * FROM `trainers`;
SELECT * FROM `assignments`;
SELECT * FROM `courses`;
-- Read all students per course (here: id = 1)
SELECT
*
FROM
`students`
JOIN
`students_in_courses` ON `students_in_courses`.`students_id` = ... |
create database Training
use Training
create table student(ID int, FirstName varchar(10),LastName varchar(10),Location varchar(10));
insert into student values(101,'Aishwarya','Jadhav','Solapur');
insert into student values(102,'Asmita','Jadhav','Delhi');
insert into student values(103,'Aasha','Waghmode','Mumbai... |
INSERT INTO "AUTH_USER" (ID, PASSWORD, LAST_LOGIN, IS_SUPERUSER, USERNAME, FIRST_NAME, LAST_NAME, EMAIL, IS_STAFF, IS_ACTIVE, DATE_JOINED)
VALUES (1, 'pbkdf2_sha256$36000$8i9JpNBCORum$8pCSw54e/vDhjHThh/h0X2kNjWxtfpC0BQ1liJY//kA=', '25.12.17 20:51:17,254815000', 0, 'ivan', 'Other', 'User', 'other@gmail.com', 0, 1, '25.... |
delete MOVIE_ACTOR from MOVIE_ACTOR
join ACTOR on (ACTOR.Actorid=MOVIE_ACTOR.Actorid and ACTOR.Name like 'TOM%');
|
create table MENU_INFO
(
ID bigint not null,
FOOD_ID varchar(20) null,
FOOD_NAME varchar(64) null,
FOOD_TYPE varchar(32) null,
SOURCE varchar(64) n... |
create database seguranca;
use seguranca;
create table user(
id int primary key not null auto_increment,
email varchar(30) not null,
password varchar(32) not null);
create table role(
id int primary key not null,
name varchar(30) not null
);
create table user_role(
user_id int not null,
role_id int not null,
... |
CREATE TABLE `admin` (
`Admin_id` int(1) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`Firstname` VARCHAR(225) NOT NULL,
`Lastname` VARCHAR(225) NOT NULL,
`Phone_number` VARCHAR(11) NOT NULL,
`Address` VARCHAR(200) NOT null,
`Position` VARCHAR(30) NOT NULL,
`Password` VARCHAR(200) NOT NULL,
`Date_registered` timestamp ... |
update KRIM_PRNCPL_T
set ACTV_IND = 'N'
where actv_ind = 'Y'
and prncpl_nm not in ( 'quickstart' , 'admin' , 'jtester' );
select * from KRIM_PRNCPL_T where ACTV_IND = 'Y';
update KRIM_PRNCPL_T
set ACTV_IND = 'Y'; |
/*
ESTE SCRIPT CRIA A TABELA ESTADO E INSERE TODOS ESTADOS E SEUS RESPECTIVO UF
*/
USE gastos_parlamentares_db;
-- TABELA ESTADO
DROP TABLE IF EXISTS estado;
CREATE TABLE estado (
id INT,
nome VARCHAR(255) NOT NULL,
uf VARCHAR(02) NOT NULL
);
ALTER TABLE estado MODIFY id INT AUTO_INCREMENT PRIMARY KEY;
-... |
use employees;
EXPLAIN SELECT E.emp_no, CONCAT(first_name, ' ',last_name)
FROM employees E
WHERE NOT EXISTS(
SELECT *
FROM departments D
WHERE NOT EXISTS(
SELECT *
FROM dept_emp DE
WHERE DE.dept_no=D.dept_no and E.emp_no=DE.emp_no
))
|
CREATE TABLE JRole
(
num number, --序号
RoleID varchar(10) primary key, --角色ID
RoleName varchar(50) , --角色名称
modelid varchar(50), --模块ID
departflag varchar(10), --部门管理
remark varchar (200) --备注
)
/* drop table JRole */ |
;
CREATE USER IF NOT EXISTS "USER" SALT '153caadf6c3b2e3a' HASH '9f51802a9c216da3c2bd6f2dddd776704acf2ecdc7442f4e34d978aabe2e9fd6' ADMIN;
CREATE SEQUENCE "PUBLIC"."SYSTEM_SEQUENCE_E56ECFFF_C98B_466A_B89F_ED72C3290398" START WITH 3 BELONGS_TO_TABLE;
CREATE CACHED TABLE "PUBLIC"."TESTFILES"(
"IDFI... |
-- Needs to be run from APEX SQL Workshop
-- I use it heaps as sanity check for apex emailing
begin
apex_mail.send
(p_to => 'wesleys@sage.com.au'
,p_from => 'wesleys@sage.com.au'
,p_body => 'text/html; charset=us-ascii'
,p_body_html => 'hello <b>universe</b>'
,p_subj ... |
-- 25/12/2014 - Fixing type of 'total' in orders table
ALTER TABLE `orders` CHANGE `total` `total` DECIMAL(8,2); |
CREATE TABLE STUDENT_INFO
(
SID INT UNIQUE,
STUD_NAME VARCHAR(20) NOT NULL,
STUDE_SCORE NUMERIC(5,2) DEFAULT 20
);
SELECT * FROM STUDENT_INFO;
DESCRIBE STUDENT_INFO;
ALTER TABLE STUDENT_INFO ADD PRIMARY KEY(SID);
INSERT INTO STUDENT_INFO VALUES(1,'ALEENA',180),(2,'BINU',175),
(3,'CHERIN',151),(4,'DEEN',165),(5,'ELSA'... |
create table c_article_list
(
id int not null auto_increment, -- 主键id
article_id varchar(50), -- 文章id
title varchar(100), -- 文章标题
author varchar(50), -- 作者
article_abstract text, -- 文章摘要
link varchar(500), -- 文章链接
image_link varchar(500), -- 图片链接
article_type varchar(50), ... |
--Challenge 1
select e.emp_no,e.first_name,e.last_name,t.title,t.from_date,t.to_date
into retirement_titles
from titles as t
inner join employees as e on e.emp_no=t.emp_no
where (birth_date >= '1952-01-01' and birth_date < '1955-12-31')
--where e.birth_date between '1952-01-01' and '1955-12-31'
order by e.emp_no
sel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.