text stringlengths 6 9.38M |
|---|
--База данных - Банк
--База данных включает в себя 4 вспомогательных таблиц: клиенты, работники, место, тип операции. И главной, включающей в себя информацию о каждой операции.
CREATE DATABASE bank;
GRANT ALL PRIVILEGES ON DATABASE bank TO defygee;
--//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--Создание таблицы с клиентами
CREATE TABLE clients(id INT, surname VARCHAR, name VARCHAR, patronymic VARCHAR, nationality VARCHAR, date_of_birth DATE, pass_series INT, pass_num INT, phone_number VARCHAR, salary FLOAT, note TEXT, PRIMARY KEY(id));
--Заполнение данными
INSERT INTO clients values(1,'Zvonarev','Alexey','Evgenevich','Russia','2000-08-07','4542','645231','+79534450975', 1000000.0,NULL);
INSERT INTO clients values(2,'Martinovich','Vasiliy','Alexandrovich','Ukraine','1997-02-15','4554','153835','+79556678475', 200000.0,NULL);
INSERT INTO clients values(3,'Arsak','Sergey','Evgenevich','Russia','2000-01-25','4357','895789','+79842468536', 50000.0,NULL);
INSERT INTO clients values(4,'Arilev','Oleg','Dmitrievich','Russia','1990-03-03','4754','785454','+79086425791', 100000.0,NULL);
INSERT INTO clients values(5,'Antonov','Nikita','Vasilevich','Russia','1987-11-11','4657','653354','+79764741062', 70000.0,NULL);
INSERT INTO clients values(6,'Vasilev','Alexey','Alexandrovich','Russia','1999-01-20','4864','643431','+79534459635', 521000.0,NULL);
--Вывод данных
SELECT * FROM clients;
id | surname | name | patronymic | nationality | date_of_birth | pass_series | pass_num | phone_number | salary | note
----+-------------+---------+---------------+-------------+---------------+-------------+----------+--------------+---------+------
1 | Zvonarev | Alexey | Evgenevich | Russia | 2000-08-07 | 4542 | 645231 | +79534450975 | 1000000 |
2 | Martinovich | Vasiliy | Alexandrovich | Ukraine | 1997-02-15 | 4554 | 153835 | +79556678475 | 200000 |
3 | Arsak | Sergey | Evgenevich | Russia | 2000-01-25 | 4357 | 895789 | +79842468536 | 50000 |
4 | Arilev | Oleg | Dmitrievich | Russia | 1990-03-03 | 4754 | 785454 | +79086425791 | 100000 |
5 | Antonov | Nikita | Vasilevich | Russia | 1987-11-11 | 4657 | 653354 | +79764741062 | 70000 |
6 | Vasilev | Alexey | Alexandrovich | Russia | 1999-01-20 | 4864 | 643431 | +79534459635 | 521000 |
(6 rows)
--Создание таблицы с работниками
CREATE TABLE employee(id INT, surname VARCHAR, name VARCHAR, patronymic VARCHAR, nationality VARCHAR, date_of_birth DATE, position VARCHAR,experience INT,phone_number VARCHAR,salary FLOAT,PRIMARY KEY(id));
--Заполнение данными
INSERT INTO employee values(1,'Antonov','Alexey','Alexandrovich','Russia','1988-08-07','Manager',3,'+79865645345', 30000.0);
INSERT INTO employee values(2,'Kirzhach','Oleg','Dmitrievich','Russia','1985-06-03','Consultant',1,'+79126437893', 25000.0);
INSERT INTO employee values(3,'Grupin','Sergey','Alexandrovich','Russia','1978-11-25','Manager',4,'+79097534567', 30000.0);
INSERT INTO employee values(4,'Pupin','Alexey','Dmitrievich','Russia','1993-12-11','Manager',0,'+79764893258', 30000.0);
INSERT INTO employee values(5,'Lupin','Vasiliy','Alexandrovich','Russia','1950-03-15','Manager',15,'+79875645345', 40000.0);
INSERT INTO employee values(6,'Kepkin','Anton','Vasilevich','Russia','1999-04-24','IT-Specialist',2,'+7913634543', 100000.0);
INSERT INTO employee values(7,'Petrov','Nikita','Evgenevichh','Russia','1994-08-05','Consultant',3,'+79654358907', 30000.0);
INSERT INTO employee values(8,'Vasilev','Sergey','Evgenevich','Russia','1988-09-22','Manager',6,'+79875365340', 30000.0);
--Вывод данных
SELECT * FROM employee;
id | surname | name | patronymic | nationality | date_of_birth | position | experience | phone_number | salary
----+----------+---------+---------------+-------------+---------------+---------------+------------+--------------+--------
1 | Antonov | Alexey | Alexandrovich | Russia | 1988-08-07 | Manager | 3 | +79865645345 | 30000
2 | Kirzhach | Oleg | Dmitrievich | Russia | 1985-06-03 | Consultant | 1 | +79126437893 | 25000
3 | Grupin | Sergey | Alexandrovich | Russia | 1978-11-25 | Manager | 4 | +79097534567 | 30000
4 | Pupin | Alexey | Dmitrievich | Russia | 1993-12-11 | Manager | 0 | +79764893258 | 30000
5 | Lupin | Vasiliy | Alexandrovich | Russia | 1950-03-15 | Manager | 15 | +79875645345 | 40000
6 | Kepkin | Anton | Vasilevich | Russia | 1999-04-24 | IT-Specialist | 2 | +7913634543 | 100000
7 | Petrov | Nikita | Evgenevichh | Russia | 1994-08-05 | Consultant | 3 | +79654358907 | 30000
8 | Vasilev | Sergey | Evgenevich | Russia | 1988-09-22 | Manager | 6 | +79875365340 | 30000
--Создание таблицы с местами
CREATE TABLE place(id INT, adress VARCHAR, city VARCHAR, country VARCHAR, note TEXT,PRIMARY KEY(id));
--Заполнение данными
INSERT INTO place VALUES(1, '24 Avdeeva street','Moscow','Russia',NULL);
INSERT INTO place VALUES(2, '24 Pushkina street','Sochi','Russia',NULL);
INSERT INTO place VALUES(3, '774 Westminster Avenue','Brooklyn','USA',NULL);
--Вывод данных
SELECT * FROM place;
id | adress | city | country | note
----+------------------------+----------+---------+------
1 | 24 Avdeeva street | Moscow | Russia |
2 | 24 Pushkina street | Sochi | Russia |
3 | 774 Westminster Avenue | Brooklyn | USA |
(3 rows)
--Создание таблицы с типами операций
CREATE TABLE type_of_operation(id INT, name VARCHAR, percent float, min_months INT, min_sum INT, template tsvector,PRIMARY KEY(id));
--Заполнение данными
INSERT INTO type_of_operation VALUES(1, 'Loan "THE BEST"', 15.4, 84, 10000000, NULL);
INSERT INTO type_of_operation VALUES(2, 'Loan "Strawberry"', 21, 36, 1000000, NULL);
INSERT INTO type_of_operation VALUES(3, 'Loan "Malis"', 22, 36, 500000, NULL);
INSERT INTO type_of_operation VALUES(4, 'Loan "Crawnberry"', 18, 60, 5000000, NULL);
INSERT INTO type_of_operation VALUES(5, 'Loan "Rose"', 24.3, 36, 100000, NULL);
INSERT INTO type_of_operation VALUES(6, 'Loan "Boost"', 27.1, 12, 50000, NULL);
INSERT INTO type_of_operation VALUES(7, 'Contribution "Record"', 5.4, 12, 10000, NULL);
INSERT INTO type_of_operation VALUES(8, 'Contribution "Maximum"', 6.2, 36, 250000, NULL);
INSERT INTO type_of_operation VALUES(9, 'Contribution "Nuts"', 5, 12, 100000, NULL);
INSERT INTO type_of_operation VALUES(10, 'Contribution "Crew"', 7, 48, 500000, NULL);
INSERT INTO type_of_operation VALUES(11, 'Contribution "Money"', 7.1, 60, 1000000, NULL);
INSERT INTO type_of_operation VALUES(12, 'Contribution "Beautiful Life"', 6, 24, 200000, NULL);
--Создание основной таблицы
CREATE TABLE operation(id INT,transID INT,clientID INT, employeeID INT,placeID INT,sum_of_op FLOAT,date_of_op DATE,end_of_op DATE,note TEXT,accepted boolean, PRIMARY KEY(id),FOREIGN KEY(transID) REFERENCES type_of_operation(id),FOREIGN KEY(clientID) REFERENCES clients(id),FOREIGN KEY(employeeID) REFERENCES employee(id),FOREIGN KEY(placeID) REFERENCES place(id));
--Заполнение данными
INSERT INTO operation values(1,3,2,1,1,200000,'2018-11-22','2019-11-22', NULL, true);
INSERT INTO operation values(2,2,1,2,3,50000000,'2018-11-22','2021-11-22', NULL, false);
INSERT INTO operation values(3,4,4,3,3,40000,'2018-11-22','2019-11-22', NULL, true);
INSERT INTO operation values(4,1,3,4,2,7000000,'2018-11-22','2022-11-22', NULL, true);
--//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--Вывод ФИО и суммы операции
SELECT surname, name, patronymic, sum_of_op FROM operation,clients GROUP BY name,sum_of_op,clients.id,operation.clientID HAVING clients.id=operation.clientID ORDER BY surname,name,patronymic;
surname | name | patronymic | sum_of_op
-------------+---------+---------------+-----------
Arilev | Oleg | Dmitrievich | 40000
Arsak | Sergey | Evgenevich | 7000000
Martinovich | Vasiliy | Alexandrovich | 200000
Zvonarev | Alexey | Evgenevich | 50000000
(4 rows)
--Вывод ФИО и места проведения операции
SELECT surname, name, patronymic,place FROM operation,clients,place GROUP BY name,operation.placeID,operation.clientID,surname,patronymic,place,clients.id,place.id HAVING (clients.id=operation.clientID) AND (place.id=operation.placeID) ORDER BY place;
surname | name | patronymic | place
-------------+---------+---------------+--------------------------------------------
Martinovich | Vasiliy | Alexandrovich | (1,"24 Avdeeva street",Moscow,Russia,)
Arsak | Sergey | Evgenevich | (2,"24 Pushkina street",Sochi,Russia,)
Zvonarev | Alexey | Evgenevich | (3,"774 Westminster Avenue",Brooklyn,USA,)
Arilev | Oleg | Dmitrievich | (3,"774 Westminster Avenue",Brooklyn,USA,)
(4 rows)
--Вывод клиентов с фамилией начинающейся с буквы А
SELECT surname, name, patronymic FROM clients WHERE surname LIKE 'A%';
surname | name | patronymic
---------+--------+-------------
Arsak | Sergey | Evgenevich
Arilev | Oleg | Dmitrievich
Antonov | Nikita | Vasilevich
(3 rows)
--Вывод средней суммы всех операций
SELECT avg(sum_of_op) as avg_sum FROM operation;
avg_sum
----------
14310000
(1 row)
--Вывод операций, которые закончатся с 2020-01-01 до 2025-01-01
SELECT id,end_of_op FROM operation WHERE end_of_op BETWEEN '2020-01-01' AND '2025-01-01' ORDER BY end_of_op ASC;
id | end_of_op
----+------------
2 | 2021-11-22
4 | 2022-11-22
(2 rows)
--Вывод общей суммы операций, которые закончатся с 2020-01-01 до 2025-01-01
WITH tmp_table AS (SELECT id,end_of_op,sum_of_op FROM operation WHERE end_of_op BETWEEN '2020-01-01' AND '2025-01-01') SELECT SUM(sum_of_op) as avg_sum_2015_2017_ FROM tmp_table;
avg_sum_2015_2017_
--------------------
57000000
(1 row)
--Вывод ФИО и суммы операции (клиенты, сумма операций которых больше 200000, но меньше 10000000)
SELECT surname, name, patronymic, sum_of_op FROM clients,operation WHERE (clients.id=operation.clientID) AND (sum_of_op BETWEEN 200000 AND 10000000);
surname | name | patronymic | sum_of_op
-------------+---------+---------------+-----------
Martinovich | Vasiliy | Alexandrovich | 200000
Arsak | Sergey | Evgenevich | 7000000
(2 rows)
--Кол-во людей, чьи заявки были одобрены
SELECT COUNT(clientID) FROM operation WHERE accepted = true;
count
-------
3
(1 row)
--Кол-во проведенных операций каждым работником(который проводил хотя бы одну операцию)
SELECT surname, name, patronymic, COUNT(operation.id) OVER (PARTITION BY employeeID) FROM operation,employee WHERE employee.id=operation.employeeid GROUP BY operation.id,surname, name, patronymic,operation.employeeid,employee.id;
surname | name | patronymic | count
----------+--------+---------------+-------
Antonov | Alexey | Alexandrovich | 1
Kirzhach | Oleg | Dmitrievich | 1
Grupin | Sergey | Alexandrovich | 1
Pupin | Alexey | Dmitrievich | 1
(4 rows)
--ФИО и телефон людей, которым было отказано в операции(чтобы позвонить и оповестить)
SELECT surname, name, patronymic,phone_number,accepted FROM operation,clients WHERE (clients.id=operation.clientID) AND (accepted = false);
surname | name | patronymic | phone_number | accepted
----------+--------+------------+--------------+----------
Zvonarev | Alexey | Evgenevich | +79534450975 | f
(1 row)
|
DROP TABLE IF EXISTS organisations CASCADE;
CREATE TABLE organisations (
id SERIAL PRIMARY KEY NOT NULL,
name VARCHAR(255) NOT NULL
);
|
-- phpMyAdmin SQL Dump
-- version 4.1.6
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 16, 2016 at 08:32 AM
-- Server version: 5.6.16
-- PHP Version: 5.5.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `profile`
--
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`full_name` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`user_name` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`avatar` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`phone` int(40) NOT NULL,
`password` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`level` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=18 ;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`id`, `full_name`, `user_name`, `avatar`, `email`, `phone`, `password`, `level`) VALUES
(3, 'Khiem ngu si', 'khiem', 'cho.png', 'gaconchaylu@gmail.com', 1664567, '40bd001563085fc35165329ea1ff5c5ecbdbbeef', 2),
(4, 'Khiem sida', 'banthan', 'cho.png', '12345678@gmail.com', 12345454, 'd2f75e8204fedf2eacd261e2461b2964e3bfd5be', 2),
(5, 'Duong Thu Van Anh', 'Mon beo', 'cho.png', 'beo@gmail.com', 166862004, '7c222fb2927d828af22f592134e8932480637c0d', 1),
(6, 'Tran Thi Phuong Hai', 'PuHa', '13435607_1070733649659028_1928836069_n.jpg', 'thieu@gmail.com', 987654, '49224cbb8961faced56065bca492e895415a1c51', 1),
(7, 'Trinh The Hoang', 'Hoang beo', 'cho.png', 'hoangbeo@gmail.com', 98463754, '', 3),
(10, 'Nguyen Cong Hoan', 'ban than', 'cho.png', 'hoan @gmail.com', 9837453, 'a7d579ba76398070eae654c30ff153a4c273272a', 1),
(13, 'Tran Duc Nhuan', 'nhuan', 'cho.png', 'nhuantd@gmail.com', 123456, '7110eda4d09e062aa5e4a390b0a572ac0d2c0220', 3),
(14, 'Mai Hoang Anh', 'anh', '13435607_1070733649659028_1928836069_n.jpg', 'anhhoang@gmail.com', 1234, '7110eda4d09e062aa5e4a390b0a572ac0d2c0220', 2),
(16, 'Doan Hoa Khiem', 'khiemsida', '13435607_1070733649659028_1928836069_n.jpg', 'khiem@gmail.com', 98765, '6df73cc169278dd6daab5fe7d6cacb1fed537131', 3),
(17, 'Doan Hoa Khiem', 'khiemsida', 'cho.png', 'khiem@gmail.com', 1111, '011c945f30ce2cbafc452f39840f025693339c42', 2);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
-- ----------------------------------------------------------------------------
--
-- Event store tables schema.
--
-- ----------------------------------------------------------------------------
CREATE TABLE "projector_state" (
"id" varchar(500) NOT NULL,
"created_at" timestamp NOT NULL DEFAULT now(),
"updated_at" timestamp NOT NULL DEFAULT now(),
"position" bigint NOT NULL DEFAULT 0,
"is_locked" bool NOT NULL DEFAULT false,
"is_error" bool NOT NULL DEFAULT false,
"error_code" bigint NOT NULL DEFAULT 0,
"error_message" text DEFAULT null,
"error_trace" text DEFAULT null,
PRIMARY KEY("id")
);
|
drop database if exists wallethub;
create database if not exists wallethub;
use wallethub;
create table votes ( name char(10), votes int );
insert into votes values
('smith',10), ('jones',15), ('white',20), ('black',40), ('green',50), ('brown',20);
set @rankorder=0;
select @rankorder:=@rankorder+1 as rankorder, name, votes from votes order by votes desc, name asc; |
DROP DATABASE IF EXISTS vk2;
CREATE DATABASE vk2;
USE vk2;
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id SERIAL PRIMARY KEY, -- SERIAL = BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE
firstname VARCHAR(50),
lastname VARCHAR(50) COMMENT 'Фамиль', -- COMMENT на случай, если имя неочевидное
email VARCHAR(120) UNIQUE,
phone BIGINT,
INDEX users_phone_idx(phone), -- как выбирать индексы?
INDEX users_firstname_lastname_idx(firstname, lastname)
);
INSERT INTO `users` VALUES
('5', 'Reuben', 'Niewnew', 'obc1@oft45.net', '89261111111'),
('6', 'Reuben', 'Niewnew', 'obc2@oft45.net', '89262222222'),
('7', 'Reuben', 'Niewnew', 'obc3@oft45.net', '89263333333'),
('8', 'Reuben', 'Niewnew', 'obc4@oft45.net', '89264444444'); |
CREATE TABLE GameRankings (
GameRankingId UNIQUEIDENTIFIER NOT NULL CONSTRAINT
DF_GameRanking_Id DEFAULT NEWSEQUENTIALID(),
GameConsoleId UNIQUEIDENTIFIER NOT NULL,
GameId UNIQUEIDENTIFIER NOT NULL,
GameRanking INT,
GameRankingName VARCHAR(255),
CreatedDate DATETIME2,
CreatedBy VARCHAR(255),
UpdatedDate DATETIME2,
UpdatedBy VARCHAR(255),
CONSTRAINT PK_GameRanking
PRIMARY KEY (GameRankingId),
CONSTRAINT FK_GameRankings_GameConsoleId
FOREIGN KEY (GameConsoleId) REFERENCES GameConsoles(GameConsoleId)
);
|
SELECT
p.player_id,
name,
pl.team_id as team_id,
team_name,
-- count(*) as game_count,
sum(runs)/sum(inning)*5 as era,
(sum(hit)+sum(four_ball))/sum(inning) as WHIP,
sum(strike_out)/sum(inning)*5 as strike_avg,
sum(inning) as inning,
sum(pa) as pa,
sum(hit) as hit,
sum(homerun) as homerun,
sum(four_ball) as four_ball,
sum(strike_out) as strike_out,
sum(runs) as runs,
sum(complete) as complete,
sum(shutout) as shutout,
sum(win) as win,
sum(lose) as lose,
sum(save) as save,
year_count as year
FROM
pitching p
inner join GAME g on g.game_id=p.game_id
inner join PLAYER pl on p.player_id=pl.id
inner join TEAM t on t.team_id=pl.team_id
inner join (
select
player_id,
count(*) as year_count,
max(year(game_date))as last_join_year
from
(select
player_id,
max(game_date)as game_date,
team_id
from
pitching p
INNER JOIN GAME g on p.game_id=g.game_id
group by player_id,year(game_date)
)b2
group by player_id
having year_count>=2 and last_join_year>=/*lastYear*/
)b3
on b3.player_id=p.PLAYER_ID
group by team_id,player_id |
--1. List the following details of each employee: employee number, last name, first name, gender, and salary.
SELECT
employees.emp_no,
employees.last_name,
employees.first_name,
employees.gender,
salaries.salary
FROM employees
JOIN salaries
ON employees.emp_no = salaries.emp_no
--2. List employees who were hired in 1986.
SELECT *
FROM employees
WHERE date_part('year', hire_date) = 1986
--ORDER BY --date/emp_no etc for readability, not mandatory.
--3. List the manager of each department with the following information: department number, department name, the manager's employee number, last name, first name, and start and end employment dates.
SELECT
departments.dept_no,
departments.dept_name,
dept_managers.emp_no,
employees.last_name,
employees.first_name,
dept_managers.from_date,
dept_managers.to_date
FROM employees
INNER JOIN dept_managers ON dept_managers.emp_no = employees.emp_no --Match Dept Manager ID to employee ID
INNER JOIN departments ON departments.dept_no = dept_managers.dept_no -- Match Dept Number to Dept Manager
--INNER JOIN
--4. List the department of each employee with the following information: employee number, last name, first name, and department name.
SELECT
employees.emp_no,
employees.last_name,
employees.first_name,
departments.dept_name
FROM employees
INNER JOIN dept_employees ON dept_employees.emp_no = employees.emp_no --Match Dept/Employees ID to employee ID
INNER JOIN departments ON departments.dept_no = dept_employees.dept_no -- Match Dept Number to Dept Name
--5.List all employees whose first name is "Hercules" and last names begin with "B."
SELECT *
FROM employees
WHERE employees.first_name = 'Hercules' and employees.last_name LIKE 'B%'
--6.List all employees in the Sales department, including their employee number, last name, first name, and department name.
SELECT
employees.emp_no,
employees.last_name,
employees.first_name,
departments.dept_name
FROM employees
INNER JOIN dept_employees ON dept_employees.emp_no = employees.emp_no --Match Dept/Employees ID to employee ID
INNER JOIN departments ON departments.dept_no = dept_employees.dept_no -- Match Dept Number to Dept Name
WHERE departments.dept_name ='Sales'
--7.List all employees in the Sales and Development departments, including their employee number, last name, first name, and department name.
SELECT
employees.emp_no,
employees.last_name,
employees.first_name,
departments.dept_name
FROM employees
INNER JOIN dept_employees ON dept_employees.emp_no = employees.emp_no --Match Dept/Employees ID to employee ID
INNER JOIN departments ON departments.dept_no = dept_employees.dept_no -- Match Dept Number to Dept Name
WHERE departments.dept_name ='Sales' OR departments.dept_name = 'Development'
--8. In descending order, list the frequency count of employee last names, i.e., how many employees share each last name.
SELECT
employees.last_name,
COUNT(employees.last_name)
FROM employees
GROUP BY employees.last_name
ORDER BY COUNT(employees.last_name) DESC
|
/*
Navicat MySQL Data Transfer
Source Server : local
Source Server Version : 100116
Source Host : localhost:3306
Source Database : bd_sportingcristal
Target Server Type : MYSQL
Target Server Version : 100116
File Encoding : 65001
Date: 2017-06-09 23:58:35
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for arbitros
-- ----------------------------
DROP TABLE IF EXISTS `arbitros`;
CREATE TABLE `arbitros` (
`idarbitro` int(11) NOT NULL AUTO_INCREMENT,
`nombre` varchar(45) DEFAULT NULL,
`apellido` varchar(45) DEFAULT NULL,
`puesto` varchar(45) DEFAULT NULL,
PRIMARY KEY (`idarbitro`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of arbitros
-- ----------------------------
-- ----------------------------
-- Table structure for arbitrosxpartido
-- ----------------------------
DROP TABLE IF EXISTS `arbitrosxpartido`;
CREATE TABLE `arbitrosxpartido` (
`arbitros_idarbitro` int(11) NOT NULL,
`partido_idpartido` int(11) NOT NULL,
PRIMARY KEY (`arbitros_idarbitro`,`partido_idpartido`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of arbitrosxpartido
-- ----------------------------
-- ----------------------------
-- Table structure for equipo
-- ----------------------------
DROP TABLE IF EXISTS `equipo`;
CREATE TABLE `equipo` (
`idequipo` int(11) NOT NULL AUTO_INCREMENT,
`nombre` varchar(45) DEFAULT NULL,
`ciudad` varchar(45) DEFAULT NULL,
`anio_fundacion` varchar(45) DEFAULT NULL,
`estado` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`idequipo`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of equipo
-- ----------------------------
INSERT INTO `equipo` VALUES ('1', 'Sporting Cristal', 'Lima', '1955', '1');
INSERT INTO `equipo` VALUES ('2', 'Universitario', 'Lima', '1924', '1');
INSERT INTO `equipo` VALUES ('3', 'Melgar', 'Arequipa', '1915', '1');
INSERT INTO `equipo` VALUES ('4', 'Sport Huancayo', 'Huancayo', '2007', '1');
INSERT INTO `equipo` VALUES ('5', 'Alianza Lima', 'Lima', '1901', '1');
INSERT INTO `equipo` VALUES ('6', 'San Martin', 'Lima', '2004', '1');
INSERT INTO `equipo` VALUES ('7', 'Real Garcilazo', 'Cuzco', '2007', '1');
INSERT INTO `equipo` VALUES ('8', 'Juan Aurich', 'Chiclayo', '1924', '1');
INSERT INTO `equipo` VALUES ('9', 'Deportivo Municipal', 'Lima', '1935', '1');
INSERT INTO `equipo` VALUES ('10', 'Academia Cantolao', 'Callao', '1981', '1');
INSERT INTO `equipo` VALUES ('11', 'Ayacucho FC', 'Ayacucho', '1987', '1');
-- ----------------------------
-- Table structure for equipoxpartido
-- ----------------------------
DROP TABLE IF EXISTS `equipoxpartido`;
CREATE TABLE `equipoxpartido` (
`equipo_idequipo` int(11) NOT NULL,
`partido_idpartido` int(11) NOT NULL,
PRIMARY KEY (`equipo_idequipo`,`partido_idpartido`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of equipoxpartido
-- ----------------------------
-- ----------------------------
-- Table structure for estadio
-- ----------------------------
DROP TABLE IF EXISTS `estadio`;
CREATE TABLE `estadio` (
`idestadio` int(11) NOT NULL AUTO_INCREMENT,
`nombre` varchar(45) DEFAULT NULL,
`aforo` varchar(45) DEFAULT NULL,
`ubicacion` varchar(45) DEFAULT NULL,
PRIMARY KEY (`idestadio`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of estadio
-- ----------------------------
-- ----------------------------
-- Table structure for goles
-- ----------------------------
DROP TABLE IF EXISTS `goles`;
CREATE TABLE `goles` (
`idgoles` int(11) NOT NULL AUTO_INCREMENT,
`descripcion_gol` varchar(45) DEFAULT NULL,
`minuto_gol` varchar(45) DEFAULT NULL,
`partido_idpartido` int(11) NOT NULL,
`jugadores_idjugadores` int(11) NOT NULL,
PRIMARY KEY (`idgoles`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of goles
-- ----------------------------
-- ----------------------------
-- Table structure for jugadores
-- ----------------------------
DROP TABLE IF EXISTS `jugadores`;
CREATE TABLE `jugadores` (
`idjugadores` int(11) NOT NULL AUTO_INCREMENT,
`nombre` varchar(45) DEFAULT NULL,
`fecha_nacimiento` varchar(45) DEFAULT NULL,
`nacionalidad` varchar(45) DEFAULT NULL,
`posicion` varchar(45) DEFAULT NULL,
`equipo_idequipo` int(11) NOT NULL,
PRIMARY KEY (`idjugadores`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of jugadores
-- ----------------------------
INSERT INTO `jugadores` VALUES ('1', 'Mauricio Viana', '12/06/1992', 'Chile', 'Arquero', '111');
INSERT INTO `jugadores` VALUES ('2', 'Carlos Lobaton', '30/02/1975', 'Peru', 'Mediocampista', '222');
INSERT INTO `jugadores` VALUES ('3', 'Pedro Aquino', '02/06/1994', 'Peru', 'Mediocampista', '333');
INSERT INTO `jugadores` VALUES ('4', 'Jorge Cazulo', '01/05/1986', 'Peru/Uruguay', 'Mediocampista', '444');
INSERT INTO `jugadores` VALUES ('5', 'Josepmir Ballón', '24/04/1989', 'Peru', 'Mediocampista', '555');
-- ----------------------------
-- Table structure for lesion
-- ----------------------------
DROP TABLE IF EXISTS `lesion`;
CREATE TABLE `lesion` (
`idlesion` int(11) NOT NULL AUTO_INCREMENT,
`tipo_lesion` varchar(45) DEFAULT NULL,
`duracion` varchar(45) DEFAULT NULL,
`jugadores_idjugadores` int(11) NOT NULL,
PRIMARY KEY (`idlesion`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of lesion
-- ----------------------------
-- ----------------------------
-- Table structure for partido
-- ----------------------------
DROP TABLE IF EXISTS `partido`;
CREATE TABLE `partido` (
`idpartido` int(11) NOT NULL AUTO_INCREMENT,
`lugar` varchar(45) DEFAULT NULL,
`fecha` varchar(45) DEFAULT NULL,
`hora` varchar(45) DEFAULT NULL,
`resultado` varchar(45) DEFAULT NULL,
`estadio_idestadio` int(11) NOT NULL,
PRIMARY KEY (`idpartido`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of partido
-- ----------------------------
-- ----------------------------
-- Table structure for suspendido
-- ----------------------------
DROP TABLE IF EXISTS `suspendido`;
CREATE TABLE `suspendido` (
`idsuspendido` int(11) NOT NULL AUTO_INCREMENT,
`amarilla` varchar(45) DEFAULT NULL,
`roja` varchar(45) DEFAULT NULL,
`jugadores_idjugadores` int(11) NOT NULL,
PRIMARY KEY (`idsuspendido`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of suspendido
-- ----------------------------
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`iduser` int(11) NOT NULL,
`usuario` varchar(45) DEFAULT NULL,
`contrasena` varchar(45) DEFAULT NULL,
PRIMARY KEY (`iduser`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES ('1', 'joel', 'c000ccf225950aac2a082a59ac5e57ff');
SET FOREIGN_KEY_CHECKS=1;
|
CREATE TABLE [geo].[Ciudades] (
[Id] INT NOT NULL,
[Id_Departamento] INT NOT NULL,
[Codigo] VARCHAR (10) NOT NULL,
[Nombre] VARCHAR (50) NOT NULL,
[Longitud] DECIMAL (18, 15) NULL,
[Latitud] DECIMAL (18, 15) NULL,
[Ordinal] INT NOT NULL,
[Activo] BIT NOT NULL,
[Fecha_Actualizacion] DATETIME2 (0) NOT NULL,
[Usuario_Actualizacion] VARCHAR (50) NOT NULL,
CONSTRAINT [PK_Ciudades] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_Ciudades_Departamentos] FOREIGN KEY ([Id_Departamento]) REFERENCES [geo].[Departamentos] ([Id]),
CONSTRAINT [UK_Ciudades_01_Nombre] UNIQUE NONCLUSTERED ([Id_Departamento] ASC, [Nombre] ASC)
);
|
/*
SQLite Syntax
Schema:
Movie ( mID, title, year, director )
English: There is a movie with ID number mID, a title, a release year, and a director.
Reviewer ( rID, name )
English: The reviewer with ID number rID has a certain name.
Rating ( rID, mID, stars, ratingDate )
English: The reviewer rID gave the movie mID a number of stars rating (1-5) on a certain ratingDate.
*/
/*
Q1:
Find the titles of all movies directed by Steven Spielberg.
*/
SELECT title
FROM Movie
WHERE director = "Steven Spielberg"
/*
Q2:
Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order.
*/
SELECT distinct year
FROM Movie join Rating
on Rating.mID = Movie.mID
WHERE Rating.stars >= 4
ORDER BY year
/*
Q3:
Find the titles of all movies that have no ratings.
*/
SELECT title
FROM Movie
WHERE mID not in (SELECT mID
FROM Rating)
/*
Q4:
Some reviewers didn't provide a date with their rating. Find the names of all reviewers who have ratings with a NULL
value for the date.
*/
SELECT name
FROM Reviewer join Rating
on Rating.rID = Reviewer.rID
WHERE ratingDate is NULL
/*
Q5:
Write a query to return the ratings data in a more readable format: reviewer name, movie title, stars, and ratingDate.
Also, sort the data, first by reviewer name, then by movie title, and lastly by number of stars.
*/
Select name, title, stars, ratingDate
FROM Movie join Rating on
Rating.mID = Movie.mID
join Reviewer on
Reviewer.rID = Rating.rID
Order by name,title,stars
/*
Q6:
For all cases where the same reviewer rated the same movie twice and gave it a higher rating the second time,
return the reviewer's name and the title of the movie.
*/
Select name, title
FROM Movie join Rating on
Rating.mID = Movie.mID
join Reviewer on
Reviewer.rID = Rating.rID
WHERE Reviewer.rID in (SELECT rID --Separates based on 2 ratings only
FROM Rating
GROUP BY rID
HAVING count(rID) = 2)
AND Rating.stars > (SELECT stars --Makes sure the 2nd value is higher, might need to separate from rID
FROM Rating)
AND Rating.mID not in (SELECT mID --Removes entries with more than 2 movies(pretty sure this only clears the test case)
FROM Rating
GROUP BY mID
HAVING count(mID) = 2)
/*
Q7:
For each movie that has at least one rating, find the highest number of stars that movie received. Return the
movie title and number of stars. Sort by movie title.
*/
SELECT title, max(stars)
FROM Movie M join Rating R on
R.mID = M.mID
WHERE M.mID in (SELECT mID
FROM Rating)
GROUP BY title
ORDER BY title
/*
Q8:
For each movie, return the title and the 'rating spread', that is, the difference between highest and lowest
ratings given to that movie. Sort by rating spread from highest to lowest, then by movie title.
*/
SELECT title, max(stars) - min(stars) as spread
FROM Movie M join Rating R on
R.mID = M.mID
WHERE M.mID in (SELECT mID
FROM Rating)
GROUP BY title
ORDER BY spread desc
/*
Q9:
Find the difference between the average rating of movies released before 1980 and the average rating of movies
released after 1980. (Make sure to calculate the average rating for each movie, then the average of those averages
for movies before 1980 and movies after. Don't just calculate the overall average rating before and after 1980.)
*/
SELECT avg(aver1) - avg(aver2)
FROM (SELECT title, year, avg(stars) as aver1
FROM Movie join Rating on
Movie.mID = Rating.mID
GROUP BY title
Having year < 1980) m1,
(SELECT title, year, avg(stars) as aver2
FROM Movie join Rating on
Movie.mID = Rating.mID
GROUP BY title
Having year > 1980) m2 |
/* Long names of days, starting with 0 = Sunday
* as per the Sqlite strftime function. */
CREATE TABLE v1_DimDay
( DayId INTEGER PRIMARY KEY
, DayName TEXT NOT NULL
, UNIQUE(DayName));
CREATE TABLE v1_User
( UserId INTEGER PRIMARY KEY
, UserName TEXT NOT NULL
, UserPersonId INTEGER NOT NULL
, PasswordHash TEXT NOT NULL
, PasswordSalt TEXT NOT NULL
, RoleNative TEXT NOT NULL
, UNIQUE(UserName)
, FOREIGN KEY(UserPersonId) REFERENCES v1_Person(PersonId));
CREATE TABLE v1_Session
( SessionId INTEGER PRIMARY KEY
, UserId INTEGER NOT NULL
, Hash TEXT NOT NULL
, RoleNative TEXT NOT NULL
, RoleActive TEXT NOT NULL
, StartTime DATETIME NOT NULL
, EndTime DATETIME
, UNIQUE(UserId, Hash));
/* A person known to the organization. */
CREATE TABLE v1_Person
( PersonId INTEGER PRIMARY KEY
, MemberId INTEGER
, PreferredName TEXT
, FirstName TEXT NOT NULL
, FamilyName TEXT
, DateOfBirth DATE
, PhoneMobile TEXT
, PhoneFixed TEXT
, Email TEXT
, DojoHome TEXT
, MembershipLevel TEXT
, MembershipRenewal DATE
, EmergencyName1 TEXT
, EmergencyPhone1 TEXT
, EmergencyName2 TEXT
, EmergencyPhone2 TEXT);
/* Person device registration code can be used by a person to register
* their device with the system. Registering sets a cookie in their
* device that they can then use to register attendance to classes.
*
* The code is used to generate both the registration page that the
* person sees, as well as the contents of the cookie in their device.
*
* If a registration code is being misused then the database admin
* can set the 'active' field to '0' / false to disable it.
*
* The next time the person dev link page is visited on the site
* a new code will be generated.
*/
CREATE TABLE v1_PersonDeviceRegCode
( Id INTEGER PRIMARY KEY
, TimeCreated DATETIME NOT NULL
, PersonId INTEGER NOT NULL
, Content STRING NOT NULL
, Active INTEGER CHECK (Active IN (0, 1))
, FOREIGN KEY(PersonId) REFERENCES v1_Person(PersonId));
/* Possible membership levels that a person can have with
* the organization. */
CREATE TABLE v1_PersonMembershipLevel
( SortOrder INTEGER
, Name STRING PRIMARY KEY);
/* An event that people can attend.
* The event may either be an instance of a reoccuring class,
* or a one-off class created separately.
*/
CREATE TABLE v1_Event
( EventId INTEGER PRIMARY KEY
, CreatedBy INTEGER NOT NULL
, Type STRING
, Location STRING
, Time DATETIME
, FOREIGN KEY(CreatedBy) REFERENCES v1_User(UserId));
CREATE TABLE v1_EventType
( SortOrder Integer
, Name STRING PRIMARY KEY);
CREATE TABLE v1_Attendance
( PersonId INTEGER
, EventId INTEGER
, PRIMARY KEY(PersonId, EventId)
, FOREIGN KEY(PersonId) REFERENCES v1_Person(PersonId)
, FOREIGN KEY(EventId) REFERENCES v1_Event(EventId));
/* A reocurring weekly class, which can be used as a template
* to create a new event. */
CREATE TABLE v1_Class
( ClassId INTEGER PRIMARY KEY
, OwnerUserName STRING NOT NULL
, Type STRING NOT NULL
, Location STRING NOT NULL
, Day STRING NOT NULL
, TimeStart TIME NOT NULL
, TimeEnd TIME
, DateFirst DATE NOT NULL
, DateFinal DATE
, FOREIGN KEY(OwnerUserName) REFERENCES v1_User(Name));
/* Additional adminstrator for a reoccuring class that manages
* the attendance records, but is not the primary class owner.
*/
CREATE TABLE v1_ClassAdmin
( ClassId INTEGER NOT NULL
, AdminUserName STRING NOT NULL
, PRIMARY KEY (ClassId, AdminUserName)
, FOREIGN KEY(ClassId) REFERENCES v1_Class(ClassId)
, FOREIGN KEY(AdminUserName) REFERENCES v1_User(UserName));
/* Class device registration code can be used by a person to register
* their attendance for the class.
*
* The code is used to generate the QR code used to register for it.
*
* If a registration code is being misused then the database admin
* can set the 'active' field to '0' / false to disable it.
*
* The next time the class dev link page is visited on the site
* a new code will be generated.
*/
CREATE TABLE v1_ClassDeviceRegCode
( Id INTEGER PRIMARY KEY
, TimeCreated DATETIME NOT NULL
, ClassId INTEGER NOT NULL
, Content STRING NOT NULL
, Active INTEGER CHECK (Active IN (0, 1))
, FOREIGN KEY(ClassId) REFERENCES v1_Class(ClassId));
/* Dojo names. */
CREATE TABLE v1_Dojo
( Name STRING PRIMARY KEY);
|
/*
PROCEDURES DO BANCO DE DADOS GOODEYES
**ALTERAR************************************************************************
*/
/* -- LOGIN*/
DELIMITER $$
drop procedure if exists pa_alterarLogin $$
create Procedure pa_alterarLogin (
$email varchar (60),
$senha varchar (8),
$nivel_acesso int
)
main: begin
update tbLogin
set senha = $senha, nivel_acesso = $nivel_acesso
where email = $email;
end$$
DELIMITER ;
call pa_alterarLogin ('leticia.vieira@outlook.com', '12345678', 2);
/* -- CLIENTE*/
DELIMITER $$
drop procedure if exists pa_alterarCliente $$ -- se existir essa procedure ele vai excluir
create Procedure pa_alterarCliente (
$cd_cliente int,
$email varchar (50),
$nome varchar (30),
$sobrenome varchar(50),
$no_cpf varchar (14),
$no_tel varchar (14),
$no_cel varchar (15),
$dt_nascimento varchar (10),
$nm_rua varchar (50),
$no_rua varchar (5),
$no_cep varchar (9),
$bairro varchar (50),
$cidade varchar (50),
$estado varchar (50),
$sg_uf varchar (2),
$complemento varchar (30)
)
main: begin
update tbCliente
set
nome = $nome,
sobrenome = $sobrenome,
no_cpf = $no_cpf,
no_tel = $no_tel,
no_cel = $no_cel,
dt_nascimento = $dt_nascimento,
nm_rua = $nm_rua,
no_rua = $no_rua,
no_cep = $no_cep,
bairro = $bairro,
cidade = $cidade,
estado = $estado,
sg_uf = $sg_uf,
complemento = $complemento
where cd_cliente = $cd_cliente;
end$$
DELIMITER ;
-- call pa_alterarCliente(1, 'ana.silva@outlook.com','Ana', 'Silva', '522.171.988-02', '(11)3947-5213', '(11)96554-2536', '02/06/1990', 'Rua 2', '45', '02990-270', 'Jardim Amélia','Pirapora', 'São Paulo', 'SP', 'apt A');
/* -- RECEITA*/
DELIMITER $$
drop procedure if exists pa_alterarReceita $$
create Procedure pa_alterarReceita (
$cd_receita int,
$cd_cliente int,
$olho_direito varchar (40),
$olho_esquerdo varchar (40),
$distancia_pupilar varchar (10),
$nm_oftalmo varchar (50),
$sobrenome_oftalmo varchar(50),
$dt_receita varchar(10),
$dt_validade varchar(10),
$observacao varchar (255)
)
main: begin
update tbReceita
set cd_cliente = $cd_cliente,
olho_direito = $olho_direito,
olho_esquerdo = $olho_esquerdo,
distancia_pupilar = $distancia_pupilar,
nm_oftalmo = $nm_oftalmo,
sobrenome_oftalmo = $sobrenome_oftalmo,
dt_receita = $dt_receita,
dt_validade = $dt_validade,
observacao= $observacao
where cd_receita = $cd_receita;
end $$
DELIMITER ;
call pa_alterarReceita (1,1,'+1,25 -1,00 180° +1', '+1,50 -1,00 180° +1', '10mm','Luzia', 'Matos', '15/04/2018', '15/05/2018', 'Lente transitions');
/* -- FUNCIONÁRIO*/
DELIMITER $$
drop procedure if exists pa_alterarFuncionario $$
create Procedure pa_alterarFuncionario (
$cd_funcionario int,
$email varchar(60),
$nome varchar(30),
$sobrenome varchar(50),
$no_cpf varchar(14),
$cargo varchar(30),
$no_tel varchar(14),
$no_cel varchar(15),
$dt_nascimento varchar(10),
$nm_rua varchar(50),
$no_rua varchar(5),
$no_cep varchar(9),
$bairro varchar(50),
$cidade varchar(50),
$estado varchar(50),
$sg_uf varchar(2),
$complemento varchar(30)
)
main: begin
update tbFuncionario
set
nome = $nome,
sobrenome = $sobrenome,
no_cpf = $no_cpf,
cargo = $cargo,
no_tel = $no_tel,
no_cel = $no_cel,
dt_nascimento = $dt_nascimento,
nm_rua = $nm_rua,
no_rua = $no_rua ,
no_cep = $no_cep,
bairro = $bairro,
cidade = $cidade,
estado = $estado,
sg_uf = $sg_uf,
complemento = $complemento
where cd_funcionario = $cd_funcionario;
end$$
DELIMITER ;
-- call pa_alterarFuncionario (2, 'Jorge', 'Santos Barbosa', '254.569.744-22', 'Atendente', '(11) 1111-4521', '(11) 96532-1111', '13/06/1990', 'Rua 1', '02', '11555-222', 'Av. Ramos', 'Araraquara','São Paulo', 'SP', 'nenhum');
/* -- FORNECEDOR*/
DELIMITER $$
drop procedure if exists pa_alterarFornecedor $$
create Procedure pa_alterarFornecedor (
$cd_fornecedor int,
$nome varchar(30),
$sobrenome varchar(50),
$email varchar(50),
$no_tel varchar(14),
$no_cnpj varchar(18)
)
main: begin
update tbFornecedor
set nome=$nome, sobrenome=$sobrenome, email=$email, no_tel=$no_tel, no_cnpj=$no_cnpj
where cd_fornecedor = $cd_fornecedor;
end $$
DELIMITER ;
call pa_alterarFornecedor (1, 'Rafael', 'Santos Costa', 'rafael.santos@outlook.com', '(11)5555-2010', '11.245.578/9991-30');
/* -- FORNECEDOR MARCA*/
DELIMITER $$
drop procedure if exists pa_alterarFornecedorMarca $$
create Procedure pa_alterarFornecedorMarca (
$nm_marca varchar (50), $cd_fornecedor int
)
main: begin
update tbFornecedorMarca
set cd_fornecedor = $cd_fornecedor
where nm_marca = $nm_marca;
end $$
DELIMITER ;
call pa_alterarFornecedorMarca ('Adidas',3);
/* -- PRODUTO*/
DELIMITER $$
drop procedure if exists pa_alterarProduto $$
create Procedure pa_alterarProduto (
$cd_produto int,
$nm_marca varchar(50),
$tipo varchar(60),
$descricao varchar(255),
$aspecto varchar(255),
$vl_preco_unitario decimal(10,2),
$garantia varchar(20),
$caminho_imagem varchar(255)
)
main: begin
update tbProduto
set
nm_marca = $nm_marca,
tipo = $tipo,
descricao = $descricao,
aspecto = $aspecto,
vl_preco_unitario = $vl_preco_unitario,
garantia = $garantia,
caminho_imagem = $caminho_imagem
where cd_produto = $cd_produto;
end$$
DELIMITER ;
/* -- ESTOQUE*/
DELIMITER $$
drop procedure if exists pa_alterarEstoque $$
create Procedure pa_alterarEstoque (
$cd_produto int, $qt_estoque int
)
main: begin
update tbEstoque
set qt_estoque = $qt_estoque
where cd_produto = $cd_produto;
end$$
DELIMITER ;
/* -- PEDIDO*/
DELIMITER $$
drop procedure if exists pa_alterarPedido $$
create Procedure pa_alterarPedido (
cd_pedido int,
cd_cliente int,
dt_pedido varchar(10)
)
main: begin
update tbPedido
set cd_cliente = $cd_cliente,
dt_pedido = $dt_pedido
where cd_pedido = cd_pedido;
end$$
DELIMITER ;
-- call pa_alterarPedido (1,1,'28/08/2017');
/* -- PEDIDO ITENS*/
DELIMITER $$
drop procedure if exists pa_alterarPedidoItens $$
create Procedure pa_alterarPedidoItens(
$cd_item int,
$cd_pedido int,
$cd_produto int,
$qt_item int
)
main: begin
update tbPedidoItens
set
cd_pedido = $cd_pedido,
cd_produto = $cd_produto,
qt_item = $qt_item,
subtotal=(select vl_preco_unitario * $qt_item from tbProduto where cd_produto = $cd_produto)
where cd_item = cd_item;
end$$
DELIMITER ;
/* -- PEDIDO RECEITA*/
DELIMITER $$
drop procedure if exists pa_alterarPedidoReceita $$
create Procedure pa_alterarPedidoReceita (
$cd_pedido int, $cd_receita int, $cd_pedidoreceita int
)
main: begin
update tbPedidoReceita
set cd_pedido = $cd_pedido, cd_receita = $cd_receita
where cd_pedidoreceita = $cd_pedidoreceita;
end$$
DELIMITER ;
call pa_alterarPedidoReceita (1,3, 3);
/* -- PAGAMENTO*/
DELIMITER $$
drop procedure if exists pa_alterarFormaPagamento $$
create Procedure pa_alterarFormaPagamento(
$cd_pagamento int,
$cd_pedido int,
$tipo_pagamento varchar(255),
$parcelamento varchar(40)
)
main: begin
update tbFormaPagamento
set cd_pedido = $cd_pedido,
tipo_pagamento = $tipo_pagamento,
parcelamento = $parcelamento,
vl_total=(select SUM(vl_subtotal)from tbPedidoItens where cd_pedido = $cd_pedido)
where cd_pagamento = $cd_pagamento;
end$$
DELIMITER ;
/* -- NOTIFICACAO*/
DELIMITER $$
drop procedure if exists pa_alterarNotificacao $$
create Procedure pa_alterarNotificacao(
$cd_notificacao int,
$cd_cliente int,
$cd_produto int
)
main: begin
update tbProdutoNotificacao
set cd_cliente = $cd_cliente,
cd_produto = $cd_produto
where cd_notificacao = $cd_notificacao;
end$$
DELIMITER ;
call pa_alterarNotificacao(2,1,1);
/* -- CARRINHO*/
DELIMITER $$
drop procedure if exists pa_alterarCarrinhoCompra $$
create Procedure pa_alterarCarrinhoCompra(
$cd_carrinho int,
$cd_produto int,
$cd_cliente int,
$qt_item int
)
main: begin
update tbCarrinhoCompra
set cd_produto = $cd_produto, cd_cliente = $cd_cliente, qt_item = $qt_item
where cd_carrinho = $cd_carrinho;
end$$
DELIMITER ;
-- call pa_alterarCarrinhoCompra(1,1,2,30);
|
# several way to comment in mysql
# using --, # and /*comment*/
# create database/schema
CREATE SCHEMA IF NOT EXISTS godking;
# DISPLAY ALL DATABASES IN MYSQL
SHOW DATABASES;
USE godking;
-- table
-- create table
CREATE TABLE IF NOT EXISTS user (
id INT AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
age INT NULL,
title VARCHAR(255) NULL,
PRIMARY KEY (id)
) ENGINE=INNODB;
-- or
-- CREATE TABLE IF NOT EXISTS user (
-- id INT AUTO_INCREMENT PRIMARY KEY, -- auto not null constraint
-- name VARCHAR(255) NOT NULL,
-- age INT NULL,
-- title VARCHAR(255) NULL
-- ) ENGINE=INNODB
-- alter table
-- add columns
alter table user
add column link varchar(255) null,
add column tel varchar(255) null;
-- drop columns
alter table user
drop column link,
drop column tel;
-- change columns
alter table user
change column age age bigint null;
-- rename table
-- alter table user rename to user_n;
rename table user to user_n;
rename table user_n to user;
-- drop table
-- drop table if exists user |
delete from user_book_flight;
delete from booking;
delete from booking_passenger;
delete from passenger;
alter table passenger auto_increment = 1; |
use hackerrank_top_competitors;
insert into difficulty
(difficulty_level, score)
values
(1,20),
(2,30),
(3,40),
(4,60),
(5,80),
(6,100),
(7,120)
;
|
/* В базе данных shop и sample присутствуют одни и те же таблицы, учебной базы данных.
Переместите запись id = 1 из таблицы shop.users в таблицу sample.users. Используйте транзакции.*/
use sample;
start transaction;
insert into sample.users (id, name)
select id, name
from shop.users
where shop.users.id = 1;
-- из задания непонятно требуется ли удалять перемещенного юзера из первой таблицы, поэтому при необходимости код можно убрать
delete from shop.users
where shop.users.id = 1;
commit;
-- проверяем
select * from users;
use shop;
select * from users; |
create sequence id_sequence_crypt start 100 increment 10;
create table sensor_vals (id int8 not null, uuid varchar(255), primary key (id));
|
DROP DATABASE IF EXISTS test;
create database test;
use test;
drop table if exists item;
drop table if exists category;
drop table if exists customer;
drop table if exists ordered;
drop table if exists ordered_default;
create table item
(
code SERIAL primary key,
category_code integer,
name text,
price integer
);
create table category
(
code serial primary key,
name text
);
create table customer
(
code serial primary key,
name text,
address text,
tel text,
email text
);
create table ordered
(
code serial primary key,
customer_code integer,
ordered_date date,
total_price integer
);
create table ordered_detail
(
ordered_code integer,
item_code integer,
num integer
);
insert into category(name)
values ('本');
insert into category (name)
values ('DVD');
insert into category (name)
values ('ゲーム');
insert into item (category_code, name, price)
values (1, 'Javaの基本', 2500);
insert into item (category_code, name, price)
values (1, 'MLB Fun', 980);
insert into item (category_code, name, price)
values (1, '料理 BOOK!', 1200);
insert into item (category_code, name, price)
values (2, '懐かしのアニメシリーズ', 2000);
insert into item (category_code, name, price)
values (2, 'The Racer', 1000);
insert into item (category_code, name, price)
values (2, 'Space Wars 3', 1200);
insert into item (category_code, name, price)
values (3, 'パズルゲーム', 780);
insert into item (category_code, name, price)
values (3, 'Invader Fighter', 3400);
insert into item (category_code, name, price)
values (3, 'Play the BascketBall', 2200); |
CREATE DATABASE yetigave;
USE yetigave;
CREATE TABLE categories (
id INT AUTO_INCREMENT PRIMARY KEY,
category_name CHAR(128)
);
CREATE UNIQUE INDEX category_name ON categories(category_name);
CREATE TABLE lots (
id INT AUTO_INCREMENT PRIMARY KEY,
date_of_creation TIMESTAMP,
lot_title VARCHAR(60),
description TEXT,
image VARCHAR(32),
starting_price INT,
date_of_completion TIMESTAMP,
bid_rate INT,
additions_to_favorites SMALLINT,
user_id INT,
winner_id INT,
category_id INT
);
CREATE INDEX lot_title ON lots(lot_title);
CREATE UNIQUE INDEX image ON lots(image);
CREATE TABLE costs (
id INT AUTO_INCREMENT PRIMARY KEY,
date_of_cost TIMESTAMP,
cost INT,
user_id INT,
lot_id INT
);
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
date_of_sign_in TIMESTAMP,
email VARCHAR(64),
username VARCHAR(32),
password VARCHAR(100),
avatar VARCHAR(32),
contacts VARCHAR(32)
);
CREATE UNIQUE INDEX email ON users(email);
CREATE UNIQUE INDEX username ON users(username);
|
-- phpMyAdmin SQL Dump
-- version 4.5.4.1deb2ubuntu2.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 24, 2018 at 08:06 AM
-- Server version: 10.0.36-MariaDB-0ubuntu0.16.04.1
-- PHP Version: 7.2.5-1+ubuntu16.04.1+deb.sury.org+1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `rosi`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE `admin` (
`id` int(11) NOT NULL,
`uname` varchar(30) NOT NULL,
`pass` varchar(70) NOT NULL,
`foto` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`id`, `uname`, `pass`, `foto`) VALUES
(8, 'malasngoding', '069c546d1d97fd9648d8142b3e0fd3a3', 'text.png'),
(9, 'admin', 'admin', '');
-- --------------------------------------------------------
--
-- Table structure for table `barang`
--
CREATE TABLE `barang` (
`id_barang` int(11) NOT NULL,
`nama_barang` varchar(100) NOT NULL,
`harga` int(11) NOT NULL,
`jumlah` int(11) NOT NULL,
`sisa` int(11) NOT NULL,
`tgl_masuk` date NOT NULL,
`kadaluarsa` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `barang`
--
INSERT INTO `barang` (`id_barang`, `nama_barang`, `harga`, `jumlah`, `sisa`, `tgl_masuk`, `kadaluarsa`) VALUES
(14, 'roti unibis', 6500, 350, 20, '2018-11-01', '2018-11-06'),
(17, 'tim tam', 6000, 792, 10, '2018-11-06', '2018-11-22'),
(19, 'tic tac', 4000, 2, 24, '2018-11-01', '2018-11-23'),
(20, 'aqua sedang', 3000, 990, 1000, '2018-11-05', '2018-11-30'),
(23, 'magnum', 13000, 997, 1000, '2018-11-06', '2018-11-23'),
(24, 'santri mie', 4000, 784, 800, '2018-11-01', '2018-11-30'),
(25, 'rambut palsu', 5000, 496, 500, '2018-11-07', '2018-11-30'),
(26, 'rambut palsu', 5000, 496, 500, '2018-11-01', '2018-11-30'),
(27, 'sea foog', 60000, 598, 600, '2018-11-01', '2018-11-30'),
(28, 'mild', 17000, 192, 200, '2018-11-01', '2018-11-23'),
(29, 'dji sam soe', 15000, 145, 150, '2018-11-01', '2018-11-24'),
(31, 'nu mild', 15000, 144, 150, '2018-11-07', '2018-11-30'),
(32, 'roti', 5000, 4, 6, '2018-11-08', '2018-11-24'),
(33, 'Nutella', 20000, 2000, 10, '2018-11-12', '2019-03-28');
-- --------------------------------------------------------
--
-- Table structure for table `barang_laku`
--
CREATE TABLE `barang_laku` (
`id` int(11) NOT NULL,
`tanggal` date NOT NULL,
`nama` text NOT NULL,
`jumlah` int(11) NOT NULL,
`harga` int(11) NOT NULL,
`total_harga` int(20) NOT NULL,
`laba` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `barang_laku`
--
INSERT INTO `barang_laku` (`id`, `tanggal`, `nama`, `jumlah`, `harga`, `total_harga`, `laba`) VALUES
(46, '2015-02-01', 'roti unibis', 2, 6000, 12000, 2000),
(47, '2015-02-02', 'makkkanan', 7, 12000, 84000, 70000),
(48, '2015-02-02', 'dji sam soe', 2, 15000, 30000, 2000),
(49, '2015-02-03', 'makkkanan', 1, 12000, 12000, 10000),
(50, '2015-02-01', 'tim tam', 2, 4000, 8000, 4000),
(51, '2015-02-02', 'mild', 2, 17000, 34000, 4000),
(52, '2015-02-03', 'magnum', 1, 18000, 18000, 6000),
(53, '2015-02-06', 'dji sam soe', 2, 19000, 38000, 10000),
(54, '2015-02-15', 'nu mild', 2, 19100, 38200, 10200),
(55, '2015-02-27', 'roti unibis', 2, 8000, 16000, 6000),
(56, '2015-02-19', 'roti unibis', 1, 7000, 7000, 2000),
(57, '2015-01-14', 'roti unibis', 1, 7000, 7000, 2000),
(58, '2015-02-01', 'pulpen', 1, 3000, 3000, 2000),
(59, '2015-02-02', 'roti', 2, 3000, 6000, 2000),
(63, '2016-01-22', 'tic tac', 8, 4000, 32000, 16000);
-- --------------------------------------------------------
--
-- Table structure for table `pelanggan`
--
CREATE TABLE `pelanggan` (
`id_toko` int(11) NOT NULL,
`nama_toko` varchar(100) NOT NULL,
`pemilik` varchar(100) NOT NULL,
`alamat` varchar(100) NOT NULL,
`no_tlp` char(15) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `pelanggan`
--
INSERT INTO `pelanggan` (`id_toko`, `nama_toko`, `pemilik`, `alamat`, `no_tlp`) VALUES
(1, 'Mugi Berkah', 'Solihin', 'jl Ottoiskandardinata GG18', '085701344456'),
(2, 'Moro Seneng', 'Subandi', 'Jl Garuda 89 Pekalongan', '085741909'),
(3, 'Slamet BU', 'dol', 'Jl Sumombito', '99230920392'),
(4, 'Toko Lala', 'Lalapo', 'Jl Progo No 290 Pekalogan', '098623673'),
(5, 'Toko Global', 'Gomblo', 'Jl. Seruni No. 66A Pekalongan, Poncol', '085701366890'),
(6, 'Dekoro Jaya', 'Royhin', 'Jl. H. Agus Salim no. 5 Pekalongan', '085741909'),
(7, 'Istana', 'Topik', 'Jl. Gajah Mada No. 23-25, Pekalongan', '08570136688'),
(8, 'Kerinci jaya', 'Wiranto', 'Jl. Kurinci No. 34 Pekalongan, Bendan', '085701366890'),
(9, 'Reyhan Sembako', 'Reyhan', 'Jl. Diponegoro No. 19, Kota Pekalongan', '0987878777'),
(10, 'Toko Sodikin', 'Sodikin', 'Jl Diponegoro No 19 A, Pekalongan', '0812678787'),
(11, 'AKB', 'Aris', 'Jl. Mataram No.1, Pekalongan', '0812678787');
-- --------------------------------------------------------
--
-- Table structure for table `pengeluaran`
--
CREATE TABLE `pengeluaran` (
`id` int(11) NOT NULL,
`tanggal` date NOT NULL,
`keperluan` text NOT NULL,
`nama` text NOT NULL,
`jumlah` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `pengeluaran`
--
INSERT INTO `pengeluaran` (`id`, `tanggal`, `keperluan`, `nama`, `jumlah`) VALUES
(1, '2015-02-06', 'de', 'diki', 1234);
-- --------------------------------------------------------
--
-- Table structure for table `pesanan`
--
CREATE TABLE `pesanan` (
`id_pesanan` int(11) NOT NULL,
`kode` char(20) NOT NULL,
`sales` varchar(100) NOT NULL,
`id_toko` int(11) NOT NULL,
`tanggal` date NOT NULL,
`status` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `pesanan`
--
INSERT INTO `pesanan` (`id_pesanan`, `kode`, `sales`, `id_toko`, `tanggal`, `status`) VALUES
(5, 'PJ-A43E5', 'Admin', 1, '2018-11-08', 0),
(6, 'PJ-097FC', 'Admin', 1, '2018-11-01', 0),
(7, 'PJ-BE82E', 'Admin', 2, '2018-11-22', 0),
(8, 'PJ-5C90F', 'Helper', 1, '2018-11-01', 0),
(9, 'PJ-DDA10', 'Helper', 3, '2018-11-23', 0),
(10, 'PJ-BD6F0', 'Sales', 4, '2018-11-23', 0),
(11, 'PJ-6A17C', 'Sales', 8, '2018-11-23', 0);
-- --------------------------------------------------------
--
-- Table structure for table `pesanan_detail`
--
CREATE TABLE `pesanan_detail` (
`id_detpesanan` int(11) NOT NULL,
`id_pesanan` int(11) NOT NULL,
`id_barang` int(11) NOT NULL,
`harga` int(11) NOT NULL,
`jumlah` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `pesanan_detail`
--
INSERT INTO `pesanan_detail` (`id_detpesanan`, `id_pesanan`, `id_barang`, `harga`, `jumlah`) VALUES
(6, 5, 17, 6000, 2),
(7, 5, 19, 4000, 3),
(8, 6, 14, 6500, 3),
(9, 7, 19, 4000, 23),
(10, 7, 23, 13000, 2),
(11, 8, 20, 3000, 3),
(12, 9, 23, 13000, 8),
(13, 9, 24, 4000, 9),
(14, 9, 24, 4000, 90),
(15, 10, 29, 15000, 80),
(16, 11, 33, 20000, 2),
(17, 11, 28, 17000, 2),
(18, 11, 20, 3000, 10),
(19, 11, 27, 60000, 10),
(20, 11, 32, 5000, 10);
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`nama` varchar(100) NOT NULL,
`alamat` text NOT NULL,
`telp` char(13) NOT NULL,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`level` enum('admin','sales','gudang','helper') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `nama`, `alamat`, `telp`, `username`, `password`, `level`) VALUES
(1, 'Sales', 'Jl. (Jalan) R.A.Kartini, Kota Pekalongan, Jawa Tengah', '(0285) 423001', 'sales', 'sales', 'sales'),
(2, 'Admin', 'Jl. (Jalan) R.A.Kartini, Kota Pekalongan, Jawa Tengah', '(0285) 423001', 'admin', 'admin', 'admin'),
(3, 'Gudang', 'Jl. (Jalan) R.A.Kartini, Kota Pekalongan, Jawa Tengah', '(0285) 423001', 'gudang', 'gudang', 'gudang'),
(4, 'Helper', 'Jl. (Jalan) R.A.Kartini, Kota Pekalongan, Jawa Tengah', '(0285) 423001', 'helper', 'helper', 'helper'),
(5, 'Robinson', 'Jl. (Jalan) R.A.Kartini, Kota Pekalongan, Jawa Tengah', '(0285) 423001', 'robin', 'robin', 'sales'),
(7, 'dol patah', 'Jl. (Jalan) R.A.Kartini, Kota Pekalongan, Jawa Tengah', '(0285) 423001', 'dol', 'dol', 'helper');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `barang`
--
ALTER TABLE `barang`
ADD PRIMARY KEY (`id_barang`);
--
-- Indexes for table `barang_laku`
--
ALTER TABLE `barang_laku`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `pelanggan`
--
ALTER TABLE `pelanggan`
ADD PRIMARY KEY (`id_toko`);
--
-- Indexes for table `pengeluaran`
--
ALTER TABLE `pengeluaran`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `pesanan`
--
ALTER TABLE `pesanan`
ADD PRIMARY KEY (`id_pesanan`);
--
-- Indexes for table `pesanan_detail`
--
ALTER TABLE `pesanan_detail`
ADD PRIMARY KEY (`id_detpesanan`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `barang`
--
ALTER TABLE `barang`
MODIFY `id_barang` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34;
--
-- AUTO_INCREMENT for table `barang_laku`
--
ALTER TABLE `barang_laku`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=64;
--
-- AUTO_INCREMENT for table `pelanggan`
--
ALTER TABLE `pelanggan`
MODIFY `id_toko` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `pengeluaran`
--
ALTER TABLE `pengeluaran`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `pesanan`
--
ALTER TABLE `pesanan`
MODIFY `id_pesanan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `pesanan_detail`
--
ALTER TABLE `pesanan_detail`
MODIFY `id_detpesanan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
/*!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 */; |
-- phpMyAdmin SQL Dump
-- version 4.9.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 07, 2021 at 12:38 PM
-- Server version: 10.4.8-MariaDB
-- PHP Version: 7.3.11
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: `hotel`
--
-- --------------------------------------------------------
--
-- Table structure for table `customer`
--
CREATE TABLE `customer` (
`id_customer` int(11) NOT NULL,
`id_management` int(11) NOT NULL,
`id_card` int(11) NOT NULL,
`sex` enum('male','female') NOT NULL,
`fname` varchar(25) NOT NULL,
`lname` varchar(25) NOT NULL,
`address` varchar(100) NOT NULL,
`phone_number` varchar(12) NOT NULL,
`email` varchar(60) NOT NULL,
`registration_date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `customer`
--
INSERT INTO `customer` (`id_customer`, `id_management`, `id_card`, `sex`, `fname`, `lname`, `address`, `phone_number`, `email`, `registration_date`) VALUES
(1, 2, 2147483647, 'male', 'John', 'Andrea', 'Desa Klapagading RT 01/RW 01 \r\nKecamatan Wangon', '08127890123', 'john.andrea@gmail.com', '2021-05-16'),
(2, 2, 2147483645, 'male', 'John', 'Wick', 'Blater RT 01', '123123123', 'john.wick@mhs.unsoed.ac.id', '2021-05-17');
-- --------------------------------------------------------
--
-- Stand-in structure for view `data_meminjam`
-- (See below for the actual view)
--
CREATE TABLE `data_meminjam` (
`id_book` int(11)
,`fname` varchar(25)
,`lname` varchar(25)
,`id_card` int(11)
,`phone_number` varchar(12)
,`id_room` int(11)
,`room_name` varchar(40)
,`id_type` int(11)
,`start_date` date
,`duration` int(11)
,`end_date` date
,`pay` int(11)
,`status` enum('active','finished')
);
-- --------------------------------------------------------
--
-- Table structure for table `management`
--
CREATE TABLE `management` (
`id_management` int(11) NOT NULL,
`id_card` varchar(12) NOT NULL,
`fname` varchar(50) NOT NULL,
`lname` varchar(50) NOT NULL,
`address` varchar(500) NOT NULL,
`phone_number` varchar(13) NOT NULL,
`sex` enum('male','female') NOT NULL,
`email` varchar(100) NOT NULL,
`password` char(32) NOT NULL,
`level` enum('manager','receptionist','admin') NOT NULL,
`profile_picture` varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `management`
--
INSERT INTO `management` (`id_management`, `id_card`, `fname`, `lname`, `address`, `phone_number`, `sex`, `email`, `password`, `level`, `profile_picture`) VALUES
(1, '110202031718', 'Ferry', 'Darmawan', 'Jalan raya Purwokerto', '081278901234', 'male', 'ferry.darmawan@mhs.unsoed.ac.id', 'd8578edf8458ce06fbc5bb76a58c5ca4', 'manager', 'user/FP1.png'),
(2, '110202031719', 'Michael', 'Joe', 'Desa Blater Purbalingga', '081278901233', 'male', 'michael.joe@mhs.unsoed.ac.id', 'e807f1fcf82d132f9bb018ca6738a19f', 'receptionist', 'img/profile.png'),
(3, '1102089123', 'Rifqi', 'Ahmad', 'Purwokerto\r\nDekat Rita Supermall', '081278901212', 'male', 'rifqi.ahmad@mhs.unsoed.ac.id', 'd8578edf8458ce06fbc5bb76a58c5ca4', 'admin', 'user/FP3.png'),
(4, '2147483611', 'Heru', 'Wick', 'Desa Blater RT 01/01, Kecamatan Kalimanah Wetan\r\nKabupaten Purbalingga', '081278901232', 'male', 'heru.wick@gmail.com', 'd8578edf8458ce06fbc5bb76a58c5ca4', 'receptionist', 'img/profile.png'),
(5, '1123341234', 'Spongebob', 'Squarepants', 'Desa Blater', '081278901232', 'male', 'spongebob@gmail.com', 'd8578edf8458ce06fbc5bb76a58c5ca4', 'receptionist', 'img/profile.png');
-- --------------------------------------------------------
--
-- Table structure for table `meminjam`
--
CREATE TABLE `meminjam` (
`id_book` int(11) NOT NULL,
`id_customer` int(11) NOT NULL,
`id_management` int(11) NOT NULL,
`id_room` int(11) NOT NULL,
`start_date` date NOT NULL,
`duration` int(11) NOT NULL,
`end_date` date NOT NULL,
`pay` int(11) NOT NULL,
`status` enum('active','finished') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `meminjam`
--
INSERT INTO `meminjam` (`id_book`, `id_customer`, `id_management`, `id_room`, `start_date`, `duration`, `end_date`, `pay`, `status`) VALUES
(1, 1, 2, 1, '2021-05-16', 5, '2021-05-21', 400000, 'finished'),
(2, 1, 2, 2, '2021-05-16', 5, '2021-05-21', 400000, 'finished'),
(3, 1, 2, 3, '2021-05-16', 2, '2021-05-18', 160000, 'active'),
(4, 1, 2, 4, '2021-05-16', 2, '2021-05-18', 160000, 'active'),
(5, 1, 2, 5, '2021-05-16', 2, '2021-05-18', 160000, 'active'),
(6, 1, 2, 1, '2021-05-16', 4, '2021-05-20', 320000, 'finished'),
(7, 1, 2, 2, '2021-05-16', 4, '2021-05-20', 320000, 'finished'),
(8, 1, 2, 1, '2021-05-16', 3, '2021-05-19', 240000, 'finished'),
(9, 1, 2, 2, '2021-05-16', 7, '2021-05-23', 560000, 'active'),
(10, 2, 2, 6, '2021-05-17', 10, '2021-05-27', 2000000, 'finished');
-- --------------------------------------------------------
--
-- Table structure for table `room`
--
CREATE TABLE `room` (
`id_room` int(11) NOT NULL,
`name` varchar(40) NOT NULL,
`status` enum('free','booked','maintenance') NOT NULL,
`id_type` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `room`
--
INSERT INTO `room` (`id_room`, `name`, `status`, `id_type`) VALUES
(1, 'K1', 'free', 1),
(2, 'K2', 'booked', 1),
(3, 'K3', 'booked', 1),
(4, 'K4', 'booked', 1),
(5, 'K5', 'booked', 1),
(6, 'V1', 'free', 2),
(7, 'V2', 'free', 2),
(8, 'V3', 'free', 2);
-- --------------------------------------------------------
--
-- Table structure for table `room_pict`
--
CREATE TABLE `room_pict` (
`id_pict` int(11) NOT NULL,
`path` varchar(100) NOT NULL,
`id_type` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `room_pict`
--
INSERT INTO `room_pict` (`id_pict`, `path`, `id_type`) VALUES
(1, 'galery/P11.png', 1),
(2, 'galery/P12.png', 1),
(3, 'galery/P13.png', 1),
(4, 'galery/P21.png', 2),
(5, 'galery/P22.png', 2),
(6, 'galery/P23.png', 2),
(7, 'galery/P31.png', 3),
(8, 'galery/P32.png', 3),
(9, 'galery/P33.png', 3);
-- --------------------------------------------------------
--
-- Table structure for table `room_type`
--
CREATE TABLE `room_type` (
`id_type` int(11) NOT NULL,
`name` varchar(40) NOT NULL,
`price` int(11) NOT NULL,
`description` varchar(500) NOT NULL,
`bedroom` int(11) NOT NULL,
`bathroom` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `room_type`
--
INSERT INTO `room_type` (`id_type`, `name`, `price`, `description`, `bedroom`, `bathroom`) VALUES
(1, 'Reguler', 75000, 'Tipe kamar yang murah dan sangat nyaman.', 1, 1),
(2, 'VIP', 200000, 'Kamar dengan pelayanan dan fasilitas mewah.', 2, 1),
(3, 'Ekonomi', 300000, 'Digunakan untuk menginap dengan harga yang murah.', 2, 1);
-- --------------------------------------------------------
--
-- Structure for view `data_meminjam`
--
DROP TABLE IF EXISTS `data_meminjam`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `data_meminjam` AS select `meminjam`.`id_book` AS `id_book`,`customer`.`fname` AS `fname`,`customer`.`lname` AS `lname`,`customer`.`id_card` AS `id_card`,`customer`.`phone_number` AS `phone_number`,`room`.`id_room` AS `id_room`,`room`.`name` AS `room_name`,`room_type`.`id_type` AS `id_type`,`meminjam`.`start_date` AS `start_date`,`meminjam`.`duration` AS `duration`,`meminjam`.`end_date` AS `end_date`,`meminjam`.`pay` AS `pay`,`meminjam`.`status` AS `status` from (((`meminjam` join `customer` on(`meminjam`.`id_customer` = `customer`.`id_customer`)) join `room` on(`meminjam`.`id_room` = `room`.`id_room`)) join `room_type` on(`room`.`id_type` = `room_type`.`id_type`)) ;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `customer`
--
ALTER TABLE `customer`
ADD PRIMARY KEY (`id_customer`),
ADD UNIQUE KEY `uk_id_card_customer` (`id_card`);
--
-- Indexes for table `management`
--
ALTER TABLE `management`
ADD PRIMARY KEY (`id_management`);
--
-- Indexes for table `meminjam`
--
ALTER TABLE `meminjam`
ADD PRIMARY KEY (`id_book`),
ADD KEY `fk_customer` (`id_customer`),
ADD KEY `fk_management` (`id_management`),
ADD KEY `fk_id_room` (`id_room`);
--
-- Indexes for table `room`
--
ALTER TABLE `room`
ADD PRIMARY KEY (`id_room`),
ADD UNIQUE KEY `uk_room_name` (`name`),
ADD KEY `fk_id_type` (`id_type`);
--
-- Indexes for table `room_pict`
--
ALTER TABLE `room_pict`
ADD PRIMARY KEY (`id_pict`),
ADD KEY `fk_id_type_2` (`id_type`);
--
-- Indexes for table `room_type`
--
ALTER TABLE `room_type`
ADD PRIMARY KEY (`id_type`),
ADD UNIQUE KEY `uk_type_name` (`name`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `customer`
--
ALTER TABLE `customer`
MODIFY `id_customer` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `management`
--
ALTER TABLE `management`
MODIFY `id_management` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `meminjam`
--
ALTER TABLE `meminjam`
MODIFY `id_book` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT for table `room`
--
ALTER TABLE `room`
MODIFY `id_room` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `room_pict`
--
ALTER TABLE `room_pict`
MODIFY `id_pict` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `room_type`
--
ALTER TABLE `room_type`
MODIFY `id_type` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `meminjam`
--
ALTER TABLE `meminjam`
ADD CONSTRAINT `fk_customer` FOREIGN KEY (`id_customer`) REFERENCES `customer` (`id_customer`),
ADD CONSTRAINT `fk_id_room` FOREIGN KEY (`id_room`) REFERENCES `room` (`id_room`),
ADD CONSTRAINT `fk_management` FOREIGN KEY (`id_management`) REFERENCES `management` (`id_management`);
--
-- Constraints for table `room`
--
ALTER TABLE `room`
ADD CONSTRAINT `fk_id_type` FOREIGN KEY (`id_type`) REFERENCES `room_type` (`id_type`);
--
-- Constraints for table `room_pict`
--
ALTER TABLE `room_pict`
ADD CONSTRAINT `fk_id_type_2` FOREIGN KEY (`id_type`) REFERENCES `room_type` (`id_type`);
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 */;
|
CREATE TABLE word(
id BIGINT PRIMARY KEY auto_increment NOT NULL,
wordname VARCHAR(20),
worddesc VARCHAR(20)
);
CREATE TABLE users(
user_id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(64),
score INT
);
CREATE TABLE userattemts(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT NOT NULL,
word_id BIGINT NOT NULL,
attempts INT
);
ALTER TABLE userattemts ADD FOREIGN KEY (user_id) REFERENCES users(user_id);
ALTER TABLE userattemts ADD FOREIGN KEY (word_id) REFERENCES word(id); |
CREATE DATABASE `fujii_bot` DEFAULT CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON fujii_bot.* TO 'fujii'@'localhost' IDENTIFIED BY 'hoge' WITH GRANT OPTION;
FLUSH PRIVILEGES;
/* user */
CREATE TABLE `user`(
`user_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`mid` VARCHAR(64) NOT NULL COMMENT 'LINE FROM',
`name` VARCHAR(32) DEFAULT NULL,
`created_at` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL default '0000-00-00 00:00:00',
UNIQUE (`mid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/* user_attr */
CREATE TABLE `user_attr`(
`user_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`display_name` VARCHAR(128) NOT NULL,
`picture` VARCHAR(128) DEFAULT NULL,
`message` VARCHAR(128) DEFAULT NULL,
`last_play` TIMESTAMP NOT NULL default '0000-00-00 00:00:00',
`created_at` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL default '0000-00-00 00:00:00',
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
-- User email must be unique
ALTER TABLE USERS ADD CONSTRAINT UQ_USERS_EMAIL UNIQUE (EMAIL);
-- @rollback
ALTER TABLE USERS DROP CONSTRAINT IF EXISTS UQ_USERS_EMAIL;
-- @mysql-rollback
-- ALTER TABLE USERS DROP CONSTRAINT UQ_USERS_EMAIL;
|
IF (OBJECT_ID('dbo.FK_ComputerEmployee', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.EmployeeComputer DROP CONSTRAINT FK_ComputerEmployee
END
IF (OBJECT_ID('dbo.FK_EmployeeComp', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.EmployeeComputer DROP CONSTRAINT FK_EmployeeComp
END
IF (OBJECT_ID('dbo.FK_TrainingProgram', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.EmployeeTraining DROP CONSTRAINT FK_TrainingProgram
END
IF (OBJECT_ID('dbo.FK_EmployeeTraining', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.EmployeeTraining DROP CONSTRAINT FK_EmployeeTraining
END
IF (OBJECT_ID('dbo.FK_DepartmentEmployee', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.Employee DROP CONSTRAINT FK_DepartmentEmployee
END
IF (OBJECT_ID('dbo.FK_CustomerProduct', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.Product DROP CONSTRAINT FK_CustomerProduct
END
IF (OBJECT_ID('dbo.FK_ProductTypeProduct', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.Product DROP CONSTRAINT FK_ProductTypeProduct
END
IF (OBJECT_ID('dbo.FK_OrderProductOrder', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.ProductOrder DROP CONSTRAINT FK_OrderProductOrder
END
IF (OBJECT_ID('dbo.FK_ProductProductOrder', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.ProductOrder DROP CONSTRAINT FK_ProductProductOrder
END
IF (OBJECT_ID('dbo.FK_CustomerPaymentOrder', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.[Order] DROP CONSTRAINT FK_CustomerPaymentOrder
END
IF (OBJECT_ID('dbo.FK_CustomerOrder', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.[Order] DROP CONSTRAINT FK_CustomerOrder
END
IF (OBJECT_ID('dbo.FK_PaymentTypeCustomer', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.CustomerPayment DROP CONSTRAINT FK_PaymentTypeCustomer
END
IF (OBJECT_ID('dbo.FK_CustomerPayment', 'F') IS NOT NULL)
BEGIN
ALTER TABLE dbo.CustomerPayment DROP CONSTRAINT FK_CustomerPayment
END
DROP TABLE IF EXISTS Department;
DROP TABLE IF EXISTS Employee;
DROP TABLE IF EXISTS EmployeeComputer;
DROP TABLE IF EXISTS EmployeeTraining;
DROP TABLE IF EXISTS [Order];
DROP TABLE IF EXISTS PaymentType;
DROP TABLE IF EXISTS Product;
DROP TABLE IF EXISTS ProductOrder;
DROP TABLE IF EXISTS ProductType;
DROP TABLE IF EXISTS TrainingProgram;
DROP TABLE IF EXISTS Computer;
DROP TABLE IF EXISTS Customer;
DROP TABLE IF EXISTS CustomerPayment;
CREATE TABLE Computer (
ComputerId INTEGER NOT NULL PRIMARY KEY IDENTITY,
DatePurchased DATE NOT NULL,
DateDecommissioned DATE,
Working BIT NOT NULL,
ModelName varchar(80) NOT NULL,
Manufacturer varchar(80) NOT NULL
);
CREATE TABLE TrainingProgram (
TrainingProgramId INTEGER NOT NULL PRIMARY KEY IDENTITY,
ProgramName varchar(80) NOT NULL,
Descrip varchar(90) NOT NULL,
StartDate DATE NOT NULL,
EndDate DATE NOT NULL,
MaximumAttendees INTEGER NOT NULL
);
CREATE TABLE Department (
DepartmentId INTEGER NOT NULL PRIMARY KEY IDENTITY,
DepartmentName varchar(80) NOT NULL,
ExpenseBudget INTEGER NOT NULL
);
CREATE TABLE Employee (
EmployeeId INTEGER NOT NULL PRIMARY KEY IDENTITY,
FirstName varchar(30) NOT NULL,
LastName varchar(30) NOT NULL,
Email varchar(50) NOT NULL,
Supervisor BIT NOT NULL,
DepartmentId INTEGER NOT NULL,
CONSTRAINT FK_DepartmentEmployee FOREIGN KEY(DepartmentId)REFERENCES Department(DepartmentId)
);
CREATE TABLE EmployeeTraining (
EmployeeTrainingId INTEGER NOT NULL PRIMARY KEY IDENTITY,
TrainingProgramId INTEGER NOT NULL,
EmployeeId INTEGER NOT NULL,
CONSTRAINT FK_TrainingProgram FOREIGN KEY(TrainingProgramId)REFERENCES TrainingProgram(TrainingProgramId),
CONSTRAINT FK_EmployeeTraining FOREIGN KEY(EmployeeId)REFERENCES Employee(EmployeeId)
);
CREATE TABLE EmployeeComputer (
EmployeeComputerId INTEGER NOT NULL PRIMARY KEY IDENTITY,
DateAssigned DATE NOT NULL,
DateReturned DATE NOT NULL,
ComputerId INTEGER NOT NULL,
EmployeeId INTEGER NOT NULL,
CONSTRAINT FK_ComputerEmployee FOREIGN KEY(ComputerId)REFERENCES Computer(ComputerId),
CONSTRAINT FK_EmployeeComp FOREIGN KEY(EmployeeId)REFERENCES Employee(EmployeeId)
);
CREATE TABLE Customer (
CustomerId INTEGER NOT NULL PRIMARY KEY IDENTITY,
FirstName varchar(30) NOT NULL,
LastName varchar(30) NOT NULL,
Email varchar(50) NOT NULL,
Address varchar(80) NOT NULL,
City varchar(30) NOT NULL,
State varchar(2) NOT NULL,
AcctCreationDate DATE NOT NULL,
LastLogin DATE NOT NULL
);
CREATE TABLE ProductType (
ProductTypeId INTEGER NOT NULL PRIMARY KEY IDENTITY,
ProductTypeName varchar(30) NOT NULL
);
CREATE TABLE PaymentType (
PaymentTypeId INTEGER NOT NULL PRIMARY KEY IDENTITY,
PaymentTypeName varchar(15) NOT NULL
);
CREATE TABLE CustomerPayment (
CustomerPaymentId INTEGER NOT NULL PRIMARY KEY IDENTITY,
CardNumber BIGINT NOT NULL,
CcvCode varchar(3) NOT NULL,
ExpirationDate varchar(5) NOT NULL,
PaymentTypeId INTEGER NOT NULL,
CustomerId INTEGER NOT NULL,
CONSTRAINT FK_CustomerPayment FOREIGN KEY(CustomerId)REFERENCES Customer(CustomerId),
CONSTRAINT FK_PaymentTypeCustomer FOREIGN KEY(PaymentTypeId)REFERENCES PaymentType(PaymentTypeId)
);
CREATE TABLE [Order] (
OrderId INTEGER NOT NULL PRIMARY KEY IDENTITY,
CustomerId INTEGER NOT NULL,
CustomerPaymentId INTEGER,
CONSTRAINT FK_CustomerOrder FOREIGN KEY(CustomerId)REFERENCES Customer(CustomerId),
CONSTRAINT FK_CustomerPaymentOrder FOREIGN KEY(CustomerPaymentId)REFERENCES CustomerPayment(CustomerPaymentId)
);
CREATE TABLE Product (
ProductId INTEGER NOT NULL PRIMARY KEY IDENTITY,
Price DECIMAL(4, 2) NOT NULL,
Title varchar(55) NOT NULL,
Description varchar(400) NOT NULL,
CustomerId INTEGER NOT NULL,
Quantity INTEGER NOT NULL,
ProductTypeId INTEGER NOT NULL,
CONSTRAINT FK_CustomerProduct FOREIGN KEY(CustomerId)REFERENCES Customer(CustomerId),
CONSTRAINT FK_ProductTypeProduct FOREIGN KEY(ProductTypeId)REFERENCES ProductType(ProductTypeId)
);
CREATE TABLE ProductOrder (
ProductOrderId INTEGER NOT NULL PRIMARY KEY IDENTITY,
OrderId INTEGER NOT NULL,
ProductId INTEGER NOT NULL,
CONSTRAINT FK_OrderProductOrder FOREIGN KEY(OrderId)REFERENCES [Order](OrderId),
CONSTRAINT FK_ProductProductOrder FOREIGN KEY(ProductId)REFERENCES Product(ProductId)
);
INSERT INTO Computer(DatePurchased, DateDecommissioned, Working, ModelName, Manufacturer)
VALUES
(
'2017/10/11',
null,
1,
'XPS',
'Dell');
INSERT INTO Computer(DatePurchased, DateDecommissioned, Working, ModelName, Manufacturer)
VALUES(
'2016/04/01',
'2017/04/15',
1,
'ThinkPad',
'Lenovo');
INSERT INTO TrainingProgram(ProgramName,Descrip,StartDate,EndDate,MaximumAttendees)
VALUES(
'Learn To Type',
'Learn How to type',
'2018/09/20',
'2018/09/27',
23);
INSERT INTO TrainingProgram(ProgramName,Descrip,StartDate,EndDate, MaximumAttendees)
VALUES(
'Begining React',
'Learn React in a month',
'2017/02/14',
'2017/03/01',
14);
INSERT INTO TrainingProgram(ProgramName,Descrip,StartDate,EndDate, MaximumAttendees)
VALUES(
'Learning .NET',
'Learn .NET in 3 months',
'2019/02/14',
'2019/03/01',
20);
INSERT INTO TrainingProgram(ProgramName,Descrip,StartDate,EndDate, MaximumAttendees)
VALUES(
'Starting Angular.js',
'Learn Angular really quickly!',
'2019/04/14',
'2019/07/01',
14);
INSERT INTO TrainingProgram(ProgramName,Descrip,StartDate,EndDate, MaximumAttendees)
VALUES(
'Learn Python',
'Python is really useful',
'2020/02/14',
'2020/03/01',
14);
INSERT INTO TrainingProgram(ProgramName,Descrip,StartDate,EndDate, MaximumAttendees)
VALUES(
'Learn CSS',
'Style with CSS',
'2021/02/14',
'2021/03/01',
35);
INSERT INTO Department(DepartmentName,ExpenseBudget)
VALUES(
'CodeRockstars',
140234);
INSERT INTO Department(DepartmentName,ExpenseBudget)
VALUES(
'IT',
23400);
INSERT INTO Employee(FirstName,LastName,Email,Supervisor,DepartmentId)
VALUES(
'William',
'Kimball',
'wkkimball043@gmail.com',
1,
1);
INSERT INTO Employee(FirstName,LastName,Email,Supervisor,DepartmentId)
VALUES(
'Robert',
'Leedy',
'rleedy@gmail.com',
0,
2);
INSERT INTO Employee(FirstName,LastName,Email,Supervisor,DepartmentId)
VALUES(
'Seth',
'Dana',
'sdana@gmail.com',
0,
2);
INSERT INTO EmployeeTraining(TrainingProgramId,EmployeeId)
VALUES(
4,
1);
INSERT INTO EmployeeTraining(TrainingProgramId,EmployeeId)
VALUES(
5,
3);
INSERT INTO EmployeeTraining(TrainingProgramId,EmployeeId)
VALUES(
6,
3);
INSERT INTO EmployeeTraining(TrainingProgramId,EmployeeId)
VALUES(
4,
3);
INSERT INTO EmployeeTraining(TrainingProgramId,EmployeeId)
VALUES(
5,
2);
INSERT INTO EmployeeTraining(TrainingProgramId,EmployeeId)
VALUES(
6,
1);
INSERT INTO EmployeeComputer(DateAssigned,DateReturned,EmployeeId,ComputerId)
VALUES(
'2017/02/14',
'2017/03/01',
2,
1);
INSERT INTO EmployeeComputer(DateAssigned,DateReturned,EmployeeId,ComputerId)
VALUES(
'2017/10/07',
'2017/03/01',
1,
2);
INSERT INTO Customer(FirstName,LastName,Email, Address,City,State,AcctCreationDate,LastLogin)
VALUES(
'Sathvik',
'Reddy',
'sr@gmail.com',
'123 Main St.',
'Nashville',
'TN',
'2014/03/01',
'2018/03/01');
INSERT INTO Customer(FirstName,LastName,Email, Address,City,State,AcctCreationDate,LastLogin)
VALUES(
'Natasha',
'Cox',
'ncox@gmail.com',
'123 Side St.',
'Nashville',
'TN',
'2012/01/14',
'2018/07/23');
INSERT INTO ProductType(ProductTypeName)
VALUES(
'KnitCap');
INSERT INTO ProductType(ProductTypeName)
VALUES(
'Craft Thing');
INSERT INTO PaymentType ( PaymentTypeName)
VALUES(
'Visa');
INSERT INTO PaymentType(PaymentTypeName)
VALUES(
'MasterCard');
INSERT INTO CustomerPayment (CardNumber,CcvCode,ExpirationDate,PaymentTypeId,CustomerId)
VALUES(
6798620123,
'345',
'03/19',
2,
2);
INSERT INTO CustomerPayment(CardNumber,CcvCode,ExpirationDate,PaymentTypeId,CustomerId)
VALUES(
12343211432,
'213',
'06/23',
1,
1);
INSERT INTO [Order](CustomerPaymentId,CustomerId)
VALUES(
2,
2);
INSERT INTO [Order](CustomerId)
VALUES(
1);
INSERT INTO Product(Price,Title,Description,Quantity,CustomerId,ProductTypeId)
VALUES(
23.40,
'Cap',
'Warm Winter Cap',
1,
2,
1);
INSERT INTO Product (Price,Title,Description,Quantity,CustomerId,ProductTypeId)
VALUES(
13.23,
'Painting',
'Painting of the ocean',
2,
1,
2);
INSERT INTO ProductOrder(OrderId, ProductId)
VALUES(
1,
2);
INSERT INTO ProductOrder(OrderId, ProductId)
VALUES(
1,
2);
INSERT INTO Computer(DatePurchased, DateDecommissioned, Working, ModelName, Manufacturer)
VALUES(
'2018/12/11',
null,
1,
'Pro',
'Mac');
INSERT INTO TrainingProgram(ProgramName,Descrip,StartDate,EndDate, MaximumAttendees)
VALUES(
'Mastering SQL',
'Master SQL with this training program',
'2018/07/12',
'2018/07/13',
5);
INSERT INTO Department(DepartmentName,ExpenseBudget)
VALUES(
'Sales',
24000);
INSERT INTO Employee(FirstName,LastName,Email,Supervisor,DepartmentId)
VALUES(
'Seth',
'Dana',
'sd@gmail.com',
0,
3);
INSERT INTO EmployeeTraining(TrainingProgramId,EmployeeId)
VALUES(
3,
3);
INSERT INTO EmployeeComputer(DateAssigned,DateReturned,EmployeeId,ComputerId)
VALUES(
'2017/02/14',
'2018/03/01',
3,
3);
INSERT INTO Customer(FirstName,LastName,Email, Address,City,State,AcctCreationDate,LastLogin)
VALUES(
'Walter',
'White',
'ww@gmail.com',
'123 5th St.',
'Nashville',
'TN',
'2016/03/01',
'2018/03/01');
INSERT INTO ProductType(ProductTypeName)
VALUES(
'Poem');
INSERT INTO PaymentType (PaymentTypeName)
VALUES(
'Discover');
INSERT INTO CustomerPayment(CardNumber,CcvCode,ExpirationDate,PaymentTypeId,CustomerId)
VALUES(
12343512432,
'133',
'06/33',
3,
3)
INSERT INTO [Order](CustomerPaymentId,CustomerId)
VALUES(
3,
3);
INSERT INTO Product (Price,Title,Description,Quantity,CustomerId,ProductTypeId)
VALUES(
21,
'Love Poem',
'Heart achingly beautiful poem',
3,
3,
3);
INSERT INTO ProductOrder (OrderId, ProductId)
VALUES(
3,
3);
|
DO $$
BEGIN
IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20190809125322_v1.17') THEN
ALTER TABLE iml_medicines ADD is_from_license boolean NOT NULL DEFAULT FALSE;
END IF;
END $$;
DO $$
BEGIN
IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20190809125322_v1.17') THEN
CREATE INDEX ix_iml_medicines_application_id ON iml_medicines (application_id);
END IF;
END $$;
DO $$
BEGIN
IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20190809125322_v1.17') THEN
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20190809125322_v1.17', '2.2.2-servicing-10034');
END IF;
END $$;
|
-- 元日 一月一日
CREATE OR REPLACE FUNCTION holidays_in_japan.IS_NEW_YEARS_DAY(d DATE)
AS (
EXTRACT(DAYOFYEAR FROM d) = 1
);
|
-- Create a new table called 'TableName' in schema 'SchemaName'
-- Drop the table if it already exists
-- Create the table in the specified schema
CREATE TABLE player
(
id INT(11) NOT NULL Auto_INCREMENT PRIMARY KEY ,
plyer_name VARCHAR(50) NOT NULL,
nation VARCHAR(30) NOT NULL,
team VARCHAR(30) NOT NULL,
created DATETIME NOT NULL,
position VARCHAR(10) NOT NULL,
sub_position VARCHAR(10),
birth DATE,
height INT(11)
);
insert into player (plyer_name, nation,team,created, position, birth, height) values('호날두', '포르투갈','유벤투스',now(), '공격수','1985-02-27',187); |
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.4
-- Dumped by pg_dump version 10.4
-- Started on 2018-08-04 04:47:50
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 client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 1 (class 3079 OID 12924)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- TOC entry 2815 (class 0 OID 0)
-- Dependencies: 1
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 199 (class 1259 OID 16408)
-- Name: login; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.login (
id integer NOT NULL,
"hashPassword" character varying(100) NOT NULL,
email text NOT NULL
);
ALTER TABLE public.login OWNER TO postgres;
--
-- TOC entry 198 (class 1259 OID 16406)
-- Name: login_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.login_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.login_id_seq OWNER TO postgres;
--
-- TOC entry 2816 (class 0 OID 0)
-- Dependencies: 198
-- Name: login_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.login_id_seq OWNED BY public.login.id;
--
-- TOC entry 197 (class 1259 OID 16396)
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.users (
id integer NOT NULL,
name character varying(100),
email text NOT NULL,
entries bigint DEFAULT 0,
joined timestamp with time zone NOT NULL
);
ALTER TABLE public.users OWNER TO postgres;
--
-- TOC entry 196 (class 1259 OID 16394)
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.users_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.users_id_seq OWNER TO postgres;
--
-- TOC entry 2817 (class 0 OID 0)
-- Dependencies: 196
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
--
-- TOC entry 2680 (class 2604 OID 16411)
-- Name: login id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.login ALTER COLUMN id SET DEFAULT nextval('public.login_id_seq'::regclass);
--
-- TOC entry 2678 (class 2604 OID 16399)
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
--
-- TOC entry 2686 (class 2606 OID 16416)
-- Name: login login_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.login
ADD CONSTRAINT login_pkey PRIMARY KEY (id);
--
-- TOC entry 2682 (class 2606 OID 16420)
-- Name: users unique; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT "unique" UNIQUE (email);
--
-- TOC entry 2684 (class 2606 OID 16405)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
-- Completed on 2018-08-04 04:47:50
--
-- PostgreSQL database dump complete
--
|
CREATE DATABASE IF NOT EXISTS registro4;
USE registro4;
CREATE TABLE users(
username VARCHAR(255),
password VARCHAR(255),
id VARCHAR(255),
PRIMARY KEY(id)
);
CREATE TABLE students(
name VARCHAR(255),
last VARCHAR(255),
id VARCHAR(255),
course VARCHAR(255),
PRIMARY KEY(id)
);
CREATE TABLE professors(
name VARCHAR(255),
last VARCHAR(255),
id VARCHAR(255),
PRIMARY KEY(id)
);
CREATE TABLE matchcourse(
userid VARCHAR(255),
course VARCHAR(255),
matter VARCHAR(255),
PRIMARY KEY(userid,course,matter)
);
CREATE TABLE homework(
id int NOT NULL AUTO_INCREMENT,
matter VARCHAR(255),
course VARCHAR(255),
expire Date,
description VARCHAR(255),
PRIMARY KEY (id)
);
CREATE TABLE arguments(
id int NOT NULL AUTO_INCREMENT,
matter VARCHAR(255),
course VARCHAR(255),
title VARCHAR(255),
created Date,
description VARCHAR(255),
PRIMARY KEY (id)
);
CREATE TABLE schedule(
pid VARCHAR(255),
course VARCHAR(255),
matter VARCHAR(255),
day int(8),
hour int(8),
PRIMARY KEY(pid,day,hour)
);
CREATE TABLE grades(
id int NOT NULL AUTO_INCREMENT,
studentid VARCHAR(255),
matter VARCHAR(255),
value int,
type VARCHAR(255),
day Date,
PRIMARY KEY (id)
);
CREATE TABLE absences(
id int NOT NULL AUTO_INCREMENT,
studentid VARCHAR(255),
value VARCHAR(255),
day Date,
justified int,
PRIMARY KEY (id)
);
CREATE TABLE pin(
studentid VARCHAR(255),
pin VARCHAR(255),
PRIMARY KEY (studentid)
);
INSERT INTO users (username,password,id) VALUES ("alberto","123","1");
INSERT INTO users(username,password,id) VALUES ("fab","123","20");
INSERT INTO students (name,last,id,course) VALUES ("Alberto","Bianchi","1","1B");
INSERT INTO students (name,last,id,course) VALUES ("Mario","Rossi","3","1B");
INSERT INTO students (name,last,id,course) VALUES ("Gian Marco","Colagrossi","4","1B");
INSERT INTO students (name,last,id,course) VALUES ("Riccardo","Carpinella","5","1B");
INSERT INTO students (name,last,id,course) VALUES ("Andrea","De Paolis","6","1B");
INSERT INTO students (name,last,id,course) VALUES ("Roberto","D' Angelo","7","3B");
INSERT INTO students (name,last,id,course) VALUES ("Patrizio","Amicomio","8","3B");
INSERT INTO students (name,last,id,course) VALUES ("Federica","Riccardi","9","1B");
INSERT INTO students (name,last,id,course) VALUES ("Chiara","Proietti","10","1B");
INSERT INTO students (name,last,id,course) VALUES ("Flavia","Verona","12","1B");
INSERT INTO students (name,last,id,course) VALUES ("Donatella","Verdi","14","1B");
INSERT INTO students (name,last,id,course) VALUES ("Alberto","Amicomio","13","1B");
INSERT INTO students (name,last,id,course) VALUES ("Elisabetta","Proietti","15","3B");
INSERT INTO students (name,last,id,course) VALUES ("Davide","Conti","16","3B");
INSERT INTO students (name,last,id,course) VALUES ("Alessia","Rossi","17","3B");
INSERT INTO professors(name,last,id) VALUES ("Fabrizio","Cola","20");
INSERT INTO professors(name,last,id) VALUES ("Maurizio","Tomei","19");
INSERT INTO professors(name,last,id) VALUES ("Salvatore","Tucci","18");
INSERT INTO professors(name,last,id) VALUES ("Salvatore","Romero","21");
INSERT INTO matchcourse(userid,course,matter) VALUES ("20","1B","Matematica");
INSERT INTO matchcourse(userid,course,matter) VALUES ("20","1B","Fisica");
INSERT INTO matchcourse(userid,course,matter) VALUES ("20","3B","Matematica");
INSERT INTO matchcourse(userid,course,matter) VALUES ("19","1B","Storia");
INSERT INTO matchcourse(userid,course,matter) VALUES ("19","1B","Geografia");
INSERT INTO matchcourse(userid,course,matter) VALUES ("19","1B","Scienze");
INSERT INTO matchcourse(userid,course,matter) VALUES ("19","1B","Italiano");
INSERT INTO matchcourse(userid,course,matter) VALUES ("18","1B","Inglese");
INSERT INTO matchcourse(userid,course,matter) VALUES ("18","1B","Francese");
INSERT INTO matchcourse(userid,course,matter) VALUES ("21","3B","Storia");
INSERT INTO matchcourse(userid,course,matter) VALUES ("21","3B","Geografia");
INSERT INTO matchcourse(userid,course,matter) VALUES ("21","3B","Scienze");
INSERT INTO matchcourse(userid,course,matter) VALUES ("18","3B","Inglese");
INSERT INTO schedule(pid,course,matter,day,hour) VALUES("20","1B","Matematica",0,9);
INSERT INTO schedule(pid,course,matter,day,hour) VALUES("20","1B","Matematica",0,10);
INSERT INTO schedule(pid,course,matter,day,hour) VALUES("20","1B","Fisica",2,9);
INSERT INTO schedule(pid,course,matter,day,hour) VALUES("20","1B","Fisica",2,10);
INSERT INTO schedule(pid,course,matter,day,hour) VALUES("20","1B","Matematica",4,11);
INSERT INTO schedule(pid,course,matter,day,hour) VALUES("20","1B","Matematica",4,12);
INSERT INTO schedule(pid,course,matter,day,hour) VALUES("20","3B","Matematica",1,9);
INSERT INTO schedule(pid,course,matter,day,hour) VALUES("20","3B","Matematica",1,10);
INSERT INTO schedule(pid,course,matter,day,hour) VALUES("20","3B","Matematica",3,9);
INSERT INTO schedule(pid,course,matter,day,hour) VALUES("20","3B","Matematica",3,10);
INSERT INTO absences(studentid,value,day,justified) VALUES("1","absence","2020-05-22",0);
INSERT INTO absences(studentid,value,day,justified) VALUES("3","absence","2020-05-22",0);
INSERT INTO absences(studentid,value,day,justified) VALUES("8","absence","2020-05-8",0);
INSERT INTO absences(studentid,value,day,justified) VALUES("4","ritardo","2020-05-25",0);
INSERT INTO grades(studentid,matter,value,day,type) VALUES("1","Matematica",8,"2020-06-6","written");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("1","Matematica",6,"2020-06-7","oral");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("4","Matematica",6,"2020-06-10","oral");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("1","Matematica",5,"2020-06-13","lab");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("8","Matematica",6,"2020-06-14","oral");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("3","Matematica",6,"2020-06-16","oral");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("7","Matematica",3,"2020-06-3","written");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("5","Matematica",5,"2020-06-4","oral");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("5","Matematica",5,"2020-06-6","oral");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("5","Matematica",5,"2020-06-20","oral");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("9","Matematica",9,"2020-06-5","written");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("3","Matematica",9,"2020-06-6","oral");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("4","Matematica",3,"2020-06-7","oral");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("9","Matematica",7,"2020-06-8","lab");
INSERT INTO grades(studentid,matter,value,day,type) VALUES("3","Matematica",6,"2020-06-9","lab");
|
Use MonkeyUniv
-- (1) Listado con la cantidad de cursos.
Select count(*) as 'Cantidad de cursos' from Cursos
-- 2 Listado con la cantidad de usuarios.
Select count(*) as 'Cantidad de Usuarios' from Usuarios
-- (3) Listado con el promedio de costo de certificación de los cursos.
Select avg(Cursos.CostoCertificacion)as'Promedio De Certificacion' From Cursos
-- 4 Listado con el promedio general de calificación de reseñas.
Select avg(Reseñas.Puntaje) as 'Promedio de Calificacion de Reseñas 'From Reseñas
-- (5) Listado con la fecha de estreno de curso más antigua.
Select min(c.Estreno) as 'Fecha de Estreno mas antigua' From Cursos as C
-- 6 Listado con el costo de certificación menos costoso.
Select min(c.CostoCertificacion) as 'Certificacion mas barata' from Cursos as C
-- (7) Listado con el costo total de todos los cursos.
Select Sum(C.CostoCurso) as 'Costo Total' from Cursos as C
-- 8 Listado con la suma total de todos los pagos.
Select Sum(p.Importe) as 'Total de pagos' from Pagos as P
-- 9 Listado con la cantidad de cursos de nivel principiante.
Select count(c.ID) as 'Cantidad de cursos Nivel Principiante'
from Cursos as C
inner Join Niveles as N
on C.IDNivel=N.ID
Where N.Nombre like 'Principiante'
-- 10 Listado con la suma total de todos los pagos realizados en 2019.
Select Sum(p.Importe) as 'Importe Total de pagos 2019'
From Pagos as p
Where year(p.Fecha)=2019
-- (11) Listado con la cantidad de usuarios que son instructores.
Select count(distinct i.IDUsuario )as 'Cantidad de instructores'
From Instructores_x_Curso as I
-- 12 Listado con la cantidad de usuarios distintos que se hayan certificado.
Select count(Distinct i.IDUsuario)as Cantidad_De_Usuarios_Certificados
From Inscripciones as I
inner Join Certificaciones as C on I.ID=c.IDInscripcion
--para ver la tabla como me quedo sin el distinct
Select * From Certificaciones as c
inner Join Inscripciones as i on I.ID=c.IDInscripcion
order by I.IDUsuario
-- (13) Listado con el nombre del país y la cantidad de usuarios de cada país.
Select p.Nombre as Nombre, count(Dat.ID) as Cantidad_Usuarios
From Paises as P
Left Join Datos_Personales as Dat on P.ID=Dat.IDPais
Group by(p.Nombre)
Order by P.Nombre asc
--order by 2 desc es lo mismo de arriba
-- (14) Listado con el apellido y nombres del usuario y el importe más costoso abonado como pago.
--Sólo listar aquellos que hayan abonado más de $7500.
Select Dat.Apellidos +','+ Dat.Nombres as Apenom , max(P.importe)as MaxImporte
From Datos_Personales as Dat
inner Join Usuarios as u on Dat.ID=u.ID
inner join Inscripciones as I on U.ID=i.IDUsuario
inner join Pagos as P on I.ID=P.IDInscripcion
Group by Dat.Apellidos,Dat.Nombres
Having Max(p.Importe) >7500
order by 1 asc
-- 15 Listado con el apellido y nombres de usuario y el importe más costoso de curso al cual se haya inscripto.
Select Dat.Apellidos, Dat.Nombres , Max(C.CostoCurso)as Maxcosto_Curso
From Datos_Personales as Dat
Inner Join Usuarios as U on Dat.ID=U.ID
Inner Join Inscripciones as i on U.ID =I.IDUsuario
Inner Join Cursos as C on I.IDCurso = C.ID
Group By Dat.Apellidos,Dat.Nombres
-- 16 Listado con el nombre del curso, nombre del nivel, cantidad total de clases y duración total del curso en minutos.
select Cursos.Nombre as Curso,Niveles.Nombre as Nivel, count(Clases.ID)as CantidadDeClases, Sum(Clases.Duracion) as duracionDelCurso
From Cursos
left Join Niveles on Cursos.IDNivel=Niveles.ID
left Join Clases on Cursos.ID = Clases.IDCurso
Group by Cursos.Nombre,Niveles.Nombre
-- 17 Listado con el nombre del curso y cantidad de contenidos registrados.
-- Sólo listar aquellos cursos que tengan más de 10 contenidos registrados.
Select Cursos.Nombre as Curso, count(Contenidos.ID) as Cant_Contenido
From Cursos
Inner Join Clases on Cursos.ID=Clases.IDCurso
Inner Join Contenidos on Clases.ID=Contenidos.IDClase
Group by Cursos.Nombre
Having count(Contenidos.ID)>10
-- 18 Listado con nombre del curso, nombre del idioma y cantidad de tipos de idiomas.
Select c.Nombre as Curso ,i.Nombre as Idioma,COUNT(ixc.IDTipo) as Cant_Tipo_Idiomas
From Cursos as C
inner join Idiomas_x_Curso as IxC on C.ID=IxC.IDCurso
Inner join Idiomas as I on IxC.IDIdioma=I.ID
Inner Join TiposIdioma as T on IxC.IDTipo=T.ID
Group By C.Nombre,I.Nombre
-- 19 Listado con el nombre del curso y cantidad de idiomas distintos disponibles.
Select C.Nombre as Curso, count(distinct ixc.IDIdioma) as CantIdiomas
From Cursos as C
Inner Join Idiomas_x_Curso as ixc on C.ID=ixc.IDCurso
inner join Idiomas as i on Ixc.IDIdioma=i.ID
Group by c.Nombre
-- 20 Listado de categorías de curso y cantidad de cursos asociadas a cada categoría.
--Sólo mostrar las categorías con más de 5 cursos.
Select Cat.Nombre as Categoria,count(cxc.IDCategoria)
from Categorias as Cat
inner join Categorias_x_Curso as cxc on Cat.ID=cxc.IDCategoria
inner join Cursos As c on cxc.IDCurso=c.ID
Group by cat.Nombre
having count(cxc.IDCategoria)>5
-- 21 Listado con tipos de contenido y la cantidad de contenidos asociados a cada tipo.
-- Mostrar aquellos tipos que no hayan registrado contenidos con cantidad 0.
Select t.Nombre as Nombre, Count(c.ID) as cantContenido
From TiposContenido as t
inner join Contenidos as c on T.ID=c.IDTipo
Group By T.Nombre
-- 22 Listado con Nombre del curso, nivel, año de estreno y el total recaudado en concepto de inscripciones.
--Listar aquellos cursos sin inscripciones con total igual a $0.
Select C.Nombre as Curso,N.Nombre as Nivel,year(C.Estreno) as AñoEstreno, sum(i.Costo) as TotalRecaudado
From Cursos as c
left join Niveles as N on C.IDNivel=n.ID
left join Inscripciones as i on c.ID=i.IDCurso
group by C.Nombre,n.Nombre,c.Estreno
-- LA OPCION QUE CREEMOS CORRECTA
Select C.Nombre as Curso,N.Nombre as Nivel,year(C.Estreno) as AñoEstreno,sum(case when p.importe is null then 0 else p.Importe end) as TotalRecaudado
From Cursos as c
left join Niveles as N on C.IDNivel=n.ID
left join Inscripciones as i on c.ID=i.IDCurso
Left join Pagos as p on i.ID=p.IDInscripcion
group by C.Nombre,n.Nombre,c.Estreno
-- 23 Listado con Nombre del curso, costo de cursado y certificación y cantidad de usuarios distintos
--inscriptos cuyo costo de cursado sea menor a $10000 y cuya cantidad de usuarios inscriptos sea menor a 5.
--Listar aquellos cursos sin inscripciones con cantidad 0.
Select c.Nombre as Curso,c.CostoCurso as CostoCursado, c.CostoCertificacion as CostoCertificacion,
case when c.CostoCurso < 10000 then count (distinct I.idusuario) end as CantUsuarios
From Cursos as c
left join Inscripciones as i on C.ID=i.IDCurso
Group by c.Nombre, c.CostoCurso,c.CostoCertificacion
having c.CostoCurso < 10000 and count( distinct I.idusuario)<5
-- 24 Listado con Nombre del curso, fecha de estreno y nombre del nivel del curso que más recaudó en concepto de certificaciones.
Select top (1) c.Nombre as Curso,c.Estreno as FechaEstreno ,n.Nombre as Nivel
from Cursos as C
inner join Niveles as n on c.IDNivel=n.ID
inner join Inscripciones as i on C.ID=i.IDCurso
inner join Certificaciones as Cer on i.ID=cer.IDInscripcion
Group by C.Nombre,c.Estreno,n.Nombre
order by Sum(Cer.Costo) asc
-- 25 Listado con Nombre del idioma del idioma más utilizado como subtítulo.
Select top(1) i.Nombre
From Idiomas as i
inner join Idiomas_x_Curso as ic on i.ID=ic.IDIdioma
inner join TiposIdioma as tc on ic.IDTipo=tc.ID
where tc.Nombre like 'subtitulo'
group by i.Nombre
order by count(i.ID) desc
-- 26 Listado con Nombre del curso y promedio de puntaje de reseñas apropiadas.
Select c.Nombre as curso, avg(r.Puntaje) as Puntaje
From Cursos as c
inner join Inscripciones as i on C.ID=i.IDCurso
inner join Reseñas as r on i.ID=r.IDInscripcion
where r.Inapropiada=0
group by C.Nombre
-- 27 Listado con Nombre de usuario y la cantidad de reseñas inapropiadas que registró.
select Usuarios.NombreUsuario as Usuario,
case when Reseñas.Inapropiada = 1 then COUNT(Reseñas.Inapropiada) end as Cant
From Usuarios
left join Inscripciones on Usuarios.ID=Inscripciones.IDUsuario
left join Reseñas on Inscripciones.ID=Reseñas.IDInscripcion
Group by Usuarios.NombreUsuario,Reseñas.Inapropiada
Having COUNT(Reseñas.Inapropiada)>0
select Usuarios.NombreUsuario as Usuario,COUNT(Reseñas.Puntaje) as CantResInapropiadas
From Usuarios
left join Inscripciones on Usuarios.ID=Inscripciones.IDUsuario
left join Reseñas on Inscripciones.ID=Reseñas.IDInscripcion
where Reseñas.Inapropiada=1
Group by Usuarios.NombreUsuario,Reseñas.Inapropiada
/*
select u.NombreUsuario, sum(case when r.Inapropiada =1 then 1 else 0 end) as 'Cantidad de reseñas inapropiadas'
from Usuarios as u left join Inscripciones as i on u.ID=i.IDUsuario
left join Reseñas as r on r.IDInscripcion=i.ID
group by u.NombreUsuario
order by u.NombreUsuario asc
*/
select u.NombreUsuario, sum(cast(r.inapropiada as int)) as 'Cantidad de reseñas inapropiadas'
from Usuarios as u left join Inscripciones as i on u.ID=i.IDUsuario
left join Reseñas as r on r.IDInscripcion=i.ID
group by u.NombreUsuario
order by u.NombreUsuario asc
-- 28 Listado con Nombre del curso, nombre y apellidos de usuarios y la cantidad de veces que dicho usuario realizó dicho curso.
--No mostrar cursos y usuarios que contabilicen cero.
Select c.Nombre as Curso,dat.Nombres,dat.Apellidos,count(i.IDCurso) as cantRealizada
from Cursos as c
inner join Inscripciones as i on C.ID=i.IDCurso
inner join Usuarios as u on i.IDUsuario=u.ID
inner join Datos_Personales as dat on u.ID=dat.ID
group by c.Nombre,dat.Nombres,dat.Apellidos
order by count(i.IDCurso) desc
-- 29 Listado con Apellidos y nombres, mail y duración total en concepto de clases de cursos a los que se haya inscripto.
--Sólo listar información de aquellos registros cuya duración total supere los 400 minutos.
Select dat.Apellidos as Apellidos,dat.Nombres as Nombres ,dat.Email as Email,sum(Cla.Duracion) as Duracion
From Datos_Personales as dat
Inner Join Usuarios as U on Dat.ID=U.ID
Inner Join Inscripciones as i on U.ID =I.IDUsuario
Inner Join Cursos as C on I.IDCurso = C.ID
inner join Clases as Cla on C.ID=Cla.IDCurso
group by dat.Apellidos,dat.Nombres,dat.Email
having sum(Cla.Duracion)>1200
Order by Duracion desc
-- 30 Listado con nombre del curso y recaudación total.
--La recaudación total consiste en la sumatoria de costos de inscripción y de certificación.
--Listarlos ordenados de mayor a menor por recaudación.
SElect C.Nombre as Curso, Sum(i.Costo + cer.Costo) as RecaudacionTotal
from Cursos as c
inner join Inscripciones as i on c.ID=i.IDCurso
inner join Certificaciones as cer on i.ID=cer.IDInscripcion
group by C.Nombre
order by Sum(i.Costo + cer.Costo) desc
|
ALTER TABLE employee ADD company_code VARCHAR(255) AFTER employee_code;
UPDATE employee
SET company_code = (
SELECT company_code
FROM company
);
SELECT employee.company_code, company.company_name, employee.employee_code, employee.employee_name,
(
SELECT position.position_name
FROM position
WHERE employee_position.position_code = position.position_code
) AS position_name, employee_position.valid_from, employee_position.valid_to
FROM employee
INNER JOIN company ON employee.company_code = company.company_code
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
WHERE employee_position.position_code IN (
SELECT position_code
FROM position
WHERE position_name IN ("IT Auditor", "IT Staff")
)
ORDER BY employee_position.position_code
v
SELECT employee.company_code, company.company_name, employee.employee_code, employee.employee_name,
position.position_name, employee_position.valid_from, employee_position.valid_to
FROM employee
INNER JOIN company ON employee.company_code = company.company_code
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE position.position_name IN ("IT Auditor", "IT Staff") AND employee_position.valid_to >= '2019-05-13'
ORDER BY position.position_code
-----------------------------------------------------------------------------------------------------------
UPDATE employee_position
INNER JOIN position ON employee_position.position_code = position.position_code
SET employee_position.position_code = (
SELECT position_code
FROM position
WHERE position_name = "Software Developer"
)
WHERE position.position_name IN ("IT Auditor", "IT Staff") AND employee_position.valid_to >= '2019-05-13'
SELECT employee.company_code, company.company_name, employee.employee_code, employee.employee_name,
position.position_name, employee_position.valid_from, employee_position.valid_to
FROM employee
INNER JOIN company ON employee.company_code = company.company_code
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE position.position_name IN ("Software Developer") AND employee_position.valid_to >= '2019-05-13'
ORDER BY position.position_code
-----------------------------------------------------------------------------------------------------------
INSERT INTO employee_position(employee_code, position_code, valid_from, valid_to)
SELECT employee_code, position_code, valid_from, valid_to
FROM employee_position
-----------------------------------------------------------------------------------------------------------
/*
kalo dia "Active" (tanggal sekarang ada diantara valid from & valid to), di kolomnya muncul "Active"
vice versa.
*/
SELECT employee.company_code, company.company_name, employee.employee_code, employee.employee_name,
position.position_name, (
CASE
WHEN CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
THEN "ACTIVE"
ELSE "NOT ACTIVE" END
) AS 'Validity'
FROM employee
INNER JOIN company ON employee.company_code = company.company_code
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE position.position_name IN ("Software Developer") AND employee_position.valid_to >= '2019-05-13'
ORDER BY Validity
SELECT employee.company_code, company.company_name, employee.employee_code, employee.employee_name,
position.position_name, IF(CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to, "Active", "Not Active") AS 'validity'
FROM employee
INNER JOIN company ON employee.company_code = company.company_code
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE position.position_name IN ("Software Developer") AND employee_position.valid_to >= '2019-05-13'
ORDER BY validity
-----------------------------------------------------------------------------------------------------------
SELECT distinct if(employee_position.position_code = "POS1", employee.employee_name, NULL) AS position_1,
if(employee_position.position_code = "POS2", employee.employee_name, NULL) AS position_2,
if(employee_position.position_code = "POS3", employee.employee_name, NULL) AS position_3,
if(employee_position.position_code = "POS4", employee.employee_name, NULL) AS position_4,
if(employee_position.position_code = "POS5", employee.employee_name, NULL) AS position_5,
if(employee_position.position_code = "POS6", employee.employee_name, NULL) AS position_6,
if(employee_position.position_code = "POS7", employee.employee_name, NULL) AS position_7,
if(employee_position.position_code = "POS8", employee.employee_name, NULL) AS position_8,
if(employee_position.position_code = "POS9", employee.employee_name, NULL) AS position_9,
if(employee_position.position_code = "POS10", employee.employee_name, NULL) AS position_10
FROM employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code;
SELECT DISTINCT (if employee_position.position_code = "POS1" then employee.employee_name) AS position_1,
(if employee_position.position_code = "POS2" then employee.employee_name) AS position_2,
(if employee_position.position_code = "POS3" then employee.employee_name) AS position_3,
(if employee_position.position_code = "POS4" then employee.employee_name) AS position_4,
(if employee_position.position_code = "POS5" then employee.employee_name) AS position_5,
(if employee_position.position_code = "POS6" then employee.employee_name) AS position_6,
(if employee_position.position_code = "POS7" then employee.employee_name) AS position_7,
(if employee_position.position_code = "POS8" then employee.employee_name) AS position_8,
(if employee_position.position_code = "POS9" then employee.employee_name) AS position_9,
(if employee_position.position_code = "POS10" then employee.employee_name) AS position_10,
FROM employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
----------------------------
SELECT IFNULL(TABLE1.position_1, " ") POS1, IFNULL(TABLE2.position_2, " ") POS2, IFNULL(TABLE3.position_3, " ") POS3, IFNULL(TABLE4.position_4, " ") POS4, IFNULL(TABLE5.position_5, " ") POS5,
IFNULL(TABLE6.position_6, " ") POS6, IFNULL(TABLE7.position_7, " ") POS7, IFNULL(TABLE8.position_8, " ") POS8, IFNULL(TABLE9.position_9, " ") POS9, IFNULL(TABLE10.position_10, " ") POS10
FROM (
SELECT (
case
when if(employee_position.position_code = "POS1", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to then @t1 := @t1 + 1
ELSE NULL END
) AS row_num, if(employee_position.position_code = "POS1", employee.employee_name, NULL) AS position_1
FROM (SELECT @t1 := 0) AS m, employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE if(employee_position.position_code = "POS1", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
ORDER BY row_num
) AS TABLE1
RIGHT JOIN (
SELECT (
case
when if(employee_position.position_code = "POS2", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to then @t2 := @t2 + 1
ELSE NULL END
) AS row_num, if(employee_position.position_code = "POS2", employee.employee_name, NULL) AS position_2
FROM (SELECT @t2 := 0) AS m, employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE if(employee_position.position_code = "POS2", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
ORDER BY row_num
) AS TABLE2 ON TABLE1.row_num = TABLE2.row_num
RIGHT JOIN (
SELECT (
case
when if(employee_position.position_code = "POS3", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to then @t3 := @t3 + 1
ELSE NULL END
) AS row_num, if(employee_position.position_code = "POS3", employee.employee_name, NULL) AS position_3
FROM (SELECT @t3 := 0) AS m, employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE if(employee_position.position_code = "POS3", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
ORDER BY row_num
) AS TABLE3 ON TABLE2.row_num = TABLE3.row_num
LEFT JOIN (
SELECT (
case
when if(employee_position.position_code = "POS4", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to then @t4 := @t4 + 1
ELSE NULL END
) AS row_num, if(employee_position.position_code = "POS4", employee.employee_name, NULL) AS position_4
FROM (SELECT @t4 := 0) AS m, employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE if(employee_position.position_code = "POS4", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
ORDER BY row_num
) AS TABLE4 ON TABLE3.row_num = TABLE4.row_num
LEFT JOIN (
SELECT (
case
when if(employee_position.position_code = "POS5", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to then @t5 := @t5 + 1
ELSE NULL END
) AS row_num, if(employee_position.position_code = "POS5", employee.employee_name, NULL) AS position_5
FROM (SELECT @t5 := 0) AS m, employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE if(employee_position.position_code = "POS5", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
ORDER BY row_num
) AS TABLE5 ON TABLE3.row_num = TABLE5.row_num
LEFT JOIN (
SELECT (
case
when if(employee_position.position_code = "POS6", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to then @t6 := @t6 + 1
ELSE NULL END
) AS row_num, if(employee_position.position_code = "POS6", employee.employee_name, NULL) AS position_6
FROM (SELECT @t6 := 0) AS m, employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE if(employee_position.position_code = "POS6", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
ORDER BY row_num
) AS TABLE6 ON TABLE3.row_num = TABLE6.row_num
LEFT JOIN (
SELECT (
case
when if(employee_position.position_code = "POS7", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to then @t7 := @t7 + 1
ELSE NULL END
) AS row_num, if(employee_position.position_code = "POS7", employee.employee_name, NULL) AS position_7
FROM (SELECT @t7 := 0) AS m, employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE if(employee_position.position_code = "POS7", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
ORDER BY row_num
) AS TABLE7 ON TABLE3.row_num = TABLE7.row_num
LEFT JOIN (
SELECT (
case
when if(employee_position.position_code = "POS8", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to then @t8 := @t8 + 1
ELSE NULL END
) AS row_num, if(employee_position.position_code = "POS8", employee.employee_name, NULL) AS position_8
FROM (SELECT @t8 := 0) AS m, employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE if(employee_position.position_code = "POS8", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
ORDER BY row_num
) AS TABLE8 ON TABLE3.row_num = TABLE8.row_num
LEFT JOIN (
SELECT (
case
when if(employee_position.position_code = "POS9", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to then @t9 := @t9 + 1
ELSE NULL END
) AS row_num, if(employee_position.position_code = "POS9", employee.employee_name, NULL) AS position_9
FROM (SELECT @t9 := 0) AS m, employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE if(employee_position.position_code = "POS9", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
ORDER BY row_num
) AS TABLE9 ON TABLE3.row_num = TABLE9.row_num
LEFT JOIN (
SELECT (
case
when if(employee_position.position_code = "POS10", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to then @t10 := @t10 + 1
ELSE NULL END
) AS row_num, if(employee_position.position_code = "POS10", employee.employee_name, NULL) AS position_10
FROM (SELECT @t10 := 0) AS m, employee
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE if(employee_position.position_code = "POS10", employee.employee_name, NULL) IS NOT NULL
AND CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to
ORDER BY row_num
) AS TABLE10 ON TABLE3.row_num = TABLE10.row_num;
------------------
-- JAVA TESTING QUERIES
jdbc:mysql://localhost:3306/mydb?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC
SELECT employee.company_code, company.company_name, employee.employee_code, employee.employee_name,
position.position_name, IF(CURDATE() BETWEEN employee_position.valid_from AND employee_position.valid_to, "Active", "Not Active") AS 'validity'
FROM employee
INNER JOIN company ON employee.company_code = company.company_code
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE employee_position.valid_to >= '2019-05-13'
ORDER BY validity;
SELECT employee.company_code, company.company_name, employee.employee_code, employee.employee_name,
position.position_name, employee_position.valid_from, employee_position.valid_to
FROM employee
INNER JOIN company ON employee.company_code = company.company_code
INNER JOIN employee_position ON employee.employee_code = employee_position.employee_code
INNER JOIN position ON position.position_code = employee_position.position_code
WHERE employee_position.valid_to >= '2019-05-13'
ORDER BY position.position_code |
Insert into FIRST_LANGUAGE values (1101,'Noun',12,21,2,3,'ads','tas','tus');
Insert into FIRST_LANGUAGE values (1102,'Noun',13,22,1,4,'fds','weq','ax');
Insert into FIRST_LANGUAGE values (1103,'Verb',14,23,2,3,'pitj','morder','bra');
INSERT INTO TRANSCRIPTION(ID, ID_FIRST, ID_GERMAN,KNOWLEDGE_GERWORD, KNOWLEDGE_TRANSCRIPTION,NAME)
SELECT ID_TRANS, ID,ID_SECOND,0 AS KNOWLEDGE_GERWORD, 0 AS KNOWLEDGE_TRANSCRIPTION,' ' AS NAME FROM FIRST_LANGUAGE
|
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_lancto_contabil`
--
CREATE TABLE `tb_lancto_contabil` (
`Codigo` int(11) NOT NULL,
`Pessoa` int(11) NOT NULL,
`CentroCusto` int(11) NOT NULL,
`Credito` int(11) NOT NULL,
`Debito` int(11) NOT NULL,
`Valor` double NOT NULL,
`Data` date NOT NULL,
`HP` int(11) NOT NULL,
`Descricao` varchar(50) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
CREATE ROLE career;
ALTER ROLE career WITH SUPERUSER
INHERIT
CREATEROLE
CREATEDB
LOGIN
NOREPLICATION
NOBYPASSRLS
PASSWORD 'md5d7980ace5b59ea073a4c25bd767b9c8d';
CREATE DATABASE career WITH TEMPLATE = template0 OWNER = postgres;
GRANT ALL ON DATABASE career TO career;
|
-- Пусть задан некоторый пользователь.
-- Из всех друзей этого пользователя найдите человека, который больше всех общался с нашим пользователем.
SELECT CONCAT(
'Пользователь ',
first_name,
' ',
last_name,
' ',
'Больше всех общался с пользователем ',
(SELECT first_name, last_name FROM profiles WHERE user_id IN (
SELECT to_user_id AS user_id FROM (
SELECT to_user_id, COUNT(from_user_id) AS counter
FROM messages WHERE is_delivered = '1' AND from_user_id = '13' AND to_user_id IN (
(SELECT friend_id AS to_user_id
FROM friendship
WHERE user_id = 13
AND status_id IN (
SELECT id FROM friendship_statuses
WHERE name = 'Confirmed'
)
)
UNION
(SELECT user_id
FROM friendship
WHERE friend_id = 13
AND status_id IN (
SELECT id FROM friendship_statuses
WHERE name = 'Confirmed'
)
)
) AS to_user_id
GROUP BY to_user_id
ORDER BY counter DESC
LIMIT 1
)
)
)
FROM profiles WHERE user_id = '13'
)
;
-- тут совсем запутался как все объединить. кусками при некоторых перестановках работает
-- все вместе - нет
-- Подсчитать общее количество лайков, которые получили 10 самых молодых пользователей.
SELECT COUNT(target_id) AS likes FROM likes WHERE target_id IN (
SELECT user_id FROM profiles WHERE user_id IN (
SELECT target_id FROM likes WHERE target_type_id = '2')
ORDER BY UNIX_TIMESTAMP(STR_TO_DATE(birthdate, '%Y-%m-%d')) DESC
LIMIT 10
)
;
-- внутренний запрос отдельно работает, внешний ругается на использование LIMIT во вложенном SELECT
-- как это обойти не обновляя MySQL?
-- Определить кто больше поставил лайков (всего) - мужчины или женщины?
-- мужчины
SELECT COUNT(user_id) AS mens FROM likes WHERE id IN (
SELECT user_id FROM profiles WHERE sex = 'm'
);
-- женщины
SELECT COUNT(user_id) AS womans FROM likes WHERE id IN (
SELECT user_id FROM profiles WHERE sex = 'f'
);
-- 5. Найти 10 пользователей, которые проявляют наименьшую активность в использовании
-- социальной сети.
SELECT first_name, last_name FROM users WHERE id IN (
SELECT user_id AS id FROM (
SELECT user_id, COUNT(*) AS counter FROM likes
GROUP BY user_id
ORDER BY counter
) AS id
)
LIMIT 10
;
|
USE homestead;
INSERT INTO
document_types (id,namespace, document_type, lang_ua)
VALUES
(1,'tender', 'notice', 'Повідомлення про закупівлю'),
(2,'tender', 'biddingDocuments', 'Документи закупівлі'),
(3,'tender', 'technicalSpecifications', 'Технічні специфікації'),
(4,'tender', 'evaluationCriteria', 'Критерії оцінки'),
(5,'tender', 'clarifications', 'Пояснення до питань заданих учасниками'),
(6,'tender', 'eligibilityCriteria', 'Критерії прийнятності'),
(7,'tender', 'shortlistedFirms', 'Фірми у короткому списку'),
(8,'tender', 'riskProvisions', 'Положення для управління ризиками та зобов’язаннями'),
(9,'tender', 'billOfQuantity', 'Кошторис'),
(10,'tender', 'bidders', 'Інформація про учасників'),
(11,'tender', 'conflictOfInterest', 'Виявлені конфлікти інтересів'),
(12,'tender', 'debarments', 'Недопущення до закупівлі'),
(13,'award', 'notice', 'Повідомлення про рішення'),
(14,'award', 'evaluationReports', 'Звіт про оцінку'),
(15,'award', 'winningBid', 'Пропозиція, що перемогла'),
(16,'award', 'complaints', 'Скарги та рішення'),
(17,'contract', 'notice', 'Повідомлення про договір'),
(18,'contract', 'contractSigned', 'Підписаний договір'),
(19,'contract', 'contractArrangements', 'Заходи для припинення договору'),
(20,'contract', 'contractSchedule', 'Розклад та етапи'),
(21,'contract', 'contractAnnexe', 'Додатки до договору'),
(22,'contract', 'contractGuarantees', 'Гарантії'),
(23,'contract', 'subContract', 'Субпідряд'); |
CREATE TABLE person
(
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(250),
birth_date LONG(250)
);
CREATE TABLE users
(
id INT NOT NULL AUTO_INCREMENT,
login VARCHAR(250),
password VARCHAR(250)
) |
SELECT * FROM Sailors;
SELECT Sailors.A FROM Sailors;
SELECT Boats.F, Boats.D FROM Boats;
SELECT Reserves.G, Reserves.H FROM Reserves;
SELECT * FROM Sailors WHERE Sailors.B >= Sailors.C;
SELECT Sailors.A FROM Sailors WHERE Sailors.B >= Sailors.C
SELECT Sailors.A FROM Sailors WHERE Sailors.B >= Sailors.C AND Sailors.B < Sailors.C;
SELECT * FROM Reserves, Boats ORDER BY Reserves.G;
SELECT * FROM Reserves, Boats WHERE Reserves.G = 4;
SELECT * FROM Sailors, Reserves WHERE Sailors.A = Reserves.G;
SELECT * FROM Sailors, Reserves, Boats WHERE Sailors.A = Reserves.G AND Reserves.H = Boats.D ORDER BY Sailors.A;
SELECT * FROM Sailors, Reserves, Boats WHERE Sailors.A = Reserves.G AND Reserves.H = Boats.D AND Sailors.B < 150;
SELECT Sailors.C, Reserves.H FROM Sailors, Reserves, Boats WHERE Sailors.A = Reserves.G AND Reserves.H = Boats.D AND Sailors.B < 150;
SELECT * FROM TestTable3;
SELECT * FROM TestTable3, Boats WHERE TestTable3.N < Boats.D;
SELECT * FROM TestTable3, TestTable4;
SELECT * FROM Sailors S;
SELECT * FROM Sailors S WHERE S.A < 3;
SELECT S.A FROM Sailors S;
SELECT * FROM Sailors S, Reserves R WHERE S.A = R.G;
SELECT S.C, R.H FROM Sailors S, Reserves R, Boats B WHERE S.A = R.G AND R.H = B.D AND S.B < 150;
SELECT * FROM Sailors S1, Sailors S2 WHERE S1.A < S2.A ORDER BY S1.A;
SELECT * FROM Sailors S1, Sailors S2, Reserves R WHERE S1.A < S2.A AND S1.A = R.G ORDER BY S1.A;
SELECT S1.A, S2.A, S3.A FROM Sailors S1, Sailors S2, Sailors S3 WHERE S1.A < S2.A AND S2.A < S3.A AND S3.A < 5;
SELECT DISTINCT Reserves.G FROM Reserves;
SELECT DISTINCT R.G FROM Reserves R;
SELECT DISTINCT * FROM Sailors;
SELECT DISTINCT * FROM TestTable1;
SELECT * FROM TestTable2 WHERE TestTable2.K >= TestTable2.L AND TestTable2.L <= TestTable2.M;
SELECT * FROM TestTable1 T1, TestTable2 T2 WHERE T1.J = T2.M ORDER BY T1.J;
SELECT * FROM TestTable2 T2A, TestTable2 T2B ORDER BY T2A.K;
SELECT TestTable2.M, TestTable2.L FROM TestTable2 ORDER BY TestTable2.L;
SELECT * FROM TestTable3 ORDER BY TestTable3.N;
SELECT * FROM Sailors ORDER BY Sailors.B;
SELECT Boats.F, Boats.D FROM Boats ORDER BY Boats.D;
SELECT * FROM Sailors, Reserves, Boats WHERE Sailors.A = Reserves.G AND Reserves.H = Boats.D ORDER BY Sailors.C;
SELECT * FROM Sailors, Reserves, Boats WHERE Sailors.A = Reserves.G AND Reserves.H = Boats.D ORDER BY Sailors.C, Boats.F;
SELECT DISTINCT * FROM Sailors, Reserves, Boats WHERE Sailors.A = Reserves.G AND Reserves.H = Boats.D ORDER BY Sailors.C, Boats.F;
SELECT B.F, B.D FROM Boats B ORDER BY B.D;
SELECT * FROM Sailors S, Reserves R, Boats B WHERE S.A = R.G AND R.H = B.D ORDER BY S.C;
|
-- phpMyAdmin SQL Dump
-- version 4.3.11
-- http://www.phpmyadmin.net
--
-- Vært: 127.0.0.1
-- Genereringstid: 02. 10 2019 kl. 19:36:45
-- Serverversion: 5.6.24
-- PHP-version: 5.6.8
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: `cmk_furnitures`
--
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `articles`
--
CREATE TABLE IF NOT EXISTS `articles` (
`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`content` text NOT NULL,
`created_at` date NOT NULL,
`fk_user` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `categories`
--
CREATE TABLE IF NOT EXISTS `categories` (
`id` int(11) NOT NULL,
`name` varchar(20) DEFAULT NULL,
`description` text
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
--
-- Data dump for tabellen `categories`
--
INSERT INTO `categories` (`id`, `name`, `description`) VALUES
(8, 'Bukser', 'Bukser til alle'),
(9, 'test', 'fdgdfg');
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `contact`
--
CREATE TABLE IF NOT EXISTS `contact` (
`id` int(11) NOT NULL,
`name` varchar(60) NOT NULL,
`adress` varchar(255) DEFAULT NULL,
`phone` varchar(12) DEFAULT NULL,
`email` varchar(55) NOT NULL,
`message` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `designers`
--
CREATE TABLE IF NOT EXISTS `designers` (
`id` int(11) NOT NULL,
`name` varchar(40) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;
--
-- Data dump for tabellen `designers`
--
INSERT INTO `designers` (`id`, `name`) VALUES
(1, 'Karl Rüdiger'),
(7, 'dsfsdf'),
(8, 'test');
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `globals`
--
CREATE TABLE IF NOT EXISTS `globals` (
`id` int(11) NOT NULL,
`sitename` varchar(30) NOT NULL,
`sitedescription` text NOT NULL,
`street` varchar(60) NOT NULL,
`street_number` varchar(20) NOT NULL,
`postal_code` int(11) NOT NULL,
`city` varchar(35) NOT NULL,
`phone` varchar(15) NOT NULL,
`telefax` varchar(20) NOT NULL,
`email` varchar(80) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
--
-- Data dump for tabellen `globals`
--
INSERT INTO `globals` (`id`, `sitename`, `sitedescription`, `street`, `street_number`, `postal_code`, `city`, `phone`, `telefax`, `email`) VALUES
(1, 'CMK Møbler', 'Vi handler med de bedste møbler.', 'gadenfgh', '1', 4444, 'Franseby', '12345678', '32165487', 'test2@test2.dk');
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `images`
--
CREATE TABLE IF NOT EXISTS `images` (
`id` int(11) NOT NULL,
`name` varchar(70) NOT NULL,
`fk_product` int(11) NOT NULL,
`fk_standard_img` tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8;
--
-- Data dump for tabellen `images`
--
INSERT INTO `images` (`id`, `name`, `fk_product`, `fk_standard_img`) VALUES
(49, '1568288335847_computer1.png', 22, 0),
(50, '1568288335848_computer2.png', 0, 0),
(58, '1568978156542_delicious_32.png', 0, 0),
(59, '1568978156545_deviantart_32.png', 0, 0),
(60, '1568978156543_designmoo_32.png', 0, 0);
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `newsletter`
--
CREATE TABLE IF NOT EXISTS `newsletter` (
`id` int(11) NOT NULL,
`email` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `opening_hours`
--
CREATE TABLE IF NOT EXISTS `opening_hours` (
`id` int(11) NOT NULL,
`weekday` varchar(45) NOT NULL,
`opens` time DEFAULT NULL,
`closing` time DEFAULT NULL,
`closed` tinyint(4) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
--
-- Data dump for tabellen `opening_hours`
--
INSERT INTO `opening_hours` (`id`, `weekday`, `opens`, `closing`, `closed`) VALUES
(1, 'Mandag', '13:00:00', '17:00:00', 0),
(2, 'Tirsdag', '08:00:00', '17:00:00', 0),
(3, 'Onsdag', '08:00:00', '17:00:00', 0),
(4, 'Torsdag', '08:00:00', '17:00:00', 0),
(5, 'Fredag', '08:00:00', '17:00:00', 0),
(6, 'Lørdag', '08:00:00', '17:00:00', 0),
(7, 'Søndag', '00:00:00', '00:00:00', 1);
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `products`
--
CREATE TABLE IF NOT EXISTS `products` (
`id` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
`description` text NOT NULL,
`price` decimal(6,2) NOT NULL,
`year` int(11) NOT NULL,
`item_number` int(20) NOT NULL,
`fk_designer` int(11) NOT NULL,
`fk_category` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `profiles`
--
CREATE TABLE IF NOT EXISTS `profiles` (
`id` int(11) NOT NULL,
`firstname` varchar(45) NOT NULL,
`lastname` varchar(45) NOT NULL,
`email` varchar(50) NOT NULL,
`streetname` varchar(45) NOT NULL,
`street_no` varchar(10) NOT NULL,
`zip` int(11) NOT NULL,
`city` varchar(30) NOT NULL,
`country` varchar(25) NOT NULL,
`phone` varchar(15) NOT NULL,
`gender` varchar(10) NOT NULL,
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
--
-- Data dump for tabellen `profiles`
--
INSERT INTO `profiles` (`id`, `firstname`, `lastname`, `email`, `streetname`, `street_no`, `zip`, `city`, `country`, `phone`, `gender`, `created`) VALUES
(13, '', '', 'test@test.dk', '', '', 0, '', '', '', '', '2019-08-16 12:23:23'),
(14, '', '', 'test2@test2.dk', '', '', 0, '', '', '', '', '2019-09-11 14:13:15');
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `roles`
--
CREATE TABLE IF NOT EXISTS `roles` (
`id` int(11) NOT NULL,
`name` varchar(45) NOT NULL,
`level` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
--
-- Data dump for tabellen `roles`
--
INSERT INTO `roles` (`id`, `name`, `level`) VALUES
(1, 'superadmin', 100),
(2, 'admin', 99),
(3, 'employer', 50),
(4, 'customer', 10),
(5, 'guest', 1);
-- --------------------------------------------------------
--
-- Struktur-dump for tabellen `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL,
`username` varchar(45) NOT NULL,
`password` varchar(72) NOT NULL,
`fk_profile` int(11) NOT NULL,
`fk_role` int(11) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
--
-- Data dump for tabellen `users`
--
INSERT INTO `users` (`id`, `username`, `password`, `fk_profile`, `fk_role`) VALUES
(3, 'test', '$2a$10$nk9BAJ6ZDkI7VL6JPOrKR.wTYKarRSlNXdDoACK9q4YuQ/d/SeeYK', 13, 1),
(4, 'test2', '$2a$10$GYpwwVSYXhKKiobV/QbwCu2LagAyjXqS0gZoqFU5Eq1teYn3l4L66', 14, 1);
--
-- Begrænsninger for dumpede tabeller
--
--
-- Indeks for tabel `articles`
--
ALTER TABLE `articles`
ADD PRIMARY KEY (`id`);
--
-- Indeks for tabel `categories`
--
ALTER TABLE `categories`
ADD PRIMARY KEY (`id`);
--
-- Indeks for tabel `contact`
--
ALTER TABLE `contact`
ADD PRIMARY KEY (`id`);
--
-- Indeks for tabel `designers`
--
ALTER TABLE `designers`
ADD PRIMARY KEY (`id`);
--
-- Indeks for tabel `globals`
--
ALTER TABLE `globals`
ADD PRIMARY KEY (`id`);
--
-- Indeks for tabel `images`
--
ALTER TABLE `images`
ADD PRIMARY KEY (`id`);
--
-- Indeks for tabel `newsletter`
--
ALTER TABLE `newsletter`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `email_UNIQUE` (`email`);
--
-- Indeks for tabel `opening_hours`
--
ALTER TABLE `opening_hours`
ADD PRIMARY KEY (`id`);
--
-- Indeks for tabel `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`id`), ADD KEY `fk_category_idx` (`fk_category`);
--
-- Indeks for tabel `profiles`
--
ALTER TABLE `profiles`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `email_UNIQUE` (`email`);
--
-- Indeks for tabel `roles`
--
ALTER TABLE `roles`
ADD PRIMARY KEY (`id`);
--
-- Indeks for tabel `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `username_UNIQUE` (`username`), ADD KEY `fk_user_profiles_idx` (`fk_profile`), ADD KEY `fk_user_roles_idx` (`fk_role`);
--
-- Brug ikke AUTO_INCREMENT for slettede tabeller
--
--
-- Tilføj AUTO_INCREMENT i tabel `articles`
--
ALTER TABLE `articles`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Tilføj AUTO_INCREMENT i tabel `categories`
--
ALTER TABLE `categories`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=10;
--
-- Tilføj AUTO_INCREMENT i tabel `contact`
--
ALTER TABLE `contact`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Tilføj AUTO_INCREMENT i tabel `designers`
--
ALTER TABLE `designers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=9;
--
-- Tilføj AUTO_INCREMENT i tabel `globals`
--
ALTER TABLE `globals`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- Tilføj AUTO_INCREMENT i tabel `images`
--
ALTER TABLE `images`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=61;
--
-- Tilføj AUTO_INCREMENT i tabel `newsletter`
--
ALTER TABLE `newsletter`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Tilføj AUTO_INCREMENT i tabel `opening_hours`
--
ALTER TABLE `opening_hours`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=8;
--
-- Tilføj AUTO_INCREMENT i tabel `products`
--
ALTER TABLE `products`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Tilføj AUTO_INCREMENT i tabel `profiles`
--
ALTER TABLE `profiles`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=15;
--
-- Tilføj AUTO_INCREMENT i tabel `roles`
--
ALTER TABLE `roles`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6;
--
-- Tilføj AUTO_INCREMENT i tabel `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;
--
-- Begrænsninger for dumpede tabeller
--
--
-- Begrænsninger for tabel `products`
--
ALTER TABLE `products`
ADD CONSTRAINT `fk_category_id` FOREIGN KEY (`fk_category`) REFERENCES `categories` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Begrænsninger for tabel `users`
--
ALTER TABLE `users`
ADD CONSTRAINT `fk_user_profiles` FOREIGN KEY (`fk_profile`) REFERENCES `profiles` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_user_roles` FOREIGN KEY (`fk_role`) REFERENCES `roles` (`id`) 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 */;
|
CREATE SEQUENCE mailchimp_id_seq;
CREATE TABLE public.mailchimp
(
id smallint NOT NULL DEFAULT nextval('mailchimp_id_seq'),
first_name character varying(255) DEFAULT NULL,
last_name character varying(255) DEFAULT NULL,
email character varying(255) DEFAULT NULL UNIQUE,
CONSTRAINT user_pkey PRIMARY KEY (id),
CONSTRAINT user_email_key UNIQUE (email)
);
ALTER SEQUENCE mailchimp_id_seq OWNED BY mailchimp.id;
ALTER TABLE mailchimp OWNER TO mailchimp ;
|
CREATE TABLE transaction
(
uuid UUID NOT NULL,
from_account_id UUID,
to_account_id UUID NOT NULL,
amount BIGINT(20) NOT NULL,
status ENUM('NEW', 'FAILED', 'COMPLETED') NOT NULL,
type ENUM('CREDIT', 'TRANSFER') NOT NULL,
PRIMARY KEY (uuid),
CONSTRAINT fk_from_account_id FOREIGN KEY (from_account_id) REFERENCES account (uuid),
CONSTRAINT fk_to_account_id FOREIGN KEY (to_account_id) REFERENCES account (uuid)
); |
CREATE SEQUENCE seq_user_transaction_id AS BIGINT START WITH 1;
CREATE TABLE user_transaction (
id BIGINT PRIMARY KEY,
type INTEGER NOT NULL,
external_id VARCHAR(36) NOT NULL,
account_id BIGINT,
amount_value NUMERIC(16, 2) NOT NULL,
amount_currency VARCHAR(3) NOT NULL
);
CREATE UNIQUE INDEX idx_user_transaction_external_id ON user_transaction (external_id);
CREATE INDEX idx_user_transaction_account_id ON user_transaction (account_id);
|
# Write your MySQL query statement below
# product_name in lowercase without leading or trailing white spaces.
# sale_date in the format ('YYYY-MM').
# total the number of times the product was sold in this month.
SELECT LOWER(TRIM(product_name)) AS product_name, DATE_FORMAT(sale_date, '%Y-%m') AS sale_date, COUNT(*) AS total
FROM Sales
GROUP BY 1, 2
ORDER BY 1, 2
|
USE sakila;
-- 1a. Display the first and last names of all the actors from the table actor.
SELECT first_name, last_name from actor;
-- 1b. Display the first and last name of each actor in a single column in upper case letters. Name the column Actor Name
SELECT CONCAT(first_name, ' ', last_name) as 'ACTOR NAME' from ACTOR;
-- 2a. You need to find the ID number, first name, and last name of an actor, of whom you know only the first name, "Joe." What is one query would you use to obtain this information?
SELECT actor_id as ID, first_name, last_name FROM actor WHERE first_name = 'Joe';
-- 2b. Find all actors whose last name contain the letters GEN:
SELECT * FROM actor WHERE last_name LIKE '%GEN%';
-- 2c. Find all actors whose last names contain the letters LI. This time, order the rows by last name and first name, in that order:
SELECT * FROM actor WHERE last_name LIKE '%LI%' order by last_name, first_name;
-- 2d. Using IN, display the country_id and country columns of the following countries: Afghanistan, Bangladesh, and China:
SELECT country_id, country FROM country where country in ('Afghanistan', 'Bangladesh', 'China');
-- 3a. You want to keep a description of each actor. You don't think you will be performing queries on a description, so create a column in the table actor named description and use the data type BLOB (Make sure to research the type BLOB, as the difference between it and VARCHAR are significant).
ALTER TABLE country ADD COLUMN description BLOB NULL AFTER country;
-- 3b. Very quickly you realize that entering descriptions for each actor is too much effort. Delete the description column.
ALTER TABLE country DROP COLUMN description;
-- 4a. List the last names of actors, as well as how many actors have that last name.
SELECT DISTINCT last_name, count(last_name) AS 'No. of actors' FROM actor GROUP BY (last_name);
-- 4b. List last names of actors and the number of actors who have that last name, but only for names that are shared by at least two actors
SELECT DISTINCT last_name, count(last_name) AS 'No. of actors' FROM actor GROUP BY (last_name) HAVING count(last_name) >=2;
-- 4c. The actor HARPO WILLIAMS was accidentally entered in the actor table as GROUCHO WILLIAMS. Write a query to fix the record.
UPDATE ACTOR SET first_name = 'HARPO' WHERE first_name = 'GROUCHO' AND last_name = 'WILLIAMS';
-- 4d. Perhaps we were too hasty in changing GROUCHO to HARPO. It turns out that GROUCHO was the correct name after all! In a single query, if the first name of the actor is currently HARPO, change it to GROUCHO.
UPDATE ACTOR SET first_name = 'GROUCHO' WHERE first_name = 'HARPO' AND last_name = 'WILLIAMS';
-- 5a. You cannot locate the schema of the address table. Which query would you use to re-create it?
SHOW CREATE TABLE address;
-- Hint: https://dev.mysql.com/doc/refman/5.7/en/show-create-table.html
-- 6a. Use JOIN to display the first and last names, as well as the address, of each staff member. Use the tables staff and address:
SELECT s.first_name, s.last_name, a.address FROM address a INNER JOIN staff s on a.address_id = s.address_id;
-- 6b. Use JOIN to display the total amount rung up by each staff member in August of 2005. Use tables staff and payment.
SELECT s.staff_id, SUM(p.amount) FROM staff s INNER JOIN payment p on s.staff_id=p.staff_id WHERE YEAR(p.payment_date) = 2005 and MONTH(p.payment_date) = 05 GROUP BY s.staff_id;
-- 6c. List each film and the number of actors who are listed for that film. Use tables film_actor and film. Use inner join.
SELECT f.title, count(a.actor_id) FROM film f INNER JOIN film_actor a on f.film_id = a.film_id GROUP BY f.film_id;
-- 6d. How many copies of the film Hunchback Impossible exist in the inventory system?
SELECT f.title, count(inv.store_id) FROM film f INNER JOIN inventory inv on f.film_id = inv.film_id WHERE UPPER(f.title) = 'HUNCHBACK IMPOSSIBLE' GROUP BY f.film_id;
-- 6e. Using the tables payment and customer and the JOIN command, list the total paid by each customer. List the customers alphabetically by last name:
SELECT CONCAT(c.first_name, ' ', last_name) as 'Customer', SUM(p.amount) as 'Total Paid' FROM customer c INNER JOIN payment p on c.customer_id = p.customer_id
GROUP BY (c.customer_id) ORDER BY c.last_name;
-- 7a. The music of Queen and Kris Kristofferson have seen an unlikely resurgence. As an unintended consequence, films starting with the letters K and Q have also soared in popularity.
-- Use subqueries to display the titles of movies starting with the letters K and Q whose language is English.
SELECT title as 'Movie' from film where language_id =
(
SELECT language_id from language where name = 'English'
)
and (title LIKE 'K%' OR title LIKE 'Q%')
;
-- 7b. Use subqueries to display all actors who appear in the film Alone Trip.
SELECT CONCAT(a.first_name, ' ', a.last_name) as 'Actors' FROM actor a WHERE a.actor_id IN
(
SELECT actor_id FROM film_actor WHERE film_id =
(
SELECT film_id FROM film where title = 'Alone Trip'
)
);
-- 7c. You want to run an email marketing campaign in Canada, for which you will need the names and email addresses of all Canadian customers. Use joins to retrieve this information.
SELECT CONCAT(c.first_name, ' ', c.last_name) as 'Customer', c.email FROM customer c INNER JOIN address ad ON c.address_id = ad.address_id
INNER JOIN city ON ad.city_id = city.city_id INNER JOIN country ctr ON city.country_id = ctr.country_id WHERE ctr.country = 'CANADA';
-- 7d. Sales have been lagging among young families, and you wish to target all family movies for a promotion. Identify all movies categorized as family films.
SELECT title FROM film WHERE film_id IN
(
SELECT film_id FROM film_category WHERE category_id IN
(
SELECT category_id FROM category WHERE name = 'Family'
)
);
-- 7e. Display the most frequently rented movies in descending order.
SELECT f.title, COUNT(r.rental_id) as 'frequencey' FROM rental r INNER JOIN inventory inv ON r.inventory_id = inv.inventory_id INNER JOIN film f ON inv.film_id = f.film_id
GROUP BY inv.inventory_id ORDER by COUNT(r.rental_id) DESC, f.title DESC;
-- 7f. Write a query to display how much business, in dollars, each store brought in.
SELECT store.store_id AS 'Store', SUM(payment.amount) AS 'Total Business ($)' FROM payment INNER JOIN store ON payment.staff_id = store.manager_staff_id GROUP BY payment.staff_id;
-- 7g. Write a query to display for each store its store ID, city, and country.
SELECT store.store_id, city.city, country.country FROM store, address, city, country where store.address_id = address.address_id
and address.city_id = city.city_id and city.country_id = country.country_id;
-- 7h. List the top five genres in gross revenue in descending order. (Hint: you may need to use the following tables: category, film_category, inventory, payment, and rental.)
/**
The query ensued is equivalent to the following. This is created as a cross reference to the amount that we receive. The query as ensued is created on Sports Category with id = 15.
=======================================================================================================================================
SELECT SUM(amount) FROM sakila.payment where rental_id in (SELECT rental_id FROM rental where inventory_id in
(SELECT inventory_id FROM sakila.inventory where film_id in (SELECT film_id FROM sakila.film_category where category_id = 15)));
=======================================================================================================================================
This query returns 5314.21 which is the same as that we receive on executing the main query.
*/
SELECT category.name as 'Genre', SUM(payment.amount)
FROM payment
INNER JOIN rental ON payment.rental_id = rental.rental_id
INNER JOIN inventory ON inventory.inventory_id = rental.inventory_id
INNER JOIN film_category fc ON fc.film_id = inventory.film_id
INNER JOIN category ON category.category_id = fc.category_id
GROUP BY category.name
ORDER BY SUM(payment.amount) DESC
LIMIT 5
;
-- 8a. In your new role as an executive, you would like to have an easy way of viewing the Top five genres by gross revenue.
-- Use the solution from the problem above to create a view. If you haven't solved 7h, you can substitute another query to create a view.
CREATE VIEW top_five_genre AS
(
SELECT category.name as 'Genre', SUM(payment.amount)
FROM payment
INNER JOIN rental ON payment.rental_id = rental.rental_id
INNER JOIN inventory ON inventory.inventory_id = rental.inventory_id
INNER JOIN film_category fc ON fc.film_id = inventory.film_id
INNER JOIN category ON category.category_id = fc.category_id
GROUP BY category.name
ORDER BY SUM(payment.amount) DESC
LIMIT 5
)
;
-- 8b. How would you display the view that you created in 8a?
SELECT * FROM sakila.top_five_genre;
-- 8c. You find that you no longer need the view top_five_genres. Write a query to delete it.
DROP VIEW sakila.top_five_genre;
|
create table devcode_transactions
(
id bigint not null auto_increment,
player_id bigint not null,
event_type character varying(50) not null,
level bigint not null,
authorization_code character varying(46),
amount bigint not null,
currency character varying(3) not null,
transaction_id character varying(60) not null,
transaction_type integer not null,
transaction_name character varying(120) not null,
account_id character varying(46),
masked_account character varying(40),
attributes character varying(140),
bonus_code character varying(100),
original_transaction character varying(60),
transaction_provider character varying(60),
status_code character varying(60),
psp_status_code character varying(60),
success tinyint,
error_code integer,
error_message character varying(120),
provider_id integer not null,
version integer not null,
created_date timestamp not null,
constraint devcode_transactions_pkey primary key (id),
constraint devcode_transactions_player_id_fkey foreign key (player_id) references players (id),
constraint devcode_transactions_provider_id_fkey foreign key (provider_id) references providers (id)
);
|
CREATE TABLE visitors (
Name varchar(255),
ContactInfo varchar(255)
);
|
DROP TABLE IF EXISTS `quotes`;
CREATE TABLE `quotes` (
`id` int NOT NULL AUTO_INCREMENT,
`quote` VARCHAR(500) NOT NULL,
`author` VARCHAR(300) NOT NULL,
`likes` INT,
PRIMARY KEY (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
INSERT INTO `quotes` (quote, author)
VALUES ('La vie cest cool', 'Benito'), ('Le front cest les meilleurs', 'Mehdi'), ('Je voulais faire une formation de coiffeur', 'David Lafleur'); |
use employees;
select emp_no,birth_date,first_name,last_name,gender,hire_date from employees order by hire_date limit 0,1;
UPDATE salaries,employees SET salaries.salary=salaries.salary+1 WHERE salaries.emp_no=employees.emp_no and employees.gender="M";
DELETE dept_emp FROM employees,dept_emp WHERE employees.emp_no=dept_emp.emp_no and employees.last_name="Acton";
DELETE dept_manager FROM employees,dept_manager WHERE employees.emp_no=dept_manager.emp_no and employees.last_name="Acton";
DELETE salaries FROM employees,salaries WHERE employees.emp_no=salaries.emp_no and employees.last_name="Acton";
DELETE titles FROM employees,titles WHERE employees.emp_no=titles.emp_no and employees.last_name="Acton";
DELETE FROM employees WHERE employees.last_name="Acton";
insert into employees values(1,"1953-09-02","haha","haha","M","1986-06-26");
insert into titles values(1,"Senior Engineer","1986-06-26","9999-01-01");
insert into dept_emp values(1,"d001","1985-01-01","9999-01-01");
insert into salaries values(1,66962,"1990-06-25","1991-06-25"); |
CREATE TABLE language (
language_id integer NOT NULL
PRIMARY KEY,
language_name varchar(30)
);
|
/*
Warnings:
- Added the required column `entityId` to the `EntityLog` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "EntityLog" ADD COLUMN "entityId" TEXT NOT NULL;
|
col status for a10
SELECT vh.inst_id, vh.sid locking_sid,vs.serial#,
vs.status status,
vs.program program_holding,
vw.sid waiter_sid,
vsw.program program_waiting
FROM gv$lock vh,
gv$lock vw,
gv$session vs,
gv$session vsw
WHERE (vh.id1, vh.id2) IN (SELECT id1, id2
FROM gv$lock
WHERE request = 0
INTERSECT
SELECT id1, id2
FROM gv$lock
WHERE lmode = 0)
AND vh.id1 = vw.id1
AND vh.id2 = vw.id2
AND vh.inst_id = vw.inst_id
AND vh.request = 0
AND vw.lmode = 0
AND vh.sid = vs.sid
and vh.inst_id = vs.inst_id
AND vw.sid = vsw.sid
and vw.inst_id = vsw.inst_id; |
ALTER TABLE behavior_group_action
ADD COLUMN position INTEGER NOT NULL DEFAULT 0; -- The default value is required to migrate existing actions.
ALTER TABLE behavior_group_action
ALTER COLUMN position DROP DEFAULT; -- Migration done, we can drop the default value.
|
CREATE TABLE inbound_message
( message_id NUMBER(19,0),
message_body VARCHAR2(200),
received_date DATE
)
/
CREATE SEQUENCE inbound_message_seq
START WITH 1
INCREMENT BY 1
NOCACHE
NOCYCLE
/
CREATE TABLE tower
( tower_id NUMBER(19,0),
VALUE NUMBER,
POSITION NUMBER,
VOLUME NUMBER
)
/
CREATE SEQUENCE tower_seq
START WITH 1
INCREMENT BY 1
NOCACHE
NOCYCLE
/ |
select a.student_no, a.student_name, a.plan_submit_dept, a.adjust_start_time, a.adjust_end_time,
a.track_sale, a.lesson_status, a.fd_submit_time, a.final_feedback, a.content, a.subject_name,
a.plan_submit_sale, a.lesson_plan_id
from(
select lp.lesson_plan_id,
s.student_no,
s.name as student_name,
ui.name as plan_submit_sale,
sd.department_name as plan_submit_dept,
lp.adjust_start_time,
lp.adjust_end_time,
ui2.name as track_sale,
case when sf.is_Fisrst=1 then '报名'
when sf.is_Fisrst=2 then '失单'
when sf.is_Fisrst=3 then '跳票'
when sf.is_Fisrst=4 then '待定'
else '试听后待反馈' end as lesson_status,
sf.submit_time as fd_submit_time,
sf.final_feedback,
sf.content,
su.subject_name,
rank() over (partition by lpo.student_intention_id order by lp.adjust_start_time desc) as rk1,
rank() over (partition by concat(lpo.student_intention_id,lp.adjust_start_time) order by sf.submit_time desc) as rk2
from dw_hf_mobdb.dw_lesson_plan_order lpo
left join dw_hf_mobdb.dw_lesson_relation lr on lpo.order_id = lr.order_id
left join dw_hf_mobdb.dw_lesson_plan lp on lr.plan_id = lp.lesson_plan_id
left join dw_hf_mobdb.dw_view_student s on s.student_intention_id = lpo.student_intention_id
left join dw_hf_mobdb.dw_submit_feedback sf on sf.order_id = lr.order_id
left join dw_hf_mobdb.dw_subject su on su.subject_id = lp.subject_id
left join dw_hf_mobdb.dw_view_user_info ui on lpo.apply_user_id = ui.user_id
left join dw_hf_mobdb.dw_view_user_info ui2 on s.track_userid = ui2.user_id
left join dw_hf_mobdb.dw_sys_user_role sur on ui.user_id=sur.user_id
left join dw_hf_mobdb.dw_sys_role sr on sur.role_id=sr.role_id
left join dw_hf_mobdb.dw_sys_department sd on sr.department_id=sd.department_id
where to_date(lp.adjust_start_time) >= trunc('${analyse_date}','MM')
and to_date(lp.adjust_start_time) <= date_sub('${analyse_date}',1)
and lp.lesson_type = 2 and lp.status in(3,5) and lp.solve_status <> 6 -- 完成试听课
and sd.department_name like 'CC%'
and ui2.name <> '已报名学员' -- 去除当前已成单的
) as a
where rk1 = 1 and rk2 = 1 |
/*
import globalfirepower.csv
Note that you can wrap column names around quotes to handle spaces:
select 'Total Aircraft Strength' from globalfirepower limit 5;
Also, you can use mysqlworkbench to alter table column names.
Right-click the table and click 'alter table'.
*/
-- altering original table:
use Miscellaneous_DB;
ALTER TABLE `Miscellaneous_DB`.`globalfirepower`
CHANGE COLUMN `Total Population` `TotalPopulation` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Manpower Available` `ManpowerAvailable` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Fit-for-Service` `FitForService` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Reaching Military Age` `ReachingMilitaryAge` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Total Military Personnel` `TotalMilitaryPersonnel` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Active Personnel` `ActivePersonnel` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Reserve Personnel` `ReservePersonnel` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Total Aircraft Strength` `TotalAircraftStrength` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Fighter Aircraft` `FighterAircraft` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Attack Aircraft` `AttackAircraft` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Transport Aircraft` `TransportAircraft` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Trainer Aircraft` `TrainerAircraft` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Total Helicopter Strength` `TotalHelicopterStrength` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Attack Helicopters` `AttackHelicopters` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Combat Tanks` `CombatTanks` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Armored Fighting Vehicles` `ArmoredFightingVehicles` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Self-Propelled Artillery` `SelfPropelledArtillery` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Towed Artillery` `TowedArtillery` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Rocket Projectors` `RocketProjectors` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Total Naval Assets` `TotalNavalAssets` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Aircraft Carriers` `AircraftCarriers` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Patrol Craft` `PatrolCraft` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Mine Warfare Vessels` `MineWarfareVessels` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Production (bbl/dy)` `Production_bbl_dy` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Consumption (bbl/dy)` `Consumption_bbl_dy` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Proven Reserves (bbl)` `ProvenReserves_bbl` BIGINT(20) NULL DEFAULT NULL ,
CHANGE COLUMN `Labor Force` `LaborForce` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Merchant Marine Strength` `MerchantMarineStrength` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Major Ports / Terminals` `MajorPorts_per_Terminals` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Roadway Coverage (km)` `RoadwayCoverage_km` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Railway Coverage (km)` `RailwayCoverage_km` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Serivecable Airports` `SerivecableAirports` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Defense Budget` `DefenseBudget` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `External Debt` `ExternalDebt` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Foreign Exchange / Gold` `ForeignExchange_per_Gold` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Purchasing Power Parity` `PurchasingPowerParity` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Square Land Area (km)` `SquareLandArea_km` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Coastline (km)` `Coastline_km` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Shared Borders (km)` `SharedBorders_km` INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN `Waterways (km)` `Waterways_km` INT(11) NULL DEFAULT NULL ;
select count(*) from globalfirepower; -- 80
select count(*) from globalfirepower
where ReservePersonnel = 0; -- 8
/*
Error Code: 1175. You are using safe update mode and
you tried to update a table without a WHERE that uses a KEY column
To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect.
Note: uncheck safe updates. Then exit and reconnect to mysql server.
*/
DELETE FROM globalfirepower
WHERE ReservePersonnel = 0; -- delete 8
select count(*) from globalfirepower; -- 72
select * from globalfirepower
where FighterAircraft = 0;
UPDATE globalfirepower
SET FighterAircraft = 1, TotalAircraftStrength = TotalAircraftStrength + 1
WHERE FighterAircraft = 0;
select * from globalfirepower
where FighterAircraft = 1;
SELECT AVG(TotalMilitaryPersonnel), -- 741101
AVG(TotalAircraftStrength), -- 639
AVG(TotalHelicopterStrength), -- 257
AVG(TotalPopulation) -- 85175106
FROM globalfirepower;
INSERT INTO globalfirepower(Country,
TotalPopulation,
TotalMilitaryPersonnel,
TotalAircraftStrength,
TotalHelicopterStrength)
select 'Wakanda',
AVG(TotalPopulation),
AVG(TotalMilitaryPersonnel),
AVG(TotalAircraftStrength),
AVG(TotalHelicopterStrength)
from globalfirepower
where Country != 'Wakanda';
select * from globalfirepower where Country = 'Wakanda'; |
update levels
set bonus_id = 16
where level = 10;
update levels
set bonus_id = 17
where level = 11;
update levels
set bonus_id = 18
where level = 12;
update levels
set bonus_id = 19
where level = 13;
update levels
set bonus_id = 20
where level = 14;
update levels
set bonus_id = 21
where level = 15;
update levels
set bonus_id = 22
where level = 16;
update levels
set bonus_id = 23
where level = 17;
update levels
set bonus_id = 24
where level = 18;
update levels
set bonus_id = 25
where level = 19;
update levels
set bonus_id = 26
where level = 20;
update levels
set bonus_id = 27
where level = 21;
update levels
set bonus_id = 28
where level = 22;
update levels
set bonus_id = 29
where level = 23;
update levels
set bonus_id = 30
where level = 24;
update levels
set bonus_id = 31
where level = 25;
update levels
set bonus_id = 32
where level = 26;
update levels
set bonus_id = 33
where level = 27;
update levels
set bonus_id = 34
where level = 28;
update levels
set bonus_id = 35
where level = 29;
update levels
set bonus_id = 36
where level = 30;
update levels
set bonus_id = 37
where level = 31;
update levels
set bonus_id = 38
where level = 32;
update levels
set bonus_id = 39
where level = 33;
update levels
set bonus_id = 40
where level = 34;
update levels
set bonus_id = 41
where level = 35;
update levels
set bonus_id = 42
where level = 36;
update levels
set bonus_id = 43
where level = 37;
update levels
set bonus_id = 44
where level = 38;
update levels
set bonus_id = 45
where level = 39;
update levels
set bonus_id = 46
where level = 40;
update levels
set bonus_id = 47
where level = 41;
update levels
set bonus_id = 48
where level = 42;
update levels
set bonus_id = 49
where level = 43;
update levels
set bonus_id = 50
where level = 44;
update levels
set bonus_id = 51
where level = 45;
update levels
set bonus_id = 52
where level = 46;
update levels
set bonus_id = 53
where level = 47;
update levels
set bonus_id = 54
where level = 48;
update levels
set bonus_id = 55
where level = 49;
update levels
set bonus_id = 56
where level = 50;
update levels
set bonus_id = 57
where level = 51;
update levels
set bonus_id = 58
where level = 52;
update levels
set bonus_id = 59
where level = 53;
update levels
set bonus_id = 60
where level = 54;
update levels
set bonus_id = 61
where level = 55;
update levels
set bonus_id = 62
where level = 56;
update levels
set bonus_id = 63
where level = 57;
update levels
set bonus_id = 64
where level = 58;
update levels
set bonus_id = 65
where level = 59;
update levels
set bonus_id = 66
where level = 60;
update levels
set bonus_id = 67
where level = 61;
update levels
set bonus_id = 68
where level = 62;
update levels
set bonus_id = 69
where level = 63;
update levels
set bonus_id = 70
where level = 64;
update levels
set bonus_id = 71
where level = 65;
update levels
set bonus_id = 72
where level = 66;
update levels
set bonus_id = 73
where level = 67;
update levels
set bonus_id = 74
where level = 68;
update levels
set bonus_id = 75
where level = 69;
update levels
set bonus_id = 76
where level = 70;
update levels
set bonus_id = 77
where level = 71;
update levels
set bonus_id = 78
where level = 72;
update levels
set bonus_id = 79
where level = 73;
update levels
set bonus_id = 80
where level = 74;
update levels
set bonus_id = 81
where level = 75;
update levels
set bonus_id = 82
where level = 76;
update levels
set bonus_id = 83
where level = 77;
update levels
set bonus_id = 84
where level = 78;
update levels
set bonus_id = 85
where level = 79;
update levels
set bonus_id = 86
where level = 80;
update levels
set bonus_id = 87
where level = 81;
update levels
set bonus_id = 88
where level = 82;
update levels
set bonus_id = 89
where level = 83;
update levels
set bonus_id = 90
where level = 84;
update levels
set bonus_id = 91
where level = 85;
update levels
set bonus_id = 92
where level = 86;
update levels
set bonus_id = 93
where level = 87;
update levels
set bonus_id = 94
where level = 88;
update levels
set bonus_id = 95
where level = 89;
update levels
set bonus_id = 96
where level = 90;
update levels
set bonus_id = 97
where level = 91;
update levels
set bonus_id = 98
where level = 92;
update levels
set bonus_id = 99
where level = 93;
update levels
set bonus_id = 100
where level = 94;
update levels
set bonus_id = 101
where level = 95;
update levels
set bonus_id = 102
where level = 96;
update levels
set bonus_id = 103
where level = 97;
update levels
set bonus_id = 104
where level = 98;
update levels
set bonus_id = 105
where level = 99;
update levels
set bonus_id = 106
where level = 100;
update levels
set bonus_id = 107
where level = 101;
update levels
set bonus_id = 108
where level = 102;
update levels
set bonus_id = 109
where level = 103;
update levels
set bonus_id = 110
where level = 104;
update levels
set bonus_id = 111
where level = 105;
update levels
set bonus_id = 112
where level = 106;
update levels
set bonus_id = 113
where level = 107;
update levels
set bonus_id = 114
where level = 108;
update levels
set bonus_id = 115
where level = 109;
update levels
set bonus_id = 116
where level = 110;
update levels
set bonus_id = 117
where level = 111;
update levels
set bonus_id = 118
where level = 112;
update levels
set bonus_id = 119
where level = 113;
update levels
set bonus_id = 120
where level = 114;
update levels
set bonus_id = 121
where level = 115;
update levels
set bonus_id = 122
where level = 116;
update levels
set bonus_id = 123
where level = 117;
update levels
set bonus_id = 124
where level = 118;
update levels
set bonus_id = 125
where level = 119;
update levels
set bonus_id = 126
where level = 120; |
CREATE TABLE "FileStatus"
(
"FileStatusId" uuid NOT NULL,
"FileId" uuid NOT NULL,
"StatusType" text NOT NULL,
"Value" text NOT NULL,
"CreatedDatetime" timestamp with time zone not null,
CONSTRAINT "FileStatus_pkey" PRIMARY KEY ("FileStatusId"),
CONSTRAINT "FileStatus_File_fkey" FOREIGN KEY ("FileId")
REFERENCES "File" ("FileId") MATCH SIMPLE
);
|
INVALID TEST
Renaming views for Apache Derby is not supported by Liquibase community:
https://docs.liquibase.com/change-types/community/rename-view.html
|
USE employee_tracker_DB;
INSERT INTO department (name)
VALUES ('Sales'), ('Engineering'),('Finance'),('Legal'),('Marketing');
INSERT INTO role (title,salary, department_id)
VALUES ('Sales Lead',90000,1),('Sales Representative',70000,1),
('Lead Engineer',100000,2),('Software Engineer',90000,2),
('Accountant',60000,3),('Lawyer',150000,4),('Legal Team Lead',180000,4),
('Lead Marketing Coordinator',70000,4),('Marketing Coordinator',50000,4);
INSERT INTO employee (first_name, last_name, role_id, manager_id)
VALUES ('Angus','Adams',1,null),('Bob','Brown',2,null),('Catherine','Chan',3,null),
('Dorothy','Davidson',4,null),('Edward','Erikson',5,null),('Frances','Fong',6,null),
('George','Gagnon',7,null),('Hermione','Hernadez',8,null),('Izzy','Iwamoto',9,null);
UPDATE employee SET manager_id = 1 WHERE id = 2;
UPDATE employee SET manager_id = 3 WHERE id = 4;
UPDATE employee SET manager_id = 7 WHERE id = 6;
UPDATE employee SET manager_id = 8 WHERE id = 9;
SELECT department.id, department.name, role.title, role.id
FROM department INNER JOIN role ON (department.id = role.department_id);
SELECT e.id, e.first_name, e.last_name, role.title, role.salary, department.name, CONCAT(m.first_name," ", m.last_name) as manager
FROM employee e
LEFT JOIN employee m
ON m.id = e.manager_id
INNER JOIN role
ON role.id = e.role_id
INNER JOIN department
ON department.id = role.department_id; |
-- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 14, 2021 at 10:38 AM
-- Server version: 10.4.17-MariaDB
-- PHP Version: 8.0.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `test`
--
-- --------------------------------------------------------
--
-- Table structure for table `members`
--
CREATE TABLE `members` (
`id` bigint(20) UNSIGNED NOT NULL,
`title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`story` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `members`
--
INSERT INTO `members` (`id`, `title`, `story`, `created_at`, `updated_at`) VALUES
(1, 'ss', 'Pink ponies and purple giraffes roamed the field. Cotton candy grew from the ground as a chocolate river meandered off to the side. What looked like stones in the pasture were actually rock candy.', '2021-04-12 02:40:39', '2021-04-12 02:40:39'),
(9, 'celebrity portfolio', 'She had been an angel for coming up on 10 years and in all that time nobody had told her this was possible. The fact that it could ever happen never even entered her mind.', '2021-04-13 04:19:40', '2021-04-13 04:19:40'),
(10, 'param', 'The red ball sat proudly at the top of the toybox. It had been the last to be played with and anticipated it would be the next as well. The other toys grumbled beneath.', '2021-04-13 04:20:02', '2021-04-13 04:20:02'),
(11, 'Hello There', 'How you doing', '2021-04-13 05:54:45', '2021-04-13 05:54:45'),
(15, 'Kajal', 'Balloons are pretty and come in different colors, different shapes, different sizes, and they can even adjust sizes as needed. But don\'t make them too big .', '2021-04-13 06:48:26', '2021-04-13 06:48:26');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `members`
--
ALTER TABLE `members`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `members`
--
ALTER TABLE `members`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
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 */;
|
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Хост: 127.0.0.1
-- Время создания: Май 14 2020 г., 22:44
-- Версия сервера: 10.4.11-MariaDB
-- Версия PHP: 7.4.4
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- База данных: `chat`
--
-- --------------------------------------------------------
--
-- Структура таблицы `friends`
--
CREATE TABLE `friends` (
`user_1` int(11) NOT NULL,
`user_2` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `friends`
--
INSERT INTO `friends` (`user_1`, `user_2`) VALUES
(1, 1);
-- --------------------------------------------------------
--
-- Структура таблицы `messages`
--
CREATE TABLE `messages` (
`id` int(100) NOT NULL,
`name` varchar(100) CHARACTER SET utf8 NOT NULL,
`user_id_komu` int(100) NOT NULL,
`user_id_ot_kogo` int(100) NOT NULL,
`text` varchar(255) CHARACTER SET utf8 NOT NULL,
`time` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Дамп данных таблицы `messages`
--
INSERT INTO `messages` (`id`, `name`, `user_id_komu`, `user_id_ot_kogo`, `text`, `time`) VALUES
(1, 'Олег', 1, 3, 'Привет Юра', '2020-05-06 15:03:09'),
(3, 'Юра', 3, 1, 'Привет Олег', '2020-05-06 15:05:28'),
(7, 'Юра', 3, 1, 'Как у тебя дела?', '2020-05-06 15:05:28'),
(8, 'Олег', 1, 3, 'Нормально', '2020-05-06 15:03:09'),
(90, 'Олег', 2, 1, 'Привет', '2020-05-14 15:05:26'),
(128, '', 1, 100, ' 5555 ', '2020-05-14 23:35:37'),
(130, '', 2, 101, ' Тест ', '2020-05-14 23:38:43');
-- --------------------------------------------------------
--
-- Структура таблицы `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`name` varchar(100) CHARACTER SET utf8 NOT NULL,
`photo` varchar(100) CHARACTER SET utf8 NOT NULL,
`phone` varchar(20) CHARACTER SET utf8 NOT NULL,
`email` varchar(100) CHARACTER SET utf8 NOT NULL,
`password` varchar(250) CHARACTER SET utf8 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Дамп данных таблицы `users`
--
INSERT INTO `users` (`id`, `name`, `photo`, `phone`, `email`, `password`) VALUES
(1, 'Олег', '/img/user2.png', '555555', 'oleg@m', 'oleg'),
(2, 'Оля', '/img/user.png', '66666', 'olya@g', 'olya'),
(3, 'Юра', '/img/user3.png', '777777', 'yura@m\r\n', ''),
(101, 'Misha', '/img/user4.png', '', 'Misha@', 'misha');
--
-- Индексы сохранённых таблиц
--
--
-- Индексы таблицы `friends`
--
ALTER TABLE `friends`
ADD UNIQUE KEY `user_1` (`user_1`,`user_2`);
--
-- Индексы таблицы `messages`
--
ALTER TABLE `messages`
ADD PRIMARY KEY (`id`);
--
-- Индексы таблицы `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT для сохранённых таблиц
--
--
-- AUTO_INCREMENT для таблицы `messages`
--
ALTER TABLE `messages`
MODIFY `id` int(100) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=131;
--
-- AUTO_INCREMENT для таблицы `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=102;
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 */;
|
\copy customer FROM '../tpch/tables/customer.tbl' WITH DELIMITER AS '|';
\copy lineitem FROM '../tpch/tables/lineitem.tbl' WITH DELIMITER AS '|';
\copy nation FROM '../tpch/tables/nation.tbl' WITH DELIMITER AS '|';
\copy orders FROM '../tpch/tables/orders.tbl' WITH DELIMITER AS '|';
\copy part FROM '../tpch/tables/part.tbl' WITH DELIMITER AS '|';
\copy partsupp FROM '../tpch/tables/partsupp.tbl' WITH DELIMITER AS '|';
\copy region FROM '../tpch/tables/region.tbl' WITH DELIMITER AS '|';
\copy supplier FROM '../tpch/tables/supplier.tbl' WITH DELIMITER AS '|';
|
-- phpMyAdmin SQL Dump
-- version 4.4.15.10
-- https://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: 2017-07-04 16:25:02
-- 服务器版本: 5.5.52-MariaDB
-- PHP Version: 5.4.16
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `BuyPlus`
--
DELIMITER $$
--
-- 函数
--
CREATE DEFINER=`root`@`localhost` FUNCTION `Fibonacci`(number int) RETURNS int(11)
begin
declare before_one int default 1;
declare before_two int default 1;
declare curr int default 1;
declare i int default 3;
if number = 1 || number = 2 then
set curr = 1;
else
getNumber: while i <= number do
set curr = before_one + before_two;
set before_two = before_one;
set before_one = curr;
set i = i + 1;
end while getNumber;
end if;
return curr;
end$$
CREATE DEFINER=`root`@`localhost` FUNCTION `jieCeng`(number int) RETURNS int(11)
begin
declare count_number int default 1;
while number >= 1 do
set count_number = count_number * number;
set number = number - 1;
end while;
return count_number;
end$$
DELIMITER ;
-- --------------------------------------------------------
--
-- 表的结构 `bin_attribute`
--
CREATE TABLE IF NOT EXISTS `bin_attribute` (
`attribute_id` int(10) unsigned NOT NULL,
`goods_type_id` int(10) unsigned NOT NULL DEFAULT '0',
`attribute_type_id` int(10) unsigned NOT NULL DEFAULT '0',
`title` varchar(32) NOT NULL DEFAULT '',
`sort_number` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_attribute`
--
INSERT INTO `bin_attribute` (`attribute_id`, `goods_type_id`, `attribute_type_id`, `title`, `sort_number`) VALUES
(1, 3, 1, '作者', 0),
(2, 3, 1, '页数', 0),
(3, 3, 2, '版本', 0),
(5, 1, 3, '内存容量', 0),
(6, 1, 3, '显卡', 0);
-- --------------------------------------------------------
--
-- 表的结构 `bin_attribute_type`
--
CREATE TABLE IF NOT EXISTS `bin_attribute_type` (
`attribute_type_id` int(10) unsigned NOT NULL,
`title` varchar(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_attribute_type`
--
INSERT INTO `bin_attribute_type` (`attribute_type_id`, `title`) VALUES
(1, 'text'),
(2, 'select'),
(3, 'select-multiple');
-- --------------------------------------------------------
--
-- 表的结构 `bin_attribute_value`
--
CREATE TABLE IF NOT EXISTS `bin_attribute_value` (
`attribute_value_id` int(10) unsigned NOT NULL,
`attribute_id` int(10) unsigned NOT NULL DEFAULT '0',
`value` varchar(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_attribute_value`
--
INSERT INTO `bin_attribute_value` (`attribute_value_id`, `attribute_id`, `value`) VALUES
(1, 3, '平装'),
(2, 3, '精装'),
(3, 5, '4G'),
(4, 5, '8G'),
(5, 5, '12G'),
(6, 5, '16G'),
(7, 6, '集成显卡'),
(8, 6, '独立显卡'),
(9, 6, '高性能显卡'),
(10, 6, '集显+独显双显卡');
-- --------------------------------------------------------
--
-- 表的结构 `bin_brand`
--
CREATE TABLE IF NOT EXISTS `bin_brand` (
`brand_id` int(10) unsigned NOT NULL,
`title` varchar(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_brand`
--
INSERT INTO `bin_brand` (`brand_id`, `title`) VALUES
(6, '假装有品牌'),
(4, '暴龙'),
(3, '棒时都'),
(5, '阿木'),
(2, '阿玛尼'),
(1, '麦克斯');
-- --------------------------------------------------------
--
-- 表的结构 `bin_cart`
--
CREATE TABLE IF NOT EXISTS `bin_cart` (
`cart_id` int(10) unsigned NOT NULL,
`user_id` int(10) unsigned NOT NULL DEFAULT '0',
`carete_at` int(11) NOT NULL DEFAULT '0',
`update_at` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_cart`
--
INSERT INTO `bin_cart` (`cart_id`, `user_id`, `carete_at`, `update_at`) VALUES
(1, 3, 0, 1493874795);
-- --------------------------------------------------------
--
-- 表的结构 `bin_cart_goods`
--
CREATE TABLE IF NOT EXISTS `bin_cart_goods` (
`cart_goods_id` int(10) unsigned NOT NULL,
`cart_id` int(10) unsigned NOT NULL DEFAULT '0',
`goods_id` int(10) unsigned NOT NULL DEFAULT '0',
`goods_attribute_value_id` varchar(32) NOT NULL DEFAULT '',
`quantity` int(10) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_cart_goods`
--
INSERT INTO `bin_cart_goods` (`cart_goods_id`, `cart_id`, `goods_id`, `goods_attribute_value_id`, `quantity`) VALUES
(4, 1, 22, '', 1),
(5, 1, 23, '26,29', 2);
-- --------------------------------------------------------
--
-- 表的结构 `bin_category`
--
CREATE TABLE IF NOT EXISTS `bin_category` (
`category_id` int(10) unsigned NOT NULL,
`category_title` varchar(32) NOT NULL DEFAULT '',
`parent_id` int(10) unsigned NOT NULL DEFAULT '0',
`sort_number` int(10) unsigned NOT NULL DEFAULT '0',
`is_used` tinyint(4) NOT NULL DEFAULT '1',
`is_nav` tinyint(4) NOT NULL DEFAULT '0',
`goods_type_id` int(10) unsigned NOT NULL DEFAULT '0',
`meta_title` varchar(255) NOT NULL DEFAULT '',
`meta_keywords` varchar(255) NOT NULL DEFAULT '',
`meta_description` varchar(1024) NOT NULL DEFAULT '',
`image` varchar(255) NOT NULL DEFAULT '',
`image_thumb` varchar(255) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_category`
--
INSERT INTO `bin_category` (`category_id`, `category_title`, `parent_id`, `sort_number`, `is_used`, `is_nav`, `goods_type_id`, `meta_title`, `meta_keywords`, `meta_description`, `image`, `image_thumb`) VALUES
(1, '未分类', 0, 0, 1, 0, 0, '', '', '', '', ''),
(2, '手机数码', 0, 0, 1, 1, 0, '', '', '', '', ''),
(3, '手机', 2, 0, 1, 0, 0, '', '', '', '', ''),
(4, '单反相机', 2, 0, 1, 0, 0, '', '', '', '', ''),
(5, '眼镜', 0, 0, 1, 1, 0, '', '', '', '', ''),
(6, '太阳眼镜', 5, 0, 1, 0, 0, '', '', '', '', ''),
(7, '游泳镜', 5, 0, 1, 0, 0, '', '', '', '', ''),
(8, '索尼相机', 4, 0, 1, 0, 0, '', '', '', '', ''),
(10, '电脑', 0, 0, 1, 1, 0, '电脑', '电脑电脑', '电脑电脑电脑电脑', '', ''),
(11, '图书', 0, 0, 1, 1, 0, '', '', '', '', ''),
(12, '历史', 11, 1, 1, 0, 0, '', '', '', '', ''),
(14, '科技', 11, 1, 1, 0, 0, '', '', '', '', ''),
(15, '计算机', 11, 1, 1, 0, 0, '', '', '', '', ''),
(16, '电子书', 11, 1, 1, 0, 0, '', '', '', '', ''),
(17, '科普', 14, 1, 1, 0, 0, '', '', '', '', ''),
(18, '建筑', 14, 1, 1, 0, 0, '', '', '', '', ''),
(19, '工业技术', 14, 1, 1, 0, 0, '', '', '', '', ''),
(20, '电子通信', 14, 1, 1, 0, 0, '', '', '', '', ''),
(21, '自然科学', 14, 1, 1, 0, 0, '', '', '', '', ''),
(22, '互联网', 15, 1, 1, 0, 0, '', '', '', '', ''),
(23, '计算机编程', 15, 1, 1, 0, 0, '', '', '', '', ''),
(24, '硬件,攒机', 15, 1, 1, 0, 0, '', '', '', '', ''),
(25, '大数据', 15, 1, 1, 0, 0, '', '', '', '', ''),
(26, '移动开发', 15, 1, 1, 0, 0, '', '', '', '', ''),
(27, 'PHP', 15, 1, 1, 0, 0, '', '', '', '', ''),
(28, '近代史', 12, 1, 1, 0, 0, '', '', '', '', ''),
(29, '当代史', 12, 1, 1, 0, 0, '', '', '', '', ''),
(30, '古代史', 12, 1, 1, 0, 0, '', '', '', '', ''),
(31, '先秦百家', 12, 1, 1, 0, 0, '', '', '', '', ''),
(32, '三皇五帝', 12, 1, 1, 0, 0, '', '', '', '', ''),
(33, '励志', 16, 1, 1, 0, 0, '', '', '', '', ''),
(34, '小说', 16, 1, 1, 0, 0, '', '', '', '', ''),
(35, '成功学', 16, 1, 1, 0, 0, '', '', '', '', ''),
(36, '经济金融', 16, 1, 1, 0, 0, '', '', '', '', ''),
(37, '免费', 16, 1, 1, 0, 0, '', '', '', '', ''),
(38, '笔记本', 10, 0, 1, 1, 0, '笔记本', '笔记本笔记本', '笔记本笔记本', '2017-04-17/58f4546a17004.jpg', ''),
(39, '台式电脑', 10, 0, 1, 0, 0, '台式电脑', '台式电脑台式电脑', '台式电脑台式电脑台式电脑台式电脑台式电脑', '2017-04-17/58f459c119da2.jpg', '');
-- --------------------------------------------------------
--
-- 表的结构 `bin_goods`
--
CREATE TABLE IF NOT EXISTS `bin_goods` (
`goods_id` int(10) unsigned NOT NULL,
`name` varchar(64) NOT NULL DEFAULT '',
`image` varchar(255) NOT NULL DEFAULT '',
`image_thumb` varchar(255) NOT NULL DEFAULT '',
`SKU` varchar(16) NOT NULL DEFAULT '',
`UPC` varchar(255) NOT NULL DEFAULT '',
`price` decimal(10,2) NOT NULL DEFAULT '0.00',
`goods_type_id` int(10) unsigned NOT NULL DEFAULT '0',
`tax_id` int(10) unsigned NOT NULL DEFAULT '0',
`quantity` int(10) unsigned NOT NULL DEFAULT '0',
`minimum` int(10) unsigned NOT NULL DEFAULT '0',
`subtract` tinyint(3) unsigned NOT NULL DEFAULT '1',
`stock_status_id` int(10) unsigned NOT NULL DEFAULT '0',
`shipping` tinyint(3) unsigned NOT NULL DEFAULT '1',
`date_available` date NOT NULL DEFAULT '0000-00-00',
`length` int(10) unsigned NOT NULL DEFAULT '0',
`width` int(10) unsigned NOT NULL DEFAULT '0',
`height` int(10) unsigned NOT NULL DEFAULT '0',
`length_unit_id` int(10) unsigned NOT NULL DEFAULT '1',
`weight` int(10) unsigned NOT NULL DEFAULT '0',
`weight_unit_id` int(10) unsigned NOT NULL DEFAULT '1',
`status` tinyint(3) unsigned NOT NULL DEFAULT '1',
`sort_number` int(11) NOT NULL DEFAULT '0',
`description` text,
`meta_title` varchar(255) NOT NULL DEFAULT '',
`meta_keywords` varchar(255) NOT NULL DEFAULT '',
`meta_description` varchar(1024) NOT NULL DEFAULT '',
`brand_id` int(11) NOT NULL DEFAULT '0',
`category_id` int(11) NOT NULL DEFAULT '0',
`create_at` int(11) NOT NULL DEFAULT '0',
`update_at` int(11) NOT NULL DEFAULT '0',
`is_deleted` tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_goods`
--
INSERT INTO `bin_goods` (`goods_id`, `name`, `image`, `image_thumb`, `SKU`, `UPC`, `price`, `goods_type_id`, `tax_id`, `quantity`, `minimum`, `subtract`, `stock_status_id`, `shipping`, `date_available`, `length`, `width`, `height`, `length_unit_id`, `weight`, `weight_unit_id`, `status`, `sort_number`, `description`, `meta_title`, `meta_keywords`, `meta_description`, `brand_id`, `category_id`, `create_at`, `update_at`, `is_deleted`) VALUES
(21, '戴尔外星人2017笔记本', '2017-04-17/58f4757683e85.jpg', '2017-04-17/300X340-58f4757683e85.jpg', '台', '865643234', 20000.00, 1, 2, 3, 1, 1, 1, 1, '2016-07-10', 0, 0, 0, 1, 0, 1, 1, 0, '<p>戴尔外星人2017笔记本戴尔外星人2017笔记本戴尔外星人2017笔记本<br></p>', '戴尔外星人2017笔记本', '戴尔外星人2017笔记本戴尔外星人2017笔记本戴尔外星人2017笔记本戴尔外星人2017笔记本', '戴尔外星人2017笔记本戴尔外星人2017笔记本', 0, 38, 1492415922, 1492415922, 0),
(22, '普利邦欧美大框墨镜男潮2016太阳', '2017-04-17/58f4c29f65db0.jpg', '2017-04-17/300X340-58f4c29f65db0.jpg', '副', '75423412', 97767.00, 2, 2, 100, 1, 1, 1, 1, '2016-07-10', 0, 0, 0, 1, 20, 1, 1, 0, '<p>普利邦欧美大框墨镜男潮2016太阳普利邦欧美大框墨镜男潮2016太阳<br></p>', '普利邦欧美大框墨镜男潮2016太阳普利邦欧美大框墨镜男潮2016太阳', '普利邦欧美大框墨镜男潮2016太阳普利邦欧美大框墨镜男潮2016太阳普利邦欧美大框墨镜男潮2016太阳普利邦欧美大框墨镜男潮2016太阳普利邦欧美大框墨镜男潮2016太阳普利邦欧美大框墨镜男潮2016太阳', '普利邦欧美大框墨镜男潮2016太阳普利邦欧美大框墨镜男潮2016太阳普利邦欧美大框墨镜男潮2016太阳普利邦欧美大框墨镜男潮2016太阳', 3, 6, 1492435660, 1492435660, 0),
(23, 'Mac Pro', '2017-04-17/58f4c389604ae.jpg', '2017-04-17/300X340-58f4c389604ae.jpg', '台', '43243232', 30000.00, 1, 2, 5, 1, 1, 1, 1, '2016-07-10', 0, 0, 0, 1, 0, 1, 0, 0, '<p>Mac Pro<br></p>', 'Mac Pro', 'Mac ProMac ProMac ProMac Pro', 'Mac ProMac Pro', 0, 38, 1492435901, 1492435901, 0),
(24, '戴尔普通笔记本', '2017-04-19/58f763044ad2f.jpg', '2017-04-19/300X340-58f763044ad2f.jpg', '台', '9754523', 9998.00, 1, 2, 200, 1, 1, 1, 1, '2016-07-10', 0, 0, 0, 1, 3000, 1, 1, 0, '<p>戴尔普通笔记本戴尔普通笔记本戴尔普通笔记本戴尔普通笔记本</p>', '戴尔普通笔记本戴尔普通笔记本', '戴尔普通笔记本戴尔普通笔记本戴尔普通笔记本戴尔普通笔记本', '戴尔普通笔记本戴尔普通笔记本戴尔普通笔记本', 0, 38, 1492607878, 1492607878, 0),
(26, 'javascript从入门到放弃', '2017-04-21/58f9eb1a8037d.jpg', '2017-04-21/300X340-58f9eb1a8037d.jpg', '本', '1578123', 223.00, 3, 2, 200, 1, 1, 1, 1, '2016-07-10', 0, 0, 0, 1, 1000, 1, 1, 0, '<p>javascript从入门到放弃javascript从入门到放弃<br></p>', 'javascript从入门到放弃javascript从入门到放弃', 'javascript从入门到放弃javascript从入门到放弃javascript从入门到放弃', 'javascript从入门到放弃javascript从入门到放弃', 0, 27, 1492773724, 1492773724, 0);
-- --------------------------------------------------------
--
-- 表的结构 `bin_goods_attribute`
--
CREATE TABLE IF NOT EXISTS `bin_goods_attribute` (
`goods_attribute_id` int(10) unsigned NOT NULL,
`goods_id` int(11) NOT NULL DEFAULT '0',
`attribute_id` int(11) NOT NULL DEFAULT '0',
`option` tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_goods_attribute`
--
INSERT INTO `bin_goods_attribute` (`goods_attribute_id`, `goods_id`, `attribute_id`, `option`) VALUES
(13, 21, 5, 0),
(14, 21, 6, 1),
(15, 23, 5, 1),
(16, 23, 6, 1),
(17, 24, 5, 1),
(18, 24, 6, 1),
(22, 26, 1, 0),
(23, 26, 2, 0),
(24, 26, 3, 0);
-- --------------------------------------------------------
--
-- 表的结构 `bin_goods_attribute_value`
--
CREATE TABLE IF NOT EXISTS `bin_goods_attribute_value` (
`goods_attribute_value_id` int(10) unsigned NOT NULL,
`goods_attribute_id` int(10) unsigned NOT NULL DEFAULT '0',
`attribute_value_id` int(10) unsigned NOT NULL DEFAULT '0',
`value` varchar(255) NOT NULL DEFAULT '',
`quantity` int(11) NOT NULL DEFAULT '0',
`price_operate` tinyint(4) NOT NULL DEFAULT '1',
`price_drift` decimal(10,2) NOT NULL DEFAULT '0.00',
`status` tinyint(4) NOT NULL DEFAULT '1'
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_goods_attribute_value`
--
INSERT INTO `bin_goods_attribute_value` (`goods_attribute_value_id`, `goods_attribute_id`, `attribute_value_id`, `value`, `quantity`, `price_operate`, `price_drift`, `status`) VALUES
(1, 2, 0, '小习', 0, 1, 0.00, 1),
(2, 3, 0, '399', 0, 1, 0.00, 1),
(3, 4, 2, '', 0, 1, 0.00, 1),
(4, 5, 6, '', 0, 1, 0.00, 1),
(5, 6, 7, '', 0, 1, 0.00, 1),
(6, 6, 9, '', 0, 1, 0.00, 1),
(7, 6, 10, '', 0, 1, 0.00, 1),
(8, 7, 6, '', 0, 1, 0.00, 1),
(9, 8, 7, '', 0, 1, 0.00, 1),
(10, 8, 9, '', 0, 1, 0.00, 1),
(11, 8, 10, '', 0, 1, 0.00, 1),
(12, 9, 3, '', 300, 0, 0.00, 1),
(13, 10, 7, '', 0, 1, 0.00, 1),
(14, 10, 9, '', 0, 1, 0.00, 1),
(15, 10, 10, '', 0, 1, 0.00, 1),
(16, 11, 3, '', 0, 1, 0.00, 1),
(17, 12, 8, '', 0, 1, 0.00, 1),
(18, 12, 9, '', 0, 1, 0.00, 1),
(19, 13, 3, '', 0, 1, 0.00, 1),
(20, 14, 7, '', 0, 1, 0.00, 1),
(21, 14, 9, '', 0, 1, 0.00, 1),
(22, 14, 10, '', 0, 1, 0.00, 1),
(23, 15, 3, '', 100, 2, 100.00, 1),
(24, 15, 4, '', 50, 1, 200.00, 1),
(25, 15, 5, '', 30, 1, 300.00, 1),
(26, 15, 6, '', 25, 1, 500.00, 1),
(27, 16, 7, '', 200, 2, 200.00, 1),
(28, 16, 8, '', 300, 1, 100.00, 1),
(29, 16, 10, '', 100, 1, 300.00, 1),
(30, 17, 3, '', 0, 1, 0.00, 1),
(31, 17, 4, '', 0, 1, 0.00, 1),
(32, 18, 7, '', 0, 1, 0.00, 1),
(33, 18, 10, '', 0, 1, 0.00, 1),
(37, 22, 0, '我去', 0, 1, 0.00, 1),
(38, 23, 0, '998', 0, 1, 0.00, 1),
(39, 24, 2, '', 0, 1, 0.00, 1);
-- --------------------------------------------------------
--
-- 表的结构 `bin_goods_image`
--
CREATE TABLE IF NOT EXISTS `bin_goods_image` (
`goods_image_id` int(10) unsigned NOT NULL,
`goods_id` int(11) NOT NULL DEFAULT '0',
`image` varchar(255) NOT NULL DEFAULT '',
`image_small` varchar(255) NOT NULL DEFAULT '',
`image_medium` varchar(255) NOT NULL DEFAULT '',
`image_big` varchar(255) NOT NULL DEFAULT '',
`sort_number` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_goods_image`
--
INSERT INTO `bin_goods_image` (`goods_image_id`, `goods_id`, `image`, `image_small`, `image_medium`, `image_big`, `sort_number`) VALUES
(13, 21, '2017-04-17/58f475acf1732.jpg', '2017-04-17/60X60-58f475acf1732.jpg', '2017-04-17/300X300-58f475acf1732.jpg', '2017-04-17/800X800-58f475acf1732.jpg', 0),
(14, 21, '2017-04-17/58f475af62a9d.jpg', '2017-04-17/60X60-58f475af62a9d.jpg', '2017-04-17/300X300-58f475af62a9d.jpg', '2017-04-17/800X800-58f475af62a9d.jpg', 0),
(15, 22, '2017-04-17/58f4c2c7c1a4e.jpg', '2017-04-17/60X60-58f4c2c7c1a4e.jpg', '2017-04-17/300X300-58f4c2c7c1a4e.jpg', '2017-04-17/800X800-58f4c2c7c1a4e.jpg', 0),
(16, 22, '2017-04-17/58f4c2ca33793.jpg', '2017-04-17/60X60-58f4c2ca33793.jpg', '2017-04-17/300X300-58f4c2ca33793.jpg', '2017-04-17/800X800-58f4c2ca33793.jpg', 0),
(17, 23, '2017-04-17/58f4c3b7e16ef.jpg', '2017-04-17/60X60-58f4c3b7e16ef.jpg', '2017-04-17/300X300-58f4c3b7e16ef.jpg', '2017-04-17/800X800-58f4c3b7e16ef.jpg', 0),
(18, 23, '2017-04-17/58f4c3bb9fdfb.jpg', '2017-04-17/60X60-58f4c3bb9fdfb.jpg', '2017-04-17/300X300-58f4c3bb9fdfb.jpg', '2017-04-17/800X800-58f4c3bb9fdfb.jpg', 0),
(19, 24, '2017-04-19/58f7635802455.jpg', '2017-04-19/60X60-58f7635802455.jpg', '2017-04-19/300X300-58f7635802455.jpg', '2017-04-19/800X800-58f7635802455.jpg', 0),
(20, 24, '2017-04-19/58f76359e65c0.jpg', '2017-04-19/60X60-58f76359e65c0.jpg', '2017-04-19/300X300-58f76359e65c0.jpg', '2017-04-19/800X800-58f76359e65c0.jpg', 0),
(21, 24, '2017-04-19/58f7635b8eb10.jpg', '2017-04-19/60X60-58f7635b8eb10.jpg', '2017-04-19/300X300-58f7635b8eb10.jpg', '2017-04-19/800X800-58f7635b8eb10.jpg', 0),
(22, 25, '2017-04-21/58f9e7a05c308.jpg', '2017-04-21/60X60-58f9e7a05c308.jpg', '2017-04-21/300X300-58f9e7a05c308.jpg', '2017-04-21/800X800-58f9e7a05c308.jpg', 0),
(23, 25, '2017-04-21/58f9e7a293b26.jpg', '2017-04-21/60X60-58f9e7a293b26.jpg', '2017-04-21/300X300-58f9e7a293b26.jpg', '2017-04-21/800X800-58f9e7a293b26.jpg', 0),
(24, 25, '2017-04-21/58f9e7a52bfbf.jpg', '2017-04-21/60X60-58f9e7a52bfbf.jpg', '2017-04-21/300X300-58f9e7a52bfbf.jpg', '2017-04-21/800X800-58f9e7a52bfbf.jpg', 0),
(25, 26, '2017-04-21/58f9eb58cd1f2.jpg', '2017-04-21/60X60-58f9eb58cd1f2.jpg', '2017-04-21/300X300-58f9eb58cd1f2.jpg', '2017-04-21/800X800-58f9eb58cd1f2.jpg', 0),
(26, 26, '2017-04-21/58f9eb5ad8da2.jpg', '2017-04-21/60X60-58f9eb5ad8da2.jpg', '2017-04-21/300X300-58f9eb5ad8da2.jpg', '2017-04-21/800X800-58f9eb5ad8da2.jpg', 0);
-- --------------------------------------------------------
--
-- 表的结构 `bin_goods_special`
--
CREATE TABLE IF NOT EXISTS `bin_goods_special` (
`goods_special_id` int(10) unsigned NOT NULL,
`goods_id` int(10) unsigned NOT NULL DEFAULT '0',
`price` decimal(10,2) NOT NULL DEFAULT '0.00',
`date_start` int(10) unsigned NOT NULL DEFAULT '0',
`date_end` int(10) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_goods_special`
--
INSERT INTO `bin_goods_special` (`goods_special_id`, `goods_id`, `price`, `date_start`, `date_end`) VALUES
(2, 26, 123.00, 1492531200, 1494777600);
-- --------------------------------------------------------
--
-- 表的结构 `bin_goods_type`
--
CREATE TABLE IF NOT EXISTS `bin_goods_type` (
`goods_type_id` int(10) unsigned NOT NULL,
`title` varchar(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_goods_type`
--
INSERT INTO `bin_goods_type` (`goods_type_id`, `title`) VALUES
(1, '笔记本'),
(2, '眼镜'),
(3, '图书');
-- --------------------------------------------------------
--
-- 表的结构 `bin_length_unit`
--
CREATE TABLE IF NOT EXISTS `bin_length_unit` (
`length_unit_id` int(11) NOT NULL,
`title` varchar(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_length_unit`
--
INSERT INTO `bin_length_unit` (`length_unit_id`, `title`) VALUES
(1, '厘米'),
(2, '毫米'),
(3, '英寸'),
(4, '米');
-- --------------------------------------------------------
--
-- 表的结构 `bin_order`
--
CREATE TABLE IF NOT EXISTS `bin_order` (
`order_id` int(10) unsigned NOT NULL,
`user_id` int(10) unsigned NOT NULL DEFAULT '0',
`create_at` int(10) unsigned NOT NULL DEFAULT '0',
`shipping_id` int(10) unsigned NOT NULL DEFAULT '0',
`address_id` int(10) unsigned NOT NULL DEFAULT '0',
`payment_id` int(10) unsigned NOT NULL DEFAULT '0',
`shipping_status` int(10) unsigned NOT NULL DEFAULT '0',
`payment_status` tinyint(4) NOT NULL DEFAULT '0',
`status` int(11) NOT NULL DEFAULT '0',
`total_price` decimal(10,2) NOT NULL DEFAULT '0.00',
`extra` text
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_order`
--
INSERT INTO `bin_order` (`order_id`, `user_id`, `create_at`, `shipping_id`, `address_id`, `payment_id`, `shipping_status`, `payment_status`, `status`, `total_price`, `extra`) VALUES
(1, 3, 1494741059, 0, 0, 0, 1, 1, 1, 100.00, '');
-- --------------------------------------------------------
--
-- 表的结构 `bin_order_goods`
--
CREATE TABLE IF NOT EXISTS `bin_order_goods` (
`order_goods_id` int(10) unsigned NOT NULL,
`order_id` int(10) unsigned NOT NULL DEFAULT '0',
`goods_id` int(10) unsigned NOT NULL DEFAULT '0',
`goods_attribute_value_id` int(10) unsigned NOT NULL DEFAULT '0',
`qunantity` int(10) unsigned NOT NULL DEFAULT '0',
`price` decimal(10,2) NOT NULL DEFAULT '0.00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `bin_region`
--
CREATE TABLE IF NOT EXISTS `bin_region` (
`region_id` int(10) unsigned NOT NULL,
`region_name` varchar(128) NOT NULL DEFAULT '',
`parent_id` int(10) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=5001 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_region`
--
INSERT INTO `bin_region` (`region_id`, `region_name`, `parent_id`) VALUES
(1, '中国', 0),
(2, '北京市', 1),
(3, '天津市', 1),
(4, '河北省', 1),
(5, '山西省', 1),
(6, '内蒙古自治区', 1),
(7, '辽宁省', 1),
(8, '吉林省', 1),
(9, '黑龙江省', 1),
(10, '上海市', 1),
(11, '江苏省', 1),
(12, '浙江省', 1),
(13, '安徽省', 1),
(14, '福建省', 1),
(15, '江西省', 1),
(16, '山东省', 1),
(17, '河南省', 1),
(18, '湖北省', 1),
(19, '湖南省', 1),
(20, '广东省', 1),
(21, '广西壮族自治区', 1),
(22, '海南省', 1),
(23, '重庆市', 1),
(24, '四川省', 1),
(25, '贵州省', 1),
(26, '云南省', 1),
(27, '西藏自治区', 1),
(28, '陕西省', 1),
(29, '甘肃省', 1),
(30, '青海省', 1),
(31, '宁夏回族自治区', 1),
(32, '新疆维吾尔自治区', 1),
(33, '市辖区', 2),
(34, '县', 2),
(35, '市辖区', 3),
(36, '县', 3),
(37, '石家庄市', 4),
(38, '唐山市', 4),
(39, '秦皇岛市', 4),
(40, '邯郸市', 4),
(41, '邢台市', 4),
(42, '保定市', 4),
(43, '张家口市', 4),
(44, '承德市', 4),
(45, '沧州市', 4),
(46, '廊坊市', 4),
(47, '衡水市', 4),
(48, '太原市', 5),
(49, '大同市', 5),
(50, '阳泉市', 5),
(51, '长治市', 5),
(52, '晋城市', 5),
(53, '朔州市', 5),
(54, '晋中市', 5),
(55, '运城市', 5),
(56, '忻州市', 5),
(57, '临汾市', 5),
(58, '吕梁市', 5),
(59, '呼和浩特市', 6),
(60, '包头市', 6),
(61, '乌海市', 6),
(62, '赤峰市', 6),
(63, '通辽市', 6),
(64, '鄂尔多斯市', 6),
(65, '呼伦贝尔市', 6),
(66, '巴彦淖尔市', 6),
(67, '乌兰察布市', 6),
(68, '兴安盟', 6),
(69, '锡林郭勒盟', 6),
(70, '阿拉善盟', 6),
(71, '沈阳市', 7),
(72, '大连市', 7),
(73, '鞍山市', 7),
(74, '抚顺市', 7),
(75, '本溪市', 7),
(76, '丹东市', 7),
(77, '锦州市', 7),
(78, '营口市', 7),
(79, '阜新市', 7),
(80, '辽阳市', 7),
(81, '盘锦市', 7),
(82, '铁岭市', 7),
(83, '朝阳市', 7),
(84, '葫芦岛市', 7),
(85, '长春市', 8),
(86, '吉林市', 8),
(87, '四平市', 8),
(88, '辽源市', 8),
(89, '通化市', 8),
(90, '白山市', 8),
(91, '松原市', 8),
(92, '白城市', 8),
(93, '延边朝鲜族自治州', 8),
(94, '哈尔滨市', 9),
(95, '齐齐哈尔市', 9),
(96, '鸡西市', 9),
(97, '鹤岗市', 9),
(98, '双鸭山市', 9),
(99, '大庆市', 9),
(100, '伊春市', 9),
(101, '佳木斯市', 9),
(102, '七台河市', 9),
(103, '牡丹江市', 9),
(104, '黑河市', 9),
(105, '绥化市', 9),
(106, '大兴安岭地区', 9),
(107, '市辖区', 10),
(108, '县', 10),
(109, '南京市', 11),
(110, '无锡市', 11),
(111, '徐州市', 11),
(112, '常州市', 11),
(113, '苏州市', 11),
(114, '南通市', 11),
(115, '连云港市', 11),
(116, '淮安市', 11),
(117, '盐城市', 11),
(118, '扬州市', 11),
(119, '镇江市', 11),
(120, '泰州市', 11),
(121, '宿迁市', 11),
(122, '杭州市', 12),
(123, '宁波市', 12),
(124, '温州市', 12),
(125, '嘉兴市', 12),
(126, '湖州市', 12),
(127, '绍兴市', 12),
(128, '金华市', 12),
(129, '衢州市', 12),
(130, '舟山市', 12),
(131, '台州市', 12),
(132, '丽水市', 12),
(133, '合肥市', 13),
(134, '芜湖市', 13),
(135, '蚌埠市', 13),
(136, '淮南市', 13),
(137, '马鞍山市', 13),
(138, '淮北市', 13),
(139, '铜陵市', 13),
(140, '安庆市', 13),
(141, '黄山市', 13),
(142, '滁州市', 13),
(143, '阜阳市', 13),
(144, '宿州市', 13),
(145, '巢湖市', 13),
(146, '六安市', 13),
(147, '亳州市', 13),
(148, '池州市', 13),
(149, '宣城市', 13),
(150, '福州市', 14),
(151, '厦门市', 14),
(152, '莆田市', 14),
(153, '三明市', 14),
(154, '泉州市', 14),
(155, '漳州市', 14),
(156, '南平市', 14),
(157, '龙岩市', 14),
(158, '宁德市', 14),
(159, '南昌市', 15),
(160, '景德镇市', 15),
(161, '萍乡市', 15),
(162, '九江市', 15),
(163, '新余市', 15),
(164, '鹰潭市', 15),
(165, '赣州市', 15),
(166, '吉安市', 15),
(167, '宜春市', 15),
(168, '抚州市', 15),
(169, '上饶市', 15),
(170, '济南市', 16),
(171, '青岛市', 16),
(172, '淄博市', 16),
(173, '枣庄市', 16),
(174, '东营市', 16),
(175, '烟台市', 16),
(176, '潍坊市', 16),
(177, '济宁市', 16),
(178, '泰安市', 16),
(179, '威海市', 16),
(180, '日照市', 16),
(181, '莱芜市', 16),
(182, '临沂市', 16),
(183, '德州市', 16),
(184, '聊城市', 16),
(185, '滨州市', 16),
(186, '菏泽市', 16),
(187, '郑州市', 17),
(188, '开封市', 17),
(189, '洛阳市', 17),
(190, '平顶山市', 17),
(191, '安阳市', 17),
(192, '鹤壁市', 17),
(193, '新乡市', 17),
(194, '焦作市', 17),
(195, '濮阳市', 17),
(196, '许昌市', 17),
(197, '漯河市', 17),
(198, '三门峡市', 17),
(199, '南阳市', 17),
(200, '商丘市', 17),
(201, '信阳市', 17),
(202, '周口市', 17),
(203, '驻马店市', 17),
(204, '武汉市', 18),
(205, '黄石市', 18),
(206, '十堰市', 18),
(207, '宜昌市', 18),
(208, '襄樊市', 18),
(209, '鄂州市', 18),
(210, '荆门市', 18),
(211, '孝感市', 18),
(212, '荆州市', 18),
(213, '黄冈市', 18),
(214, '咸宁市', 18),
(215, '随州市', 18),
(216, '恩施土家族苗族自治州', 18),
(217, '省直辖县级行政区划', 18),
(218, '长沙市', 19),
(219, '株洲市', 19),
(220, '湘潭市', 19),
(221, '衡阳市', 19),
(222, '邵阳市', 19),
(223, '岳阳市', 19),
(224, '常德市', 19),
(225, '张家界市', 19),
(226, '益阳市', 19),
(227, '郴州市', 19),
(228, '永州市', 19),
(229, '怀化市', 19),
(230, '娄底市', 19),
(231, '湘西土家族苗族自治州', 19),
(232, '广州市', 20),
(233, '韶关市', 20),
(234, '深圳市', 20),
(235, '珠海市', 20),
(236, '汕头市', 20),
(237, '佛山市', 20),
(238, '江门市', 20),
(239, '湛江市', 20),
(240, '茂名市', 20),
(241, '肇庆市', 20),
(242, '惠州市', 20),
(243, '梅州市', 20),
(244, '汕尾市', 20),
(245, '河源市', 20),
(246, '阳江市', 20),
(247, '清远市', 20),
(248, '东莞市', 20),
(249, '中山市', 20),
(250, '潮州市', 20),
(251, '揭阳市', 20),
(252, '云浮市', 20),
(253, '南宁市', 21),
(254, '柳州市', 21),
(255, '桂林市', 21),
(256, '梧州市', 21),
(257, '北海市', 21),
(258, '防城港市', 21),
(259, '钦州市', 21),
(260, '贵港市', 21),
(261, '玉林市', 21),
(262, '百色市', 21),
(263, '贺州市', 21),
(264, '河池市', 21),
(265, '来宾市', 21),
(266, '崇左市', 21),
(267, '海口市', 22),
(268, '三亚市', 22),
(269, '省直辖县级行政区划', 22),
(270, '市辖区', 23),
(271, '县', 23),
(273, '成都市', 24),
(274, '自贡市', 24),
(275, '攀枝花市', 24),
(276, '泸州市', 24),
(277, '德阳市', 24),
(278, '绵阳市', 24),
(279, '广元市', 24),
(280, '遂宁市', 24),
(281, '内江市', 24),
(282, '乐山市', 24),
(283, '南充市', 24),
(284, '眉山市', 24),
(285, '宜宾市', 24),
(286, '广安市', 24),
(287, '达州市', 24),
(288, '雅安市', 24),
(289, '巴中市', 24),
(290, '资阳市', 24),
(291, '阿坝藏族羌族自治州', 24),
(292, '甘孜藏族自治州', 24),
(293, '凉山彝族自治州', 24),
(294, '贵阳市', 25),
(295, '六盘水市', 25),
(296, '遵义市', 25),
(297, '安顺市', 25),
(298, '铜仁地区', 25),
(299, '黔西南布依族苗族自治州', 25),
(300, '毕节地区', 25),
(301, '黔东南苗族侗族自治州', 25),
(302, '黔南布依族苗族自治州', 25),
(303, '昆明市', 26),
(304, '曲靖市', 26),
(305, '玉溪市', 26),
(306, '保山市', 26),
(307, '昭通市', 26),
(308, '丽江市', 26),
(309, '普洱市', 26),
(310, '临沧市', 26),
(311, '楚雄彝族自治州', 26),
(312, '红河哈尼族彝族自治州', 26),
(313, '文山壮族苗族自治州', 26),
(314, '西双版纳傣族自治州', 26),
(315, '大理白族自治州', 26),
(316, '德宏傣族景颇族自治州', 26),
(317, '怒江傈僳族自治州', 26),
(318, '迪庆藏族自治州', 26),
(319, '拉萨市', 27),
(320, '昌都地区', 27),
(321, '山南地区', 27),
(322, '日喀则地区', 27),
(323, '那曲地区', 27),
(324, '阿里地区', 27),
(325, '林芝地区', 27),
(326, '西安市', 28),
(327, '铜川市', 28),
(328, '宝鸡市', 28),
(329, '咸阳市', 28),
(330, '渭南市', 28),
(331, '延安市', 28),
(332, '汉中市', 28),
(333, '榆林市', 28),
(334, '安康市', 28),
(335, '商洛市', 28),
(336, '兰州市', 29),
(337, '嘉峪关市', 29),
(338, '金昌市', 29),
(339, '白银市', 29),
(340, '天水市', 29),
(341, '武威市', 29),
(342, '张掖市', 29),
(343, '平凉市', 29),
(344, '酒泉市', 29),
(345, '庆阳市', 29),
(346, '定西市', 29),
(347, '陇南市', 29),
(348, '临夏回族自治州', 29),
(349, '甘南藏族自治州', 29),
(350, '西宁市', 30),
(351, '海东地区', 30),
(352, '海北藏族自治州', 30),
(353, '黄南藏族自治州', 30),
(354, '海南藏族自治州', 30),
(355, '果洛藏族自治州', 30),
(356, '玉树藏族自治州', 30),
(357, '海西蒙古族藏族自治州', 30),
(358, '银川市', 31),
(359, '石嘴山市', 31),
(360, '吴忠市', 31),
(361, '固原市', 31),
(362, '中卫市', 31),
(363, '乌鲁木齐市', 32),
(364, '克拉玛依市', 32),
(365, '吐鲁番地区', 32),
(366, '哈密地区', 32),
(367, '昌吉回族自治州', 32),
(368, '博尔塔拉蒙古自治州', 32),
(369, '巴音郭楞蒙古自治州', 32),
(370, '阿克苏地区', 32),
(371, '克孜勒苏柯尔克孜自治州', 32),
(372, '喀什地区', 32),
(373, '和田地区', 32),
(374, '伊犁哈萨克自治州', 32),
(375, '塔城地区', 32),
(376, '阿勒泰地区', 32),
(377, '自治区直辖县级行政区划', 32),
(378, '东城区', 33),
(379, '西城区', 33),
(382, '朝阳区', 33),
(383, '丰台区', 33),
(384, '石景山区', 33),
(385, '海淀区', 33),
(386, '门头沟区', 33),
(387, '房山区', 33),
(388, '通州区', 33),
(389, '顺义区', 33),
(390, '昌平区', 33),
(391, '大兴区', 33),
(392, '怀柔区', 33),
(393, '平谷区', 33),
(394, '密云县', 34),
(395, '延庆县', 34),
(396, '和平区', 35),
(397, '河东区', 35),
(398, '河西区', 35),
(399, '南开区', 35),
(400, '河北区', 35),
(401, '红桥区', 35),
(404, '滨海新区', 35),
(405, '东丽区', 35),
(406, '西青区', 35),
(407, '津南区', 35),
(408, '北辰区', 35),
(409, '武清区', 35),
(410, '宝坻区', 35),
(411, '宁河县', 36),
(412, '静海县', 36),
(413, '蓟县', 36),
(414, '市辖区', 37),
(415, '长安区', 37),
(416, '桥东区', 37),
(417, '桥西区', 37),
(418, '新华区', 37),
(419, '井陉矿区', 37),
(420, '裕华区', 37),
(421, '井陉县', 37),
(422, '正定县', 37),
(423, '栾城县', 37),
(424, '行唐县', 37),
(425, '灵寿县', 37),
(426, '高邑县', 37),
(427, '深泽县', 37),
(428, '赞皇县', 37),
(429, '无极县', 37),
(430, '平山县', 37),
(431, '元氏县', 37),
(432, '赵县', 37),
(433, '辛集市', 37),
(434, '藁城市', 37),
(435, '晋州市', 37),
(436, '新乐市', 37),
(437, '鹿泉市', 37),
(438, '市辖区', 38),
(439, '路南区', 38),
(440, '路北区', 38),
(441, '古冶区', 38),
(442, '开平区', 38),
(443, '丰南区', 38),
(444, '丰润区', 38),
(445, '滦县', 38),
(446, '滦南县', 38),
(447, '乐亭县', 38),
(448, '迁西县', 38),
(449, '玉田县', 38),
(450, '唐海县', 38),
(451, '遵化市', 38),
(452, '迁安市', 38),
(453, '市辖区', 39),
(454, '海港区', 39),
(455, '山海关区', 39),
(456, '北戴河区', 39),
(457, '青龙满族自治县', 39),
(458, '昌黎县', 39),
(459, '抚宁县', 39),
(460, '卢龙县', 39),
(461, '市辖区', 40),
(462, '邯山区', 40),
(463, '丛台区', 40),
(464, '复兴区', 40),
(465, '峰峰矿区', 40),
(466, '邯郸县', 40),
(467, '临漳县', 40),
(468, '成安县', 40),
(469, '大名县', 40),
(470, '涉县', 40),
(471, '磁县', 40),
(472, '肥乡县', 40),
(473, '永年县', 40),
(474, '邱县', 40),
(475, '鸡泽县', 40),
(476, '广平县', 40),
(477, '馆陶县', 40),
(478, '魏县', 40),
(479, '曲周县', 40),
(480, '武安市', 40),
(481, '市辖区', 41),
(482, '桥东区', 41),
(483, '桥西区', 41),
(484, '邢台县', 41),
(485, '临城县', 41),
(486, '内丘县', 41),
(487, '柏乡县', 41),
(488, '隆尧县', 41),
(489, '任县', 41),
(490, '南和县', 41),
(491, '宁晋县', 41),
(492, '巨鹿县', 41),
(493, '新河县', 41),
(494, '广宗县', 41),
(495, '平乡县', 41),
(496, '威县', 41),
(497, '清河县', 41),
(498, '临西县', 41),
(499, '南宫市', 41),
(500, '沙河市', 41),
(501, '市辖区', 42),
(502, '新市区', 42),
(503, '北市区', 42),
(504, '南市区', 42),
(505, '满城县', 42),
(506, '清苑县', 42),
(507, '涞水县', 42),
(508, '阜平县', 42),
(509, '徐水县', 42),
(510, '定兴县', 42),
(511, '唐县', 42),
(512, '高阳县', 42),
(513, '容城县', 42),
(514, '涞源县', 42),
(515, '望都县', 42),
(516, '安新县', 42),
(517, '易县', 42),
(518, '曲阳县', 42),
(519, '蠡县', 42),
(520, '顺平县', 42),
(521, '博野县', 42),
(522, '雄县', 42),
(523, '涿州市', 42),
(524, '定州市', 42),
(525, '安国市', 42),
(526, '高碑店市', 42),
(527, '市辖区', 43),
(528, '桥东区', 43),
(529, '桥西区', 43),
(530, '宣化区', 43),
(531, '下花园区', 43),
(532, '宣化县', 43),
(533, '张北县', 43),
(534, '康保县', 43),
(535, '沽源县', 43),
(536, '尚义县', 43),
(537, '蔚县', 43),
(538, '阳原县', 43),
(539, '怀安县', 43),
(540, '万全县', 43),
(541, '怀来县', 43),
(542, '涿鹿县', 43),
(543, '赤城县', 43),
(544, '崇礼县', 43),
(545, '市辖区', 44),
(546, '双桥区', 44),
(547, '双滦区', 44),
(548, '鹰手营子矿区', 44),
(549, '承德县', 44),
(550, '兴隆县', 44),
(551, '平泉县', 44),
(552, '滦平县', 44),
(553, '隆化县', 44),
(554, '丰宁满族自治县', 44),
(555, '宽城满族自治县', 44),
(556, '围场满族蒙古族自治县', 44),
(557, '市辖区', 45),
(558, '新华区', 45),
(559, '运河区', 45),
(560, '沧县', 45),
(561, '青县', 45),
(562, '东光县', 45),
(563, '海兴县', 45),
(564, '盐山县', 45),
(565, '肃宁县', 45),
(566, '南皮县', 45),
(567, '吴桥县', 45),
(568, '献县', 45),
(569, '孟村回族自治县', 45),
(570, '泊头市', 45),
(571, '任丘市', 45),
(572, '黄骅市', 45),
(573, '河间市', 45),
(574, '市辖区', 46),
(575, '安次区', 46),
(576, '广阳区', 46),
(577, '固安县', 46),
(578, '永清县', 46),
(579, '香河县', 46),
(580, '大城县', 46),
(581, '文安县', 46),
(582, '大厂回族自治县', 46),
(583, '霸州市', 46),
(584, '三河市', 46),
(585, '市辖区', 47),
(586, '桃城区', 47),
(587, '枣强县', 47),
(588, '武邑县', 47),
(589, '武强县', 47),
(590, '饶阳县', 47),
(591, '安平县', 47),
(592, '故城县', 47),
(593, '景县', 47),
(594, '阜城县', 47),
(595, '冀州市', 47),
(596, '深州市', 47),
(597, '市辖区', 48),
(598, '小店区', 48),
(599, '迎泽区', 48),
(600, '杏花岭区', 48),
(601, '尖草坪区', 48),
(602, '万柏林区', 48),
(603, '晋源区', 48),
(604, '清徐县', 48),
(605, '阳曲县', 48),
(606, '娄烦县', 48),
(607, '古交市', 48),
(608, '市辖区', 49),
(609, '城区', 49),
(610, '矿区', 49),
(611, '南郊区', 49),
(612, '新荣区', 49),
(613, '阳高县', 49),
(614, '天镇县', 49),
(615, '广灵县', 49),
(616, '灵丘县', 49),
(617, '浑源县', 49),
(618, '左云县', 49),
(619, '大同县', 49),
(620, '市辖区', 50),
(621, '城区', 50),
(622, '矿区', 50),
(623, '郊区', 50),
(624, '平定县', 50),
(625, '盂县', 50),
(626, '市辖区', 51),
(627, '城区', 51),
(628, '郊区', 51),
(629, '长治县', 51),
(630, '襄垣县', 51),
(631, '屯留县', 51),
(632, '平顺县', 51),
(633, '黎城县', 51),
(634, '壶关县', 51),
(635, '长子县', 51),
(636, '武乡县', 51),
(637, '沁县', 51),
(638, '沁源县', 51),
(639, '潞城市', 51),
(640, '市辖区', 52),
(641, '城区', 52),
(642, '沁水县', 52),
(643, '阳城县', 52),
(644, '陵川县', 52),
(645, '泽州县', 52),
(646, '高平市', 52),
(647, '市辖区', 53),
(648, '朔城区', 53),
(649, '平鲁区', 53),
(650, '山阴县', 53),
(651, '应县', 53),
(652, '右玉县', 53),
(653, '怀仁县', 53),
(654, '市辖区', 54),
(655, '榆次区', 54),
(656, '榆社县', 54),
(657, '左权县', 54),
(658, '和顺县', 54),
(659, '昔阳县', 54),
(660, '寿阳县', 54),
(661, '太谷县', 54),
(662, '祁县', 54),
(663, '平遥县', 54),
(664, '灵石县', 54),
(665, '介休市', 54),
(666, '市辖区', 55),
(667, '盐湖区', 55),
(668, '临猗县', 55),
(669, '万荣县', 55),
(670, '闻喜县', 55),
(671, '稷山县', 55),
(672, '新绛县', 55),
(673, '绛县', 55),
(674, '垣曲县', 55),
(675, '夏县', 55),
(676, '平陆县', 55),
(677, '芮城县', 55),
(678, '永济市', 55),
(679, '河津市', 55),
(680, '市辖区', 56),
(681, '忻府区', 56),
(682, '定襄县', 56),
(683, '五台县', 56),
(684, '代县', 56),
(685, '繁峙县', 56),
(686, '宁武县', 56),
(687, '静乐县', 56),
(688, '神池县', 56),
(689, '五寨县', 56),
(690, '岢岚县', 56),
(691, '河曲县', 56),
(692, '保德县', 56),
(693, '偏关县', 56),
(694, '原平市', 56),
(695, '市辖区', 57),
(696, '尧都区', 57),
(697, '曲沃县', 57),
(698, '翼城县', 57),
(699, '襄汾县', 57),
(700, '洪洞县', 57),
(701, '古县', 57),
(702, '安泽县', 57),
(703, '浮山县', 57),
(704, '吉县', 57),
(705, '乡宁县', 57),
(706, '大宁县', 57),
(707, '隰县', 57),
(708, '永和县', 57),
(709, '蒲县', 57),
(710, '汾西县', 57),
(711, '侯马市', 57),
(712, '霍州市', 57),
(713, '市辖区', 58),
(714, '离石区', 58),
(715, '文水县', 58),
(716, '交城县', 58),
(717, '兴县', 58),
(718, '临县', 58),
(719, '柳林县', 58),
(720, '石楼县', 58),
(721, '岚县', 58),
(722, '方山县', 58),
(723, '中阳县', 58),
(724, '交口县', 58),
(725, '孝义市', 58),
(726, '汾阳市', 58),
(727, '市辖区', 59),
(728, '新城区', 59),
(729, '回民区', 59),
(730, '玉泉区', 59),
(731, '赛罕区', 59),
(732, '土默特左旗', 59),
(733, '托克托县', 59),
(734, '和林格尔县', 59),
(735, '清水河县', 59),
(736, '武川县', 59),
(737, '市辖区', 60),
(738, '东河区', 60),
(739, '昆都仑区', 60),
(740, '青山区', 60),
(741, '石拐区', 60),
(742, '白云鄂博矿区', 60),
(743, '九原区', 60),
(744, '土默特右旗', 60),
(745, '固阳县', 60),
(746, '达尔罕茂明安联合旗', 60),
(747, '市辖区', 61),
(748, '海勃湾区', 61),
(749, '海南区', 61),
(750, '乌达区', 61),
(751, '市辖区', 62),
(752, '红山区', 62),
(753, '元宝山区', 62),
(754, '松山区', 62),
(755, '阿鲁科尔沁旗', 62),
(756, '巴林左旗', 62),
(757, '巴林右旗', 62),
(758, '林西县', 62),
(759, '克什克腾旗', 62),
(760, '翁牛特旗', 62),
(761, '喀喇沁旗', 62),
(762, '宁城县', 62),
(763, '敖汉旗', 62),
(764, '市辖区', 63),
(765, '科尔沁区', 63),
(766, '科尔沁左翼中旗', 63),
(767, '科尔沁左翼后旗', 63),
(768, '开鲁县', 63),
(769, '库伦旗', 63),
(770, '奈曼旗', 63),
(771, '扎鲁特旗', 63),
(772, '霍林郭勒市', 63),
(773, '东胜区', 64),
(774, '达拉特旗', 64),
(775, '准格尔旗', 64),
(776, '鄂托克前旗', 64),
(777, '鄂托克旗', 64),
(778, '杭锦旗', 64),
(779, '乌审旗', 64),
(780, '伊金霍洛旗', 64),
(781, '市辖区', 65),
(782, '海拉尔区', 65),
(783, '阿荣旗', 65),
(784, '莫力达瓦达斡尔族自治旗', 65),
(785, '鄂伦春自治旗', 65),
(786, '鄂温克族自治旗', 65),
(787, '陈巴尔虎旗', 65),
(788, '新巴尔虎左旗', 65),
(789, '新巴尔虎右旗', 65),
(790, '满洲里市', 65),
(791, '牙克石市', 65),
(792, '扎兰屯市', 65),
(793, '额尔古纳市', 65),
(794, '根河市', 65),
(795, '市辖区', 66),
(796, '临河区', 66),
(797, '五原县', 66),
(798, '磴口县', 66),
(799, '乌拉特前旗', 66),
(800, '乌拉特中旗', 66),
(801, '乌拉特后旗', 66),
(802, '杭锦后旗', 66),
(803, '市辖区', 67),
(804, '集宁区', 67),
(805, '卓资县', 67),
(806, '化德县', 67),
(807, '商都县', 67),
(808, '兴和县', 67),
(809, '凉城县', 67),
(810, '察哈尔右翼前旗', 67),
(811, '察哈尔右翼中旗', 67),
(812, '察哈尔右翼后旗', 67),
(813, '四子王旗', 67),
(814, '丰镇市', 67),
(815, '乌兰浩特市', 68),
(816, '阿尔山市', 68),
(817, '科尔沁右翼前旗', 68),
(818, '科尔沁右翼中旗', 68),
(819, '扎赉特旗', 68),
(820, '突泉县', 68),
(821, '二连浩特市', 69),
(822, '锡林浩特市', 69),
(823, '阿巴嘎旗', 69),
(824, '苏尼特左旗', 69),
(825, '苏尼特右旗', 69),
(826, '东乌珠穆沁旗', 69),
(827, '西乌珠穆沁旗', 69),
(828, '太仆寺旗', 69),
(829, '镶黄旗', 69),
(830, '正镶白旗', 69),
(831, '正蓝旗', 69),
(832, '多伦县', 69),
(833, '阿拉善左旗', 70),
(834, '阿拉善右旗', 70),
(835, '额济纳旗', 70),
(836, '市辖区', 71),
(837, '和平区', 71),
(838, '沈河区', 71),
(839, '大东区', 71),
(840, '皇姑区', 71),
(841, '铁西区', 71),
(842, '苏家屯区', 71),
(843, '东陵区', 71),
(844, '沈北新区', 71),
(845, '于洪区', 71),
(846, '辽中县', 71),
(847, '康平县', 71),
(848, '法库县', 71),
(849, '新民市', 71),
(850, '市辖区', 72),
(851, '中山区', 72),
(852, '西岗区', 72),
(853, '沙河口区', 72),
(854, '甘井子区', 72),
(855, '旅顺口区', 72),
(856, '金州区', 72),
(857, '长海县', 72),
(858, '瓦房店市', 72),
(859, '普兰店市', 72),
(860, '庄河市', 72),
(861, '市辖区', 73),
(862, '铁东区', 73),
(863, '铁西区', 73),
(864, '立山区', 73),
(865, '千山区', 73),
(866, '台安县', 73),
(867, '岫岩满族自治县', 73),
(868, '海城市', 73),
(869, '市辖区', 74),
(870, '新抚区', 74),
(871, '东洲区', 74),
(872, '望花区', 74),
(873, '顺城区', 74),
(874, '抚顺县', 74),
(875, '新宾满族自治县', 74),
(876, '清原满族自治县', 74),
(877, '市辖区', 75),
(878, '平山区', 75),
(879, '溪湖区', 75),
(880, '明山区', 75),
(881, '南芬区', 75),
(882, '本溪满族自治县', 75),
(883, '桓仁满族自治县', 75),
(884, '市辖区', 76),
(885, '元宝区', 76),
(886, '振兴区', 76),
(887, '振安区', 76),
(888, '宽甸满族自治县', 76),
(889, '东港市', 76),
(890, '凤城市', 76),
(891, '市辖区', 77),
(892, '古塔区', 77),
(893, '凌河区', 77),
(894, '太和区', 77),
(895, '黑山县', 77),
(896, '义县', 77),
(897, '凌海市', 77),
(898, '北镇市', 77),
(899, '市辖区', 78),
(900, '站前区', 78),
(901, '西市区', 78),
(902, '鲅鱼圈区', 78),
(903, '老边区', 78),
(904, '盖州市', 78),
(905, '大石桥市', 78),
(906, '市辖区', 79),
(907, '海州区', 79),
(908, '新邱区', 79),
(909, '太平区', 79),
(910, '清河门区', 79),
(911, '细河区', 79),
(912, '阜新蒙古族自治县', 79),
(913, '彰武县', 79),
(914, '市辖区', 80),
(915, '白塔区', 80),
(916, '文圣区', 80),
(917, '宏伟区', 80),
(918, '弓长岭区', 80),
(919, '太子河区', 80),
(920, '辽阳县', 80),
(921, '灯塔市', 80),
(922, '市辖区', 81),
(923, '双台子区', 81),
(924, '兴隆台区', 81),
(925, '大洼县', 81),
(926, '盘山县', 81),
(927, '市辖区', 82),
(928, '银州区', 82),
(929, '清河区', 82),
(930, '铁岭县', 82),
(931, '西丰县', 82),
(932, '昌图县', 82),
(933, '调兵山市', 82),
(934, '开原市', 82),
(935, '市辖区', 83),
(936, '双塔区', 83),
(937, '龙城区', 83),
(938, '朝阳县', 83),
(939, '建平县', 83),
(940, '喀喇沁左翼蒙古族自治县', 83),
(941, '北票市', 83),
(942, '凌源市', 83),
(943, '市辖区', 84),
(944, '连山区', 84),
(945, '龙港区', 84),
(946, '南票区', 84),
(947, '绥中县', 84),
(948, '建昌县', 84),
(949, '兴城市', 84),
(950, '市辖区', 85),
(951, '南关区', 85),
(952, '宽城区', 85),
(953, '朝阳区', 85),
(954, '二道区', 85),
(955, '绿园区', 85),
(956, '双阳区', 85),
(957, '农安县', 85),
(958, '九台市', 85),
(959, '榆树市', 85),
(960, '德惠市', 85),
(961, '市辖区', 86),
(962, '昌邑区', 86),
(963, '龙潭区', 86),
(964, '船营区', 86),
(965, '丰满区', 86),
(966, '永吉县', 86),
(967, '蛟河市', 86),
(968, '桦甸市', 86),
(969, '舒兰市', 86),
(970, '磐石市', 86),
(971, '市辖区', 87),
(972, '铁西区', 87),
(973, '铁东区', 87),
(974, '梨树县', 87),
(975, '伊通满族自治县', 87),
(976, '公主岭市', 87),
(977, '双辽市', 87),
(978, '市辖区', 88),
(979, '龙山区', 88),
(980, '西安区', 88),
(981, '东丰县', 88),
(982, '东辽县', 88),
(983, '市辖区', 89),
(984, '东昌区', 89),
(985, '二道江区', 89),
(986, '通化县', 89),
(987, '辉南县', 89),
(988, '柳河县', 89),
(989, '梅河口市', 89),
(990, '集安市', 89),
(991, '市辖区', 90),
(992, '八道江区', 90),
(993, '抚松县', 90),
(994, '靖宇县', 90),
(995, '长白朝鲜族自治县', 90),
(996, '江源区', 90),
(997, '临江市', 90),
(998, '市辖区', 91),
(999, '宁江区', 91),
(1000, '前郭尔罗斯蒙古族自治县', 91),
(1001, '长岭县', 91),
(1002, '乾安县', 91),
(1003, '扶余县', 91),
(1004, '市辖区', 92),
(1005, '洮北区', 92),
(1006, '镇赉县', 92),
(1007, '通榆县', 92),
(1008, '洮南市', 92),
(1009, '大安市', 92),
(1010, '延吉市', 93),
(1011, '图们市', 93),
(1012, '敦化市', 93),
(1013, '珲春市', 93),
(1014, '龙井市', 93),
(1015, '和龙市', 93),
(1016, '汪清县', 93),
(1017, '安图县', 93),
(1018, '市辖区', 94),
(1019, '道里区', 94),
(1020, '南岗区', 94),
(1021, '道外区', 94),
(1022, '香坊区', 94),
(1024, '平房区', 94),
(1025, '松北区', 94),
(1026, '呼兰区', 94),
(1027, '依兰县', 94),
(1028, '方正县', 94),
(1029, '宾县', 94),
(1030, '巴彦县', 94),
(1031, '木兰县', 94),
(1032, '通河县', 94),
(1033, '延寿县', 94),
(1034, '阿城区', 94),
(1035, '双城市', 94),
(1036, '尚志市', 94),
(1037, '五常市', 94),
(1038, '市辖区', 95),
(1039, '龙沙区', 95),
(1040, '建华区', 95),
(1041, '铁锋区', 95),
(1042, '昂昂溪区', 95),
(1043, '富拉尔基区', 95),
(1044, '碾子山区', 95),
(1045, '梅里斯达斡尔族区', 95),
(1046, '龙江县', 95),
(1047, '依安县', 95),
(1048, '泰来县', 95),
(1049, '甘南县', 95),
(1050, '富裕县', 95),
(1051, '克山县', 95),
(1052, '克东县', 95),
(1053, '拜泉县', 95),
(1054, '讷河市', 95),
(1055, '市辖区', 96),
(1056, '鸡冠区', 96),
(1057, '恒山区', 96),
(1058, '滴道区', 96),
(1059, '梨树区', 96),
(1060, '城子河区', 96),
(1061, '麻山区', 96),
(1062, '鸡东县', 96),
(1063, '虎林市', 96),
(1064, '密山市', 96),
(1065, '市辖区', 97),
(1066, '向阳区', 97),
(1067, '工农区', 97),
(1068, '南山区', 97),
(1069, '兴安区', 97),
(1070, '东山区', 97),
(1071, '兴山区', 97),
(1072, '萝北县', 97),
(1073, '绥滨县', 97),
(1074, '市辖区', 98),
(1075, '尖山区', 98),
(1076, '岭东区', 98),
(1077, '四方台区', 98),
(1078, '宝山区', 98),
(1079, '集贤县', 98),
(1080, '友谊县', 98),
(1081, '宝清县', 98),
(1082, '饶河县', 98),
(1083, '市辖区', 99),
(1084, '萨尔图区', 99),
(1085, '龙凤区', 99),
(1086, '让胡路区', 99),
(1087, '红岗区', 99),
(1088, '大同区', 99),
(1089, '肇州县', 99),
(1090, '肇源县', 99),
(1091, '林甸县', 99),
(1092, '杜尔伯特蒙古族自治县', 99),
(1093, '市辖区', 100),
(1094, '伊春区', 100),
(1095, '南岔区', 100),
(1096, '友好区', 100),
(1097, '西林区', 100),
(1098, '翠峦区', 100),
(1099, '新青区', 100),
(1100, '美溪区', 100),
(1101, '金山屯区', 100),
(1102, '五营区', 100),
(1103, '乌马河区', 100),
(1104, '汤旺河区', 100),
(1105, '带岭区', 100),
(1106, '乌伊岭区', 100),
(1107, '红星区', 100),
(1108, '上甘岭区', 100),
(1109, '嘉荫县', 100),
(1110, '铁力市', 100),
(1111, '市辖区', 101),
(1113, '向阳区', 101),
(1114, '前进区', 101),
(1115, '东风区', 101),
(1116, '郊区', 101),
(1117, '桦南县', 101),
(1118, '桦川县', 101),
(1119, '汤原县', 101),
(1120, '抚远县', 101),
(1121, '同江市', 101),
(1122, '富锦市', 101),
(1123, '市辖区', 102),
(1124, '新兴区', 102),
(1125, '桃山区', 102),
(1126, '茄子河区', 102),
(1127, '勃利县', 102),
(1128, '市辖区', 103),
(1129, '东安区', 103),
(1130, '阳明区', 103),
(1131, '爱民区', 103),
(1132, '西安区', 103),
(1133, '东宁县', 103),
(1134, '林口县', 103),
(1135, '绥芬河市', 103),
(1136, '海林市', 103),
(1137, '宁安市', 103),
(1138, '穆棱市', 103),
(1139, '市辖区', 104),
(1140, '爱辉区', 104),
(1141, '嫩江县', 104),
(1142, '逊克县', 104),
(1143, '孙吴县', 104),
(1144, '北安市', 104),
(1145, '五大连池市', 104),
(1146, '市辖区', 105),
(1147, '北林区', 105),
(1148, '望奎县', 105),
(1149, '兰西县', 105),
(1150, '青冈县', 105),
(1151, '庆安县', 105),
(1152, '明水县', 105),
(1153, '绥棱县', 105),
(1154, '安达市', 105),
(1155, '肇东市', 105),
(1156, '海伦市', 105),
(1157, '呼玛县', 106),
(1158, '塔河县', 106),
(1159, '漠河县', 106),
(1160, '黄浦区', 107),
(1161, '卢湾区', 107),
(1162, '徐汇区', 107),
(1163, '长宁区', 107),
(1164, '静安区', 107),
(1165, '普陀区', 107),
(1166, '闸北区', 107),
(1167, '虹口区', 107),
(1168, '杨浦区', 107),
(1169, '闵行区', 107),
(1170, '宝山区', 107),
(1171, '嘉定区', 107),
(1172, '浦东新区', 107),
(1173, '金山区', 107),
(1174, '松江区', 107),
(1175, '青浦区', 107),
(1177, '奉贤区', 107),
(1178, '崇明县', 108),
(1179, '市辖区', 109),
(1180, '玄武区', 109),
(1181, '白下区', 109),
(1182, '秦淮区', 109),
(1183, '建邺区', 109),
(1184, '鼓楼区', 109),
(1185, '下关区', 109),
(1186, '浦口区', 109),
(1187, '栖霞区', 109),
(1188, '雨花台区', 109),
(1189, '江宁区', 109),
(1190, '六合区', 109),
(1191, '溧水县', 109),
(1192, '高淳县', 109),
(1193, '市辖区', 110),
(1194, '崇安区', 110),
(1195, '南长区', 110),
(1196, '北塘区', 110),
(1197, '锡山区', 110),
(1198, '惠山区', 110),
(1199, '滨湖区', 110),
(1200, '江阴市', 110),
(1201, '宜兴市', 110),
(1202, '市辖区', 111),
(1203, '鼓楼区', 111),
(1204, '云龙区', 111),
(1206, '贾汪区', 111),
(1207, '泉山区', 111),
(1208, '丰县', 111),
(1209, '沛县', 111),
(1210, '铜山区', 111),
(1211, '睢宁县', 111),
(1212, '新沂市', 111),
(1213, '邳州市', 111),
(1214, '市辖区', 112),
(1215, '天宁区', 112),
(1216, '钟楼区', 112),
(1217, '戚墅堰区', 112),
(1218, '新北区', 112),
(1219, '武进区', 112),
(1220, '溧阳市', 112),
(1221, '金坛市', 112),
(1222, '市辖区', 113),
(1223, '沧浪区', 113),
(1224, '平江区', 113),
(1225, '金阊区', 113),
(1226, '虎丘区', 113),
(1227, '吴中区', 113),
(1228, '相城区', 113),
(1229, '常熟市', 113),
(1230, '张家港市', 113),
(1231, '昆山市', 113),
(1232, '吴江市', 113),
(1233, '太仓市', 113),
(1234, '市辖区', 114),
(1235, '崇川区', 114),
(1236, '港闸区', 114),
(1237, '海安县', 114),
(1238, '如东县', 114),
(1239, '启东市', 114),
(1240, '如皋市', 114),
(1241, '通州区', 114),
(1242, '海门市', 114),
(1243, '市辖区', 115),
(1244, '连云区', 115),
(1245, '新浦区', 115),
(1246, '海州区', 115),
(1247, '赣榆县', 115),
(1248, '东海县', 115),
(1249, '灌云县', 115),
(1250, '灌南县', 115),
(1251, '市辖区', 116),
(1252, '清河区', 116),
(1253, '楚州区', 116),
(1254, '淮阴区', 116),
(1255, '清浦区', 116),
(1256, '涟水县', 116),
(1257, '洪泽县', 116),
(1258, '盱眙县', 116),
(1259, '金湖县', 116),
(1260, '市辖区', 117),
(1261, '亭湖区', 117),
(1262, '盐都区', 117),
(1263, '响水县', 117),
(1264, '滨海县', 117),
(1265, '阜宁县', 117),
(1266, '射阳县', 117),
(1267, '建湖县', 117),
(1268, '东台市', 117),
(1269, '大丰市', 117),
(1270, '市辖区', 118),
(1271, '广陵区', 118),
(1272, '邗江区', 118),
(1273, '维扬区', 118),
(1274, '宝应县', 118),
(1275, '仪征市', 118),
(1276, '高邮市', 118),
(1277, '江都市', 118),
(1278, '市辖区', 119),
(1279, '京口区', 119),
(1280, '润州区', 119),
(1281, '丹徒区', 119),
(1282, '丹阳市', 119),
(1283, '扬中市', 119),
(1284, '句容市', 119),
(1285, '市辖区', 120),
(1286, '海陵区', 120),
(1287, '高港区', 120),
(1288, '兴化市', 120),
(1289, '靖江市', 120),
(1290, '泰兴市', 120),
(1291, '姜堰市', 120),
(1292, '市辖区', 121),
(1293, '宿城区', 121),
(1294, '宿豫区', 121),
(1295, '沭阳县', 121),
(1296, '泗阳县', 121),
(1297, '泗洪县', 121),
(1298, '市辖区', 122),
(1299, '上城区', 122),
(1300, '下城区', 122),
(1301, '江干区', 122),
(1302, '拱墅区', 122),
(1303, '西湖区', 122),
(1304, '滨江区', 122),
(1305, '萧山区', 122),
(1306, '余杭区', 122),
(1307, '桐庐县', 122),
(1308, '淳安县', 122),
(1309, '建德市', 122),
(1310, '富阳市', 122),
(1311, '临安市', 122),
(1312, '市辖区', 123),
(1313, '海曙区', 123),
(1314, '江东区', 123),
(1315, '江北区', 123),
(1316, '北仑区', 123),
(1317, '镇海区', 123),
(1318, '鄞州区', 123),
(1319, '象山县', 123),
(1320, '宁海县', 123),
(1321, '余姚市', 123),
(1322, '慈溪市', 123),
(1323, '奉化市', 123),
(1324, '市辖区', 124),
(1325, '鹿城区', 124),
(1326, '龙湾区', 124),
(1327, '瓯海区', 124),
(1328, '洞头县', 124),
(1329, '永嘉县', 124),
(1330, '平阳县', 124),
(1331, '苍南县', 124),
(1332, '文成县', 124),
(1333, '泰顺县', 124),
(1334, '瑞安市', 124),
(1335, '乐清市', 124),
(1336, '市辖区', 125),
(1338, '秀洲区', 125),
(1339, '嘉善县', 125),
(1340, '海盐县', 125),
(1341, '海宁市', 125),
(1342, '平湖市', 125),
(1343, '桐乡市', 125),
(1344, '市辖区', 126),
(1345, '吴兴区', 126),
(1346, '南浔区', 126),
(1347, '德清县', 126),
(1348, '长兴县', 126),
(1349, '安吉县', 126),
(1350, '市辖区', 127),
(1351, '越城区', 127),
(1352, '绍兴县', 127),
(1353, '新昌县', 127),
(1354, '诸暨市', 127),
(1355, '上虞市', 127),
(1356, '嵊州市', 127),
(1357, '市辖区', 128),
(1358, '婺城区', 128),
(1359, '金东区', 128),
(1360, '武义县', 128),
(1361, '浦江县', 128),
(1362, '磐安县', 128),
(1363, '兰溪市', 128),
(1364, '义乌市', 128),
(1365, '东阳市', 128),
(1366, '永康市', 128),
(1367, '市辖区', 129),
(1368, '柯城区', 129),
(1369, '衢江区', 129),
(1370, '常山县', 129),
(1371, '开化县', 129),
(1372, '龙游县', 129),
(1373, '江山市', 129),
(1374, '市辖区', 130),
(1375, '定海区', 130),
(1376, '普陀区', 130),
(1377, '岱山县', 130),
(1378, '嵊泗县', 130),
(1379, '市辖区', 131),
(1380, '椒江区', 131),
(1381, '黄岩区', 131),
(1382, '路桥区', 131),
(1383, '玉环县', 131),
(1384, '三门县', 131),
(1385, '天台县', 131),
(1386, '仙居县', 131),
(1387, '温岭市', 131),
(1388, '临海市', 131),
(1389, '市辖区', 132),
(1390, '莲都区', 132),
(1391, '青田县', 132),
(1392, '缙云县', 132),
(1393, '遂昌县', 132),
(1394, '松阳县', 132),
(1395, '云和县', 132),
(1396, '庆元县', 132),
(1397, '景宁畲族自治县', 132),
(1398, '龙泉市', 132),
(1399, '市辖区', 133),
(1400, '瑶海区', 133),
(1401, '庐阳区', 133),
(1402, '蜀山区', 133),
(1403, '包河区', 133),
(1404, '长丰县', 133),
(1405, '肥东县', 133),
(1406, '肥西县', 133),
(1407, '市辖区', 1412),
(1408, '镜湖区', 1412),
(1409, '三山区', 1412),
(1410, '弋江区', 1412),
(1411, '鸠江区', 1412),
(1412, '芜湖市', 134),
(1413, '繁昌县', 1412),
(1414, '南陵县', 1412),
(1415, '市辖区', 135),
(1416, '龙子湖区', 135),
(1417, '蚌山区', 135),
(1418, '禹会区', 135),
(1419, '淮上区', 135),
(1420, '怀远县', 135),
(1421, '五河县', 135),
(1422, '固镇县', 135),
(1423, '市辖区', 136),
(1424, '大通区', 136),
(1425, '田家庵区', 136),
(1426, '谢家集区', 136),
(1427, '八公山区', 136),
(1428, '潘集区', 136),
(1429, '凤台县', 136),
(1430, '市辖区', 137),
(1431, '金家庄区', 137),
(1432, '花山区', 137),
(1433, '雨山区', 137),
(1434, '当涂县', 137),
(1435, '市辖区', 138),
(1436, '杜集区', 138),
(1437, '相山区', 138),
(1438, '烈山区', 138),
(1439, '濉溪县', 138),
(1440, '市辖区', 139),
(1441, '铜官山区', 139),
(1442, '狮子山区', 139),
(1443, '郊区', 139),
(1444, '铜陵县', 139),
(1445, '市辖区', 140),
(1446, '迎江区', 140),
(1447, '大观区', 140),
(1448, '宜秀区', 140),
(1449, '怀宁县', 140),
(1450, '枞阳县', 140),
(1451, '潜山县', 140),
(1452, '太湖县', 140),
(1453, '宿松县', 140),
(1454, '望江县', 140),
(1455, '岳西县', 140),
(1456, '桐城市', 140),
(1457, '市辖区', 141),
(1458, '屯溪区', 141),
(1459, '黄山区', 141),
(1460, '徽州区', 141),
(1461, '歙县', 141),
(1462, '休宁县', 141),
(1463, '黟县', 141),
(1464, '祁门县', 141),
(1465, '市辖区', 142),
(1466, '琅琊区', 142),
(1467, '南谯区', 142),
(1468, '来安县', 142),
(1469, '全椒县', 142),
(1470, '定远县', 142),
(1471, '凤阳县', 142),
(1472, '天长市', 142),
(1473, '明光市', 142),
(1474, '市辖区', 143),
(1475, '颍州区', 143),
(1476, '颍东区', 143),
(1477, '颍泉区', 143),
(1478, '临泉县', 143),
(1479, '太和县', 143),
(1480, '阜南县', 143),
(1481, '颍上县', 143),
(1482, '界首市', 143),
(1483, '市辖区', 144),
(1484, '埇桥区', 144),
(1485, '砀山县', 144),
(1486, '萧县', 144),
(1487, '灵璧县', 144),
(1488, '泗县', 144),
(1489, '市辖区', 145),
(1490, '居巢区', 145),
(1491, '庐江县', 145),
(1492, '无为县', 145),
(1493, '含山县', 145),
(1494, '和县', 145),
(1495, '市辖区', 146),
(1496, '金安区', 146),
(1497, '裕安区', 146),
(1498, '寿县', 146),
(1499, '霍邱县', 146),
(1500, '舒城县', 146),
(1501, '金寨县', 146),
(1502, '霍山县', 146),
(1503, '市辖区', 147),
(1504, '谯城区', 147),
(1505, '涡阳县', 147),
(1506, '蒙城县', 147),
(1507, '利辛县', 147),
(1508, '市辖区', 148),
(1509, '贵池区', 148),
(1510, '东至县', 148),
(1511, '石台县', 148),
(1512, '青阳县', 148),
(1513, '市辖区', 149),
(1514, '宣州区', 149),
(1515, '郎溪县', 149),
(1516, '广德县', 149),
(1517, '泾县', 149),
(1518, '绩溪县', 149),
(1519, '旌德县', 149),
(1520, '宁国市', 149),
(1521, '市辖区', 150),
(1522, '鼓楼区', 150),
(1523, '台江区', 150),
(1524, '仓山区', 150),
(1525, '马尾区', 150),
(1526, '晋安区', 150),
(1527, '闽侯县', 150),
(1528, '连江县', 150),
(1529, '罗源县', 150),
(1530, '闽清县', 150),
(1531, '永泰县', 150),
(1532, '平潭县', 150),
(1533, '福清市', 150),
(1534, '长乐市', 150),
(1535, '市辖区', 151),
(1536, '思明区', 151),
(1537, '海沧区', 151),
(1538, '湖里区', 151),
(1539, '集美区', 151),
(1540, '同安区', 151),
(1541, '翔安区', 151),
(1542, '市辖区', 152),
(1543, '城厢区', 152),
(1544, '涵江区', 152),
(1545, '荔城区', 152),
(1546, '秀屿区', 152),
(1547, '仙游县', 152),
(1548, '市辖区', 153),
(1549, '梅列区', 153),
(1550, '三元区', 153),
(1551, '明溪县', 153),
(1552, '清流县', 153),
(1553, '宁化县', 153),
(1554, '大田县', 153),
(1555, '尤溪县', 153),
(1556, '沙县', 153),
(1557, '将乐县', 153),
(1558, '泰宁县', 153),
(1559, '建宁县', 153),
(1560, '永安市', 153),
(1561, '市辖区', 154),
(1562, '鲤城区', 154),
(1563, '丰泽区', 154),
(1564, '洛江区', 154),
(1565, '泉港区', 154),
(1566, '惠安县', 154),
(1567, '安溪县', 154),
(1568, '永春县', 154),
(1569, '德化县', 154),
(1570, '金门县', 154),
(1571, '石狮市', 154),
(1572, '晋江市', 154),
(1573, '南安市', 154),
(1574, '市辖区', 155),
(1575, '芗城区', 155),
(1576, '龙文区', 155),
(1577, '云霄县', 155),
(1578, '漳浦县', 155),
(1579, '诏安县', 155),
(1580, '长泰县', 155),
(1581, '东山县', 155),
(1582, '南靖县', 155),
(1583, '平和县', 155),
(1584, '华安县', 155),
(1585, '龙海市', 155),
(1586, '市辖区', 156),
(1587, '延平区', 156),
(1588, '顺昌县', 156),
(1589, '浦城县', 156),
(1590, '光泽县', 156),
(1591, '松溪县', 156),
(1592, '政和县', 156),
(1593, '邵武市', 156),
(1594, '武夷山市', 156),
(1595, '建瓯市', 156),
(1596, '建阳市', 156),
(1597, '市辖区', 157),
(1598, '新罗区', 157),
(1599, '长汀县', 157),
(1600, '永定县', 157),
(1601, '上杭县', 157),
(1602, '武平县', 157),
(1603, '连城县', 157),
(1604, '漳平市', 157),
(1605, '市辖区', 158),
(1606, '蕉城区', 158),
(1607, '霞浦县', 158),
(1608, '古田县', 158),
(1609, '屏南县', 158),
(1610, '寿宁县', 158),
(1611, '周宁县', 158),
(1612, '柘荣县', 158),
(1613, '福安市', 158),
(1614, '福鼎市', 158),
(1615, '市辖区', 159),
(1616, '东湖区', 159),
(1617, '西湖区', 159),
(1618, '青云谱区', 159),
(1619, '湾里区', 159),
(1620, '青山湖区', 159),
(1621, '南昌县', 159),
(1622, '新建县', 159),
(1623, '安义县', 159),
(1624, '进贤县', 159),
(1625, '市辖区', 160),
(1626, '昌江区', 160),
(1627, '珠山区', 160),
(1628, '浮梁县', 160),
(1629, '乐平市', 160),
(1630, '市辖区', 161),
(1631, '安源区', 161),
(1632, '湘东区', 161),
(1633, '莲花县', 161),
(1634, '上栗县', 161),
(1635, '芦溪县', 161),
(1636, '市辖区', 162),
(1637, '庐山区', 162),
(1638, '浔阳区', 162),
(1639, '九江县', 162),
(1640, '武宁县', 162),
(1641, '修水县', 162),
(1642, '永修县', 162),
(1643, '德安县', 162),
(1644, '星子县', 162),
(1645, '都昌县', 162),
(1646, '湖口县', 162),
(1647, '彭泽县', 162),
(1648, '瑞昌市', 162),
(1649, '市辖区', 163),
(1650, '渝水区', 163),
(1651, '分宜县', 163),
(1652, '市辖区', 164),
(1653, '月湖区', 164),
(1654, '余江县', 164),
(1655, '贵溪市', 164),
(1656, '市辖区', 165),
(1657, '章贡区', 165),
(1658, '赣县', 165),
(1659, '信丰县', 165),
(1660, '大余县', 165),
(1661, '上犹县', 165),
(1662, '崇义县', 165),
(1663, '安远县', 165),
(1664, '龙南县', 165),
(1665, '定南县', 165),
(1666, '全南县', 165),
(1667, '宁都县', 165),
(1668, '于都县', 165),
(1669, '兴国县', 165),
(1670, '会昌县', 165),
(1671, '寻乌县', 165),
(1672, '石城县', 165),
(1673, '瑞金市', 165),
(1674, '南康市', 165),
(1675, '市辖区', 166),
(1676, '吉州区', 166),
(1677, '青原区', 166),
(1678, '吉安县', 166),
(1679, '吉水县', 166),
(1680, '峡江县', 166),
(1681, '新干县', 166),
(1682, '永丰县', 166),
(1683, '泰和县', 166),
(1684, '遂川县', 166),
(1685, '万安县', 166),
(1686, '安福县', 166),
(1687, '永新县', 166),
(1688, '井冈山市', 166),
(1689, '市辖区', 167),
(1690, '袁州区', 167),
(1691, '奉新县', 167),
(1692, '万载县', 167),
(1693, '上高县', 167),
(1694, '宜丰县', 167),
(1695, '靖安县', 167),
(1696, '铜鼓县', 167),
(1697, '丰城市', 167),
(1698, '樟树市', 167),
(1699, '高安市', 167),
(1700, '市辖区', 168),
(1701, '临川区', 168),
(1702, '南城县', 168),
(1703, '黎川县', 168),
(1704, '南丰县', 168),
(1705, '崇仁县', 168),
(1706, '乐安县', 168),
(1707, '宜黄县', 168),
(1708, '金溪县', 168),
(1709, '资溪县', 168),
(1710, '东乡县', 168),
(1711, '广昌县', 168),
(1712, '市辖区', 169),
(1713, '信州区', 169),
(1714, '上饶县', 169),
(1715, '广丰县', 169),
(1716, '玉山县', 169),
(1717, '铅山县', 169),
(1718, '横峰县', 169),
(1719, '弋阳县', 169),
(1720, '余干县', 169),
(1721, '鄱阳县', 169),
(1722, '万年县', 169),
(1723, '婺源县', 169),
(1724, '德兴市', 169),
(1725, '市辖区', 170),
(1726, '历下区', 170),
(1727, '市中区', 170),
(1728, '槐荫区', 170),
(1729, '天桥区', 170),
(1730, '历城区', 170),
(1731, '长清区', 170),
(1732, '平阴县', 170),
(1733, '济阳县', 170),
(1734, '商河县', 170),
(1735, '章丘市', 170),
(1736, '市辖区', 171),
(1737, '市南区', 171),
(1738, '市北区', 171),
(1739, '四方区', 171),
(1740, '黄岛区', 171),
(1741, '崂山区', 171),
(1742, '李沧区', 171),
(1743, '城阳区', 171),
(1744, '胶州市', 171),
(1745, '即墨市', 171),
(1746, '平度市', 171),
(1747, '胶南市', 171),
(1748, '莱西市', 171),
(1749, '市辖区', 172),
(1750, '淄川区', 172),
(1751, '张店区', 172),
(1752, '博山区', 172),
(1753, '临淄区', 172),
(1754, '周村区', 172),
(1755, '桓台县', 172),
(1756, '高青县', 172),
(1757, '沂源县', 172),
(1758, '市辖区', 173),
(1759, '市中区', 173),
(1760, '薛城区', 173),
(1761, '峄城区', 173),
(1762, '台儿庄区', 173),
(1763, '山亭区', 173),
(1764, '滕州市', 173),
(1765, '市辖区', 174),
(1766, '东营区', 174),
(1767, '河口区', 174),
(1768, '垦利县', 174),
(1769, '利津县', 174),
(1770, '广饶县', 174),
(1771, '市辖区', 175),
(1772, '芝罘区', 175),
(1773, '福山区', 175),
(1774, '牟平区', 175),
(1775, '莱山区', 175),
(1776, '长岛县', 175),
(1777, '龙口市', 175),
(1778, '莱阳市', 175),
(1779, '莱州市', 175),
(1780, '蓬莱市', 175),
(1781, '招远市', 175),
(1782, '栖霞市', 175),
(1783, '海阳市', 175),
(1784, '市辖区', 176),
(1785, '潍城区', 176),
(1786, '寒亭区', 176),
(1787, '坊子区', 176),
(1788, '奎文区', 176),
(1789, '临朐县', 176),
(1790, '昌乐县', 176),
(1791, '青州市', 176),
(1792, '诸城市', 176),
(1793, '寿光市', 176),
(1794, '安丘市', 176),
(1795, '高密市', 176),
(1796, '昌邑市', 176),
(1797, '市辖区', 177),
(1798, '市中区', 177),
(1799, '任城区', 177),
(1800, '微山县', 177),
(1801, '鱼台县', 177),
(1802, '金乡县', 177),
(1803, '嘉祥县', 177),
(1804, '汶上县', 177),
(1805, '泗水县', 177),
(1806, '梁山县', 177),
(1807, '曲阜市', 177),
(1808, '兖州市', 177),
(1809, '邹城市', 177),
(1810, '市辖区', 178),
(1811, '泰山区', 178),
(1812, '岱岳区', 178),
(1813, '宁阳县', 178),
(1814, '东平县', 178),
(1815, '新泰市', 178),
(1816, '肥城市', 178),
(1817, '市辖区', 179),
(1818, '环翠区', 179),
(1819, '文登市', 179),
(1820, '荣成市', 179),
(1821, '乳山市', 179),
(1822, '市辖区', 180),
(1823, '东港区', 180),
(1824, '岚山区', 180),
(1825, '五莲县', 180),
(1826, '莒县', 180),
(1827, '市辖区', 181),
(1828, '莱城区', 181),
(1829, '钢城区', 181),
(1830, '市辖区', 182),
(1831, '兰山区', 182),
(1832, '罗庄区', 182),
(1833, '河东区', 182),
(1834, '沂南县', 182),
(1835, '郯城县', 182),
(1836, '沂水县', 182),
(1837, '苍山县', 182),
(1838, '费县', 182),
(1839, '平邑县', 182),
(1840, '莒南县', 182),
(1841, '蒙阴县', 182),
(1842, '临沭县', 182),
(1843, '市辖区', 183),
(1844, '德城区', 183),
(1845, '陵县', 183),
(1846, '宁津县', 183),
(1847, '庆云县', 183),
(1848, '临邑县', 183),
(1849, '齐河县', 183),
(1850, '平原县', 183),
(1851, '夏津县', 183),
(1852, '武城县', 183),
(1853, '乐陵市', 183),
(1854, '禹城市', 183),
(1855, '市辖区', 184),
(1856, '东昌府区', 184),
(1857, '阳谷县', 184),
(1858, '莘县', 184),
(1859, '茌平县', 184),
(1860, '东阿县', 184),
(1861, '冠县', 184),
(1862, '高唐县', 184),
(1863, '临清市', 184),
(1864, '市辖区', 185),
(1865, '滨城区', 185),
(1866, '惠民县', 185),
(1867, '阳信县', 185),
(1868, '无棣县', 185),
(1869, '沾化县', 185),
(1870, '博兴县', 185),
(1871, '邹平县', 185),
(1873, '牡丹区', 186),
(1874, '曹县', 186),
(1875, '单县', 186),
(1876, '成武县', 186),
(1877, '巨野县', 186),
(1878, '郓城县', 186),
(1879, '鄄城县', 186),
(1880, '定陶县', 186),
(1881, '东明县', 186),
(1882, '市辖区', 187),
(1883, '中原区', 187),
(1884, '二七区', 187),
(1885, '管城回族区', 187),
(1886, '金水区', 187),
(1887, '上街区', 187),
(1888, '惠济区', 187),
(1889, '中牟县', 187),
(1890, '巩义市', 187),
(1891, '荥阳市', 187),
(1892, '新密市', 187),
(1893, '新郑市', 187),
(1894, '登封市', 187),
(1895, '市辖区', 188),
(1896, '龙亭区', 188),
(1897, '顺河回族区', 188),
(1898, '鼓楼区', 188),
(1899, '禹王台区', 188),
(1900, '金明区', 188),
(1901, '杞县', 188),
(1902, '通许县', 188),
(1903, '尉氏县', 188),
(1904, '开封县', 188),
(1905, '兰考县', 188),
(1906, '市辖区', 189),
(1907, '老城区', 189),
(1908, '西工区', 189),
(1909, '瀍河回族区', 189),
(1910, '涧西区', 189),
(1911, '吉利区', 189),
(1912, '洛龙区', 189),
(1913, '孟津县', 189),
(1914, '新安县', 189),
(1915, '栾川县', 189),
(1916, '嵩县', 189),
(1917, '汝阳县', 189),
(1918, '宜阳县', 189),
(1919, '洛宁县', 189),
(1920, '伊川县', 189),
(1921, '偃师市', 189),
(1922, '市辖区', 190),
(1923, '新华区', 190),
(1924, '卫东区', 190),
(1925, '石龙区', 190),
(1926, '湛河区', 190),
(1927, '宝丰县', 190),
(1928, '叶县', 190),
(1929, '鲁山县', 190),
(1930, '郏县', 190),
(1931, '舞钢市', 190),
(1932, '汝州市', 190),
(1933, '市辖区', 191),
(1934, '文峰区', 191),
(1935, '北关区', 191),
(1936, '殷都区', 191),
(1937, '龙安区', 191),
(1938, '安阳县', 191),
(1939, '汤阴县', 191),
(1940, '滑县', 191),
(1941, '内黄县', 191),
(1942, '林州市', 191),
(1943, '市辖区', 192),
(1944, '鹤山区', 192),
(1945, '山城区', 192),
(1946, '淇滨区', 192),
(1947, '浚县', 192),
(1948, '淇县', 192),
(1949, '市辖区', 193),
(1950, '红旗区', 193),
(1951, '卫滨区', 193),
(1952, '凤泉区', 193),
(1953, '牧野区', 193),
(1954, '新乡县', 193),
(1955, '获嘉县', 193),
(1956, '原阳县', 193),
(1957, '延津县', 193),
(1958, '封丘县', 193),
(1959, '长垣县', 193),
(1960, '卫辉市', 193),
(1961, '辉县市', 193),
(1962, '市辖区', 194),
(1963, '解放区', 194),
(1964, '中站区', 194),
(1965, '马村区', 194),
(1966, '山阳区', 194),
(1967, '修武县', 194),
(1968, '博爱县', 194),
(1969, '武陟县', 194),
(1970, '温县', 194),
(1971, '济源市', 194),
(1972, '沁阳市', 194),
(1973, '孟州市', 194),
(1974, '市辖区', 195),
(1975, '华龙区', 195),
(1976, '清丰县', 195),
(1977, '南乐县', 195),
(1978, '范县', 195),
(1979, '台前县', 195),
(1980, '濮阳县', 195),
(1981, '市辖区', 196),
(1982, '魏都区', 196),
(1983, '许昌县', 196),
(1984, '鄢陵县', 196),
(1985, '襄城县', 196),
(1986, '禹州市', 196),
(1987, '长葛市', 196),
(1988, '市辖区', 197),
(1989, '源汇区', 197),
(1990, '郾城区', 197),
(1991, '召陵区', 197),
(1992, '舞阳县', 197),
(1993, '临颍县', 197),
(1994, '市辖区', 198),
(1995, '湖滨区', 198),
(1996, '渑池县', 198),
(1997, '陕县', 198),
(1998, '卢氏县', 198),
(1999, '义马市', 198),
(2000, '灵宝市', 198),
(2001, '市辖区', 199),
(2002, '宛城区', 199),
(2003, '卧龙区', 199),
(2004, '南召县', 199),
(2005, '方城县', 199),
(2006, '西峡县', 199),
(2007, '镇平县', 199),
(2008, '内乡县', 199),
(2009, '淅川县', 199),
(2010, '社旗县', 199),
(2011, '唐河县', 199),
(2012, '新野县', 199),
(2013, '桐柏县', 199),
(2014, '邓州市', 199),
(2015, '市辖区', 200),
(2016, '梁园区', 200),
(2017, '睢阳区', 200),
(2018, '民权县', 200),
(2019, '睢县', 200),
(2020, '宁陵县', 200),
(2021, '柘城县', 200),
(2022, '虞城县', 200),
(2023, '夏邑县', 200),
(2024, '永城市', 200),
(2025, '市辖区', 201),
(2026, '浉河区', 201),
(2027, '平桥区', 201),
(2028, '罗山县', 201),
(2029, '光山县', 201),
(2030, '新县', 201),
(2031, '商城县', 201),
(2032, '固始县', 201),
(2033, '潢川县', 201),
(2034, '淮滨县', 201),
(2035, '息县', 201),
(2036, '市辖区', 202),
(2037, '川汇区', 202),
(2038, '扶沟县', 202),
(2039, '西华县', 202),
(2040, '商水县', 202),
(2041, '沈丘县', 202),
(2042, '郸城县', 202),
(2043, '淮阳县', 202),
(2044, '太康县', 202),
(2045, '鹿邑县', 202),
(2046, '项城市', 202),
(2047, '市辖区', 203),
(2048, '驿城区', 203),
(2049, '西平县', 203),
(2050, '上蔡县', 203),
(2051, '平舆县', 203),
(2052, '正阳县', 203),
(2053, '确山县', 203),
(2054, '泌阳县', 203),
(2055, '汝南县', 203),
(2056, '遂平县', 203),
(2057, '新蔡县', 203),
(2058, '市辖区', 204),
(2059, '江岸区', 204),
(2060, '江汉区', 204),
(2061, '硚口区', 204),
(2062, '汉阳区', 204),
(2063, '武昌区', 204),
(2064, '青山区', 204),
(2065, '洪山区', 204),
(2066, '东西湖区', 204),
(2067, '汉南区', 204),
(2068, '蔡甸区', 204),
(2069, '江夏区', 204),
(2070, '黄陂区', 204),
(2071, '新洲区', 204),
(2072, '市辖区', 205),
(2073, '黄石港区', 205),
(2074, '西塞山区', 205),
(2075, '下陆区', 205),
(2076, '铁山区', 205),
(2077, '阳新县', 205),
(2078, '大冶市', 205),
(2079, '市辖区', 206),
(2080, '茅箭区', 206),
(2081, '张湾区', 206),
(2082, '郧县', 206),
(2083, '郧西县', 206),
(2084, '竹山县', 206),
(2085, '竹溪县', 206),
(2086, '房县', 206),
(2087, '丹江口市', 206),
(2088, '市辖区', 207),
(2089, '西陵区', 207),
(2090, '伍家岗区', 207),
(2091, '点军区', 207),
(2092, '猇亭区', 207),
(2093, '夷陵区', 207),
(2094, '远安县', 207),
(2095, '兴山县', 207),
(2096, '秭归县', 207),
(2097, '长阳土家族自治县', 207),
(2098, '五峰土家族自治县', 207),
(2099, '宜都市', 207),
(2100, '当阳市', 207),
(2101, '枝江市', 207),
(2102, '市辖区', 208),
(2103, '襄城区', 208),
(2104, '樊城区', 208),
(2105, '襄阳区', 208),
(2106, '南漳县', 208),
(2107, '谷城县', 208),
(2108, '保康县', 208),
(2109, '老河口市', 208),
(2110, '枣阳市', 208),
(2111, '宜城市', 208),
(2112, '市辖区', 209),
(2113, '梁子湖区', 209),
(2114, '华容区', 209),
(2115, '鄂城区', 209),
(2116, '市辖区', 210),
(2117, '东宝区', 210),
(2118, '掇刀区', 210),
(2119, '京山县', 210),
(2120, '沙洋县', 210),
(2121, '钟祥市', 210),
(2122, '市辖区', 211),
(2123, '孝南区', 211),
(2124, '孝昌县', 211),
(2125, '大悟县', 211),
(2126, '云梦县', 211),
(2127, '应城市', 211),
(2128, '安陆市', 211),
(2129, '汉川市', 211),
(2130, '市辖区', 212),
(2131, '沙市区', 212),
(2132, '荆州区', 212),
(2133, '公安县', 212),
(2134, '监利县', 212),
(2135, '江陵县', 212),
(2136, '石首市', 212),
(2137, '洪湖市', 212),
(2138, '松滋市', 212),
(2139, '市辖区', 213),
(2140, '黄州区', 213),
(2141, '团风县', 213),
(2142, '红安县', 213),
(2143, '罗田县', 213),
(2144, '英山县', 213),
(2145, '浠水县', 213),
(2146, '蕲春县', 213),
(2147, '黄梅县', 213),
(2148, '麻城市', 213),
(2149, '武穴市', 213),
(2150, '市辖区', 214),
(2151, '咸安区', 214),
(2152, '嘉鱼县', 214),
(2153, '通城县', 214),
(2154, '崇阳县', 214),
(2155, '通山县', 214),
(2156, '赤壁市', 214),
(2157, '市辖区', 215),
(2158, '曾都区', 215),
(2159, '广水市', 215),
(2160, '恩施市', 216),
(2161, '利川市', 216),
(2162, '建始县', 216),
(2163, '巴东县', 216),
(2164, '宣恩县', 216),
(2165, '咸丰县', 216),
(2166, '来凤县', 216),
(2167, '鹤峰县', 216),
(2168, '仙桃市', 217),
(2169, '潜江市', 217),
(2170, '天门市', 217),
(2171, '神农架林区', 217),
(2172, '市辖区', 218),
(2173, '芙蓉区', 218),
(2174, '天心区', 218),
(2175, '岳麓区', 218),
(2176, '开福区', 218),
(2177, '雨花区', 218),
(2178, '长沙县', 218),
(2179, '望城县', 218),
(2180, '宁乡县', 218),
(2181, '浏阳市', 218),
(2182, '市辖区', 219),
(2183, '荷塘区', 219),
(2184, '芦淞区', 219),
(2185, '石峰区', 219),
(2186, '天元区', 219),
(2187, '株洲县', 219),
(2188, '攸县', 219),
(2189, '茶陵县', 219),
(2190, '炎陵县', 219),
(2191, '醴陵市', 219),
(2192, '市辖区', 220),
(2193, '雨湖区', 220),
(2194, '岳塘区', 220),
(2195, '湘潭县', 220),
(2196, '湘乡市', 220),
(2197, '韶山市', 220),
(2198, '市辖区', 221),
(2199, '珠晖区', 221),
(2200, '雁峰区', 221),
(2201, '石鼓区', 221),
(2202, '蒸湘区', 221),
(2203, '南岳区', 221),
(2204, '衡阳县', 221),
(2205, '衡南县', 221),
(2206, '衡山县', 221),
(2207, '衡东县', 221),
(2208, '祁东县', 221),
(2209, '耒阳市', 221),
(2210, '常宁市', 221),
(2211, '市辖区', 222),
(2212, '双清区', 222),
(2213, '大祥区', 222),
(2214, '北塔区', 222),
(2215, '邵东县', 222),
(2216, '新邵县', 222),
(2217, '邵阳县', 222),
(2218, '隆回县', 222),
(2219, '洞口县', 222),
(2220, '绥宁县', 222),
(2221, '新宁县', 222),
(2222, '城步苗族自治县', 222),
(2223, '武冈市', 222),
(2224, '市辖区', 223),
(2225, '岳阳楼区', 223),
(2226, '云溪区', 223),
(2227, '君山区', 223),
(2228, '岳阳县', 223),
(2229, '华容县', 223),
(2230, '湘阴县', 223),
(2231, '平江县', 223),
(2232, '汨罗市', 223),
(2233, '临湘市', 223),
(2234, '市辖区', 224),
(2235, '武陵区', 224),
(2236, '鼎城区', 224),
(2237, '安乡县', 224),
(2238, '汉寿县', 224),
(2239, '澧县', 224),
(2240, '临澧县', 224),
(2241, '桃源县', 224),
(2242, '石门县', 224),
(2243, '津市市', 224),
(2244, '市辖区', 225),
(2245, '永定区', 225),
(2246, '武陵源区', 225),
(2247, '慈利县', 225),
(2248, '桑植县', 225),
(2249, '市辖区', 226),
(2250, '资阳区', 226),
(2251, '赫山区', 226),
(2252, '南县', 226),
(2253, '桃江县', 226),
(2254, '安化县', 226),
(2255, '沅江市', 226),
(2256, '市辖区', 227),
(2257, '北湖区', 227),
(2258, '苏仙区', 227),
(2259, '桂阳县', 227),
(2260, '宜章县', 227),
(2261, '永兴县', 227),
(2262, '嘉禾县', 227),
(2263, '临武县', 227),
(2264, '汝城县', 227),
(2265, '桂东县', 227),
(2266, '安仁县', 227),
(2267, '资兴市', 227),
(2268, '市辖区', 228),
(2270, '冷水滩区', 228),
(2271, '祁阳县', 228),
(2272, '东安县', 228),
(2273, '双牌县', 228),
(2274, '道县', 228),
(2275, '江永县', 228),
(2276, '宁远县', 228),
(2277, '蓝山县', 228),
(2278, '新田县', 228),
(2279, '江华瑶族自治县', 228),
(2280, '市辖区', 229),
(2281, '鹤城区', 229),
(2282, '中方县', 229),
(2283, '沅陵县', 229),
(2284, '辰溪县', 229),
(2285, '溆浦县', 229),
(2286, '会同县', 229),
(2287, '麻阳苗族自治县', 229),
(2288, '新晃侗族自治县', 229),
(2289, '芷江侗族自治县', 229),
(2290, '靖州苗族侗族自治县', 229),
(2291, '通道侗族自治县', 229),
(2292, '洪江市', 229),
(2293, '市辖区', 230),
(2294, '娄星区', 230),
(2295, '双峰县', 230),
(2296, '新化县', 230),
(2297, '冷水江市', 230),
(2298, '涟源市', 230),
(2299, '吉首市', 231),
(2300, '泸溪县', 231),
(2301, '凤凰县', 231),
(2302, '花垣县', 231),
(2303, '保靖县', 231),
(2304, '古丈县', 231),
(2305, '永顺县', 231),
(2306, '龙山县', 231),
(2307, '市辖区', 232),
(2308, '南沙区', 232),
(2309, '荔湾区', 232),
(2310, '越秀区', 232),
(2311, '海珠区', 232),
(2312, '天河区', 232),
(2313, '萝岗区', 232),
(2314, '白云区', 232),
(2315, '黄埔区', 232),
(2316, '番禺区', 232),
(2317, '花都区', 232),
(2318, '增城市', 232),
(2319, '从化市', 232),
(2320, '市辖区', 233),
(2321, '武江区', 233),
(2322, '浈江区', 233),
(2323, '曲江区', 233),
(2324, '始兴县', 233),
(2325, '仁化县', 233),
(2326, '翁源县', 233),
(2327, '乳源瑶族自治县', 233),
(2328, '新丰县', 233),
(2329, '乐昌市', 233),
(2330, '南雄市', 233),
(2331, '市辖区', 234),
(2332, '罗湖区', 234),
(2333, '福田区', 234),
(2334, '南山区', 234),
(2335, '宝安区', 234),
(2336, '龙岗区', 234),
(2337, '盐田区', 234),
(2338, '市辖区', 235),
(2339, '香洲区', 235),
(2340, '斗门区', 235),
(2341, '金湾区', 235),
(2342, '市辖区', 236),
(2343, '龙湖区', 236),
(2344, '金平区', 236),
(2345, '濠江区', 236),
(2346, '潮阳区', 236),
(2347, '潮南区', 236),
(2348, '澄海区', 236),
(2349, '南澳县', 236),
(2350, '市辖区', 237),
(2351, '禅城区', 237),
(2352, '南海区', 237),
(2353, '顺德区', 237),
(2354, '三水区', 237),
(2355, '高明区', 237),
(2356, '市辖区', 238),
(2357, '蓬江区', 238),
(2358, '江海区', 238),
(2359, '新会区', 238),
(2360, '台山市', 238),
(2361, '开平市', 238),
(2362, '鹤山市', 238),
(2363, '恩平市', 238),
(2364, '市辖区', 239),
(2365, '赤坎区', 239),
(2366, '霞山区', 239),
(2367, '坡头区', 239),
(2368, '麻章区', 239),
(2369, '遂溪县', 239),
(2370, '徐闻县', 239),
(2371, '廉江市', 239),
(2372, '雷州市', 239),
(2373, '吴川市', 239),
(2374, '市辖区', 240),
(2375, '茂南区', 240),
(2376, '茂港区', 240),
(2377, '电白县', 240),
(2378, '高州市', 240),
(2379, '化州市', 240),
(2380, '信宜市', 240),
(2381, '市辖区', 241),
(2382, '端州区', 241),
(2383, '鼎湖区', 241),
(2384, '广宁县', 241),
(2385, '怀集县', 241),
(2386, '封开县', 241),
(2387, '德庆县', 241),
(2388, '高要市', 241),
(2389, '四会市', 241),
(2390, '市辖区', 242),
(2391, '惠城区', 242),
(2392, '惠阳区', 242),
(2393, '博罗县', 242),
(2394, '惠东县', 242),
(2395, '龙门县', 242),
(2396, '市辖区', 243),
(2397, '梅江区', 243),
(2398, '梅县', 243),
(2399, '大埔县', 243),
(2400, '丰顺县', 243),
(2401, '五华县', 243),
(2402, '平远县', 243),
(2403, '蕉岭县', 243),
(2404, '兴宁市', 243),
(2405, '市辖区', 244),
(2406, '城区', 244),
(2407, '海丰县', 244),
(2408, '陆河县', 244),
(2409, '陆丰市', 244),
(2410, '市辖区', 245),
(2411, '源城区', 245),
(2412, '紫金县', 245),
(2413, '龙川县', 245),
(2414, '连平县', 245),
(2415, '和平县', 245),
(2416, '东源县', 245),
(2417, '市辖区', 246),
(2418, '江城区', 246),
(2419, '阳西县', 246),
(2420, '阳东县', 246),
(2421, '阳春市', 246),
(2422, '市辖区', 247),
(2423, '清城区', 247),
(2424, '佛冈县', 247),
(2425, '阳山县', 247),
(2426, '连山壮族瑶族自治县', 247),
(2427, '连南瑶族自治县', 247),
(2428, '清新县', 247),
(2429, '英德市', 247),
(2430, '连州市', 247),
(2431, '市辖区', 250),
(2432, '湘桥区', 250),
(2433, '潮安县', 250),
(2434, '饶平县', 250),
(2435, '市辖区', 251),
(2436, '榕城区', 251),
(2437, '揭东县', 251),
(2438, '揭西县', 251),
(2439, '惠来县', 251),
(2440, '普宁市', 251),
(2441, '市辖区', 252),
(2442, '云城区', 252),
(2443, '新兴县', 252),
(2444, '郁南县', 252),
(2445, '云安县', 252),
(2446, '罗定市', 252),
(2447, '市辖区', 253),
(2448, '兴宁区', 253),
(2449, '青秀区', 253),
(2450, '江南区', 253),
(2451, '西乡塘区', 253),
(2452, '良庆区', 253),
(2453, '邕宁区', 253),
(2454, '武鸣县', 253),
(2455, '隆安县', 253),
(2456, '马山县', 253),
(2457, '上林县', 253),
(2458, '宾阳县', 253),
(2459, '横县', 253),
(2460, '市辖区', 254),
(2461, '城中区', 254),
(2462, '鱼峰区', 254),
(2463, '柳南区', 254),
(2464, '柳北区', 254),
(2465, '柳江县', 254),
(2466, '柳城县', 254),
(2467, '鹿寨县', 254),
(2468, '融安县', 254),
(2469, '融水苗族自治县', 254),
(2470, '三江侗族自治县', 254),
(2471, '市辖区', 255),
(2472, '秀峰区', 255),
(2473, '叠彩区', 255),
(2474, '象山区', 255),
(2475, '七星区', 255),
(2476, '雁山区', 255),
(2477, '阳朔县', 255),
(2478, '临桂县', 255),
(2479, '灵川县', 255),
(2480, '全州县', 255),
(2481, '兴安县', 255),
(2482, '永福县', 255),
(2483, '灌阳县', 255),
(2484, '龙胜各族自治县', 255),
(2485, '资源县', 255),
(2486, '平乐县', 255),
(2487, '荔蒲县', 255),
(2488, '恭城瑶族自治县', 255),
(2489, '市辖区', 256),
(2490, '万秀区', 256),
(2491, '蝶山区', 256),
(2492, '长洲区', 256),
(2493, '苍梧县', 256),
(2494, '藤县', 256),
(2495, '蒙山县', 256),
(2496, '岑溪市', 256),
(2497, '市辖区', 257),
(2498, '海城区', 257),
(2499, '银海区', 257),
(2500, '铁山港区', 257),
(2501, '合浦县', 257),
(2502, '市辖区', 258),
(2503, '港口区', 258),
(2504, '防城区', 258),
(2505, '上思县', 258),
(2506, '东兴市', 258),
(2507, '市辖区', 259),
(2508, '钦南区', 259),
(2509, '钦北区', 259),
(2510, '灵山县', 259),
(2511, '浦北县', 259),
(2512, '市辖区', 260),
(2513, '港北区', 260),
(2514, '港南区', 260),
(2515, '覃塘区', 260),
(2516, '平南县', 260),
(2517, '桂平市', 260),
(2518, '市辖区', 261),
(2519, '玉州区', 261),
(2520, '容县', 261),
(2521, '陆川县', 261),
(2522, '博白县', 261),
(2523, '兴业县', 261),
(2524, '北流市', 261),
(2525, '市辖区', 262),
(2526, '右江区', 262),
(2527, '田阳县', 262),
(2528, '田东县', 262),
(2529, '平果县', 262),
(2530, '德保县', 262),
(2531, '靖西县', 262),
(2532, '那坡县', 262),
(2533, '凌云县', 262),
(2534, '乐业县', 262),
(2535, '田林县', 262),
(2536, '西林县', 262),
(2537, '隆林各族自治县', 262),
(2538, '市辖区', 263),
(2539, '八步区', 263),
(2540, '昭平县', 263),
(2541, '钟山县', 263),
(2542, '富川瑶族自治县', 263),
(2543, '市辖区', 264),
(2544, '金城江区', 264),
(2545, '南丹县', 264),
(2546, '天峨县', 264),
(2547, '凤山县', 264),
(2548, '东兰县', 264),
(2549, '罗城仫佬族自治县', 264),
(2550, '环江毛南族自治县', 264),
(2551, '巴马瑶族自治县', 264),
(2552, '都安瑶族自治县', 264),
(2553, '大化瑶族自治县', 264),
(2554, '宜州市', 264),
(2555, '市辖区', 265),
(2556, '兴宾区', 265),
(2557, '忻城县', 265),
(2558, '象州县', 265),
(2559, '武宣县', 265),
(2560, '金秀瑶族自治县', 265),
(2561, '合山市', 265),
(2562, '市辖区', 266),
(2563, '江洲区', 266),
(2564, '扶绥县', 266),
(2565, '宁明县', 266),
(2566, '龙州县', 266),
(2567, '大新县', 266),
(2568, '天等县', 266),
(2569, '凭祥市', 266),
(2570, '市辖区', 267),
(2571, '秀英区', 267),
(2572, '龙华区', 267),
(2573, '琼山区', 267),
(2574, '美兰区', 267),
(2575, '市辖区', 268),
(2576, '五指山市', 269),
(2577, '琼海市', 269),
(2578, '儋州市', 269),
(2579, '文昌市', 269),
(2580, '万宁市', 269),
(2581, '东方市', 269),
(2582, '定安县', 269),
(2583, '屯昌县', 269),
(2584, '澄迈县', 269),
(2585, '临高县', 269),
(2586, '白沙黎族自治县', 269),
(2587, '昌江黎族自治县', 269),
(2588, '乐东黎族自治县', 269),
(2589, '陵水黎族自治县', 269),
(2590, '保亭黎族苗族自治县', 269),
(2591, '琼中黎族苗族自治县', 269),
(2592, '西沙群岛', 269),
(2593, '南沙群岛', 269),
(2594, '中沙群岛的岛礁及其海域', 269),
(2595, '万州区', 270),
(2596, '涪陵区', 270),
(2597, '渝中区', 270),
(2598, '大渡口区', 270),
(2599, '江北区', 270),
(2600, '沙坪坝区', 270),
(2601, '九龙坡区', 270),
(2602, '南岸区', 270),
(2603, '北碚区', 270),
(2604, '万盛区', 270),
(2605, '双桥区', 270),
(2606, '渝北区', 270),
(2607, '巴南区', 270),
(2608, '黔江区', 270),
(2609, '长寿区', 270),
(2610, '綦江县', 271),
(2611, '潼南县', 271),
(2612, '铜梁县', 271),
(2613, '大足县', 271),
(2614, '荣昌县', 271),
(2615, '璧山县', 271),
(2616, '梁平县', 271),
(2617, '城口县', 271),
(2618, '丰都县', 271),
(2619, '垫江县', 271),
(2620, '武隆县', 271),
(2621, '忠县', 271),
(2622, '开县', 271),
(2623, '云阳县', 271),
(2624, '奉节县', 271),
(2625, '巫山县', 271),
(2626, '巫溪县', 271),
(2627, '石柱土家族自治县', 271),
(2628, '秀山土家族苗族自治县', 271),
(2629, '酉阳土家族苗族自治县', 271),
(2630, '彭水苗族土家族自治县', 271),
(2631, '江津区', 272),
(2632, '合川区', 272),
(2633, '永川区', 272),
(2634, '南川区', 272),
(2635, '市辖区', 273),
(2636, '锦江区', 273),
(2637, '青羊区', 273),
(2638, '金牛区', 273),
(2639, '武侯区', 273),
(2640, '成华区', 273),
(2641, '龙泉驿区', 273),
(2642, '青白江区', 273),
(2643, '新都区', 273),
(2644, '温江区', 273),
(2645, '金堂县', 273),
(2646, '双流县', 273),
(2647, '郫县', 273),
(2648, '大邑县', 273),
(2649, '蒲江县', 273),
(2650, '新津县', 273),
(2651, '都江堰市', 273),
(2652, '彭州市', 273),
(2653, '邛崃市', 273),
(2654, '崇州市', 273),
(2655, '市辖区', 274),
(2656, '自流井区', 274),
(2657, '贡井区', 274),
(2658, '大安区', 274),
(2659, '沿滩区', 274),
(2660, '荣县', 274),
(2661, '富顺县', 274),
(2662, '市辖区', 275),
(2663, '东区', 275),
(2664, '西区', 275),
(2665, '仁和区', 275),
(2666, '米易县', 275),
(2667, '盐边县', 275),
(2668, '市辖区', 276),
(2669, '江阳区', 276),
(2670, '纳溪区', 276),
(2671, '龙马潭区', 276),
(2672, '泸县', 276),
(2673, '合江县', 276),
(2674, '叙永县', 276),
(2675, '古蔺县', 276),
(2676, '市辖区', 277),
(2677, '旌阳区', 277),
(2678, '中江县', 277),
(2679, '罗江县', 277),
(2680, '广汉市', 277),
(2681, '什邡市', 277),
(2682, '绵竹市', 277),
(2683, '市辖区', 278),
(2684, '涪城区', 278),
(2685, '游仙区', 278),
(2686, '三台县', 278),
(2687, '盐亭县', 278),
(2688, '安县', 278),
(2689, '梓潼县', 278),
(2690, '北川羌族自治县', 278),
(2691, '平武县', 278),
(2692, '江油市', 278),
(2693, '市辖区', 279),
(2694, '市中区', 279),
(2695, '元坝区', 279),
(2696, '朝天区', 279),
(2697, '旺苍县', 279),
(2698, '青川县', 279),
(2699, '剑阁县', 279),
(2700, '苍溪县', 279),
(2701, '市辖区', 280),
(2702, '船山区', 280),
(2703, '安居区', 280),
(2704, '蓬溪县', 280),
(2705, '射洪县', 280),
(2706, '大英县', 280),
(2707, '市辖区', 281),
(2708, '市中区', 281),
(2709, '东兴区', 281),
(2710, '威远县', 281),
(2711, '资中县', 281),
(2712, '隆昌县', 281),
(2713, '市辖区', 282),
(2714, '市中区', 282),
(2715, '沙湾区', 282),
(2716, '五通桥区', 282),
(2717, '金口河区', 282),
(2718, '犍为县', 282),
(2719, '井研县', 282),
(2720, '夹江县', 282),
(2721, '沐川县', 282),
(2722, '峨边彝族自治县', 282),
(2723, '马边彝族自治县', 282),
(2724, '峨眉山市', 282),
(2725, '市辖区', 283),
(2726, '顺庆区', 283),
(2727, '高坪区', 283),
(2728, '嘉陵区', 283),
(2729, '南部县', 283),
(2730, '营山县', 283),
(2731, '蓬安县', 283),
(2732, '仪陇县', 283),
(2733, '西充县', 283),
(2734, '阆中市', 283),
(2735, '市辖区', 284),
(2736, '东坡区', 284),
(2737, '仁寿县', 284),
(2738, '彭山县', 284),
(2739, '洪雅县', 284),
(2740, '丹棱县', 284),
(2741, '青神县', 284),
(2742, '市辖区', 285),
(2743, '翠屏区', 285),
(2744, '宜宾县', 285),
(2745, '南溪县', 285),
(2746, '江安县', 285),
(2747, '长宁县', 285),
(2748, '高县', 285),
(2749, '珙县', 285),
(2750, '筠连县', 285),
(2751, '兴文县', 285),
(2752, '屏山县', 285),
(2753, '市辖区', 286),
(2754, '广安区', 286),
(2755, '岳池县', 286),
(2756, '武胜县', 286),
(2757, '邻水县', 286),
(2759, '市辖区', 287),
(2760, '通川区', 287),
(2761, '达县', 287),
(2762, '宣汉县', 287),
(2763, '开江县', 287),
(2764, '大竹县', 287),
(2765, '渠县', 287),
(2766, '万源市', 287),
(2767, '市辖区', 288),
(2768, '雨城区', 288),
(2769, '名山县', 288),
(2770, '荥经县', 288),
(2771, '汉源县', 288),
(2772, '石棉县', 288),
(2773, '天全县', 288),
(2774, '芦山县', 288),
(2775, '宝兴县', 288),
(2776, '市辖区', 289),
(2777, '巴州区', 289),
(2778, '通江县', 289),
(2779, '南江县', 289),
(2780, '平昌县', 289),
(2781, '市辖区', 290),
(2782, '雁江区', 290),
(2783, '安岳县', 290),
(2784, '乐至县', 290),
(2785, '简阳市', 290),
(2786, '汶川县', 291),
(2787, '理县', 291),
(2788, '茂县', 291),
(2789, '松潘县', 291),
(2790, '九寨沟县', 291),
(2791, '金川县', 291),
(2792, '小金县', 291),
(2793, '黑水县', 291),
(2794, '马尔康县', 291),
(2795, '壤塘县', 291),
(2796, '阿坝县', 291),
(2797, '若尔盖县', 291),
(2798, '红原县', 291),
(2799, '康定县', 292),
(2800, '泸定县', 292),
(2801, '丹巴县', 292),
(2802, '九龙县', 292),
(2803, '雅江县', 292),
(2804, '道孚县', 292),
(2805, '炉霍县', 292),
(2806, '甘孜县', 292),
(2807, '新龙县', 292),
(2808, '德格县', 292),
(2809, '白玉县', 292),
(2810, '石渠县', 292),
(2811, '色达县', 292),
(2812, '理塘县', 292),
(2813, '巴塘县', 292),
(2814, '乡城县', 292),
(2815, '稻城县', 292),
(2816, '得荣县', 292),
(2817, '西昌市', 293),
(2818, '木里藏族自治县', 293),
(2819, '盐源县', 293),
(2820, '德昌县', 293),
(2821, '会理县', 293),
(2822, '会东县', 293),
(2823, '宁南县', 293),
(2824, '普格县', 293),
(2825, '布拖县', 293),
(2826, '金阳县', 293),
(2827, '昭觉县', 293),
(2828, '喜德县', 293),
(2829, '冕宁县', 293),
(2830, '越西县', 293),
(2831, '甘洛县', 293),
(2832, '美姑县', 293),
(2833, '雷波县', 293),
(2834, '市辖区', 294),
(2835, '南明区', 294),
(2836, '云岩区', 294),
(2837, '花溪区', 294),
(2838, '乌当区', 294),
(2839, '白云区', 294),
(2840, '小河区', 294),
(2841, '开阳县', 294),
(2842, '息烽县', 294),
(2843, '修文县', 294),
(2844, '清镇市', 294),
(2845, '钟山区', 295),
(2846, '六枝特区', 295),
(2847, '水城县', 295),
(2848, '盘县', 295),
(2849, '市辖区', 296),
(2850, '红花岗区', 296),
(2851, '汇川区', 296),
(2852, '遵义县', 296),
(2853, '桐梓县', 296),
(2854, '绥阳县', 296),
(2855, '正安县', 296),
(2856, '道真仡佬族苗族自治县', 296),
(2857, '务川仡佬族苗族自治县', 296),
(2858, '凤冈县', 296),
(2859, '湄潭县', 296),
(2860, '余庆县', 296),
(2861, '习水县', 296),
(2862, '赤水市', 296),
(2863, '仁怀市', 296),
(2864, '市辖区', 297),
(2865, '西秀区', 297),
(2866, '平坝县', 297),
(2867, '普定县', 297),
(2868, '镇宁布依族苗族自治县', 297),
(2869, '关岭布依族苗族自治县', 297),
(2870, '紫云苗族布依族自治县', 297),
(2871, '铜仁市', 298),
(2872, '江口县', 298),
(2873, '玉屏侗族自治县', 298),
(2874, '石阡县', 298);
INSERT INTO `bin_region` (`region_id`, `region_name`, `parent_id`) VALUES
(2875, '思南县', 298),
(2876, '印江土家族苗族自治县', 298),
(2877, '德江县', 298),
(2878, '沿河土家族自治县', 298),
(2879, '松桃苗族自治县', 298),
(2880, '万山特区', 298),
(2881, '兴义市', 299),
(2882, '兴仁县', 299),
(2883, '普安县', 299),
(2884, '晴隆县', 299),
(2885, '贞丰县', 299),
(2886, '望谟县', 299),
(2887, '册亨县', 299),
(2888, '安龙县', 299),
(2889, '毕节市', 300),
(2890, '大方县', 300),
(2891, '黔西县', 300),
(2892, '金沙县', 300),
(2893, '织金县', 300),
(2894, '纳雍县', 300),
(2895, '威宁彝族回族苗族自治县', 300),
(2896, '赫章县', 300),
(2897, '凯里市', 301),
(2898, '黄平县', 301),
(2899, '施秉县', 301),
(2900, '三穗县', 301),
(2901, '镇远县', 301),
(2902, '岑巩县', 301),
(2903, '天柱县', 301),
(2904, '锦屏县', 301),
(2905, '剑河县', 301),
(2906, '台江县', 301),
(2907, '黎平县', 301),
(2908, '榕江县', 301),
(2909, '从江县', 301),
(2910, '雷山县', 301),
(2911, '麻江县', 301),
(2912, '丹寨县', 301),
(2913, '都匀市', 302),
(2914, '福泉市', 302),
(2915, '荔波县', 302),
(2916, '贵定县', 302),
(2917, '瓮安县', 302),
(2918, '独山县', 302),
(2919, '平塘县', 302),
(2920, '罗甸县', 302),
(2921, '长顺县', 302),
(2922, '龙里县', 302),
(2923, '惠水县', 302),
(2924, '三都水族自治县', 302),
(2925, '市辖区', 303),
(2926, '五华区', 303),
(2927, '盘龙区', 303),
(2928, '官渡区', 303),
(2929, '西山区', 303),
(2930, '东川区', 303),
(2931, '呈贡县', 303),
(2932, '晋宁县', 303),
(2933, '富民县', 303),
(2934, '宜良县', 303),
(2935, '石林彝族自治县', 303),
(2936, '嵩明县', 303),
(2937, '禄劝彝族苗族自治县', 303),
(2938, '寻甸回族彝族自治县', 303),
(2939, '安宁市', 303),
(2940, '市辖区', 304),
(2941, '麒麟区', 304),
(2942, '马龙县', 304),
(2943, '陆良县', 304),
(2944, '师宗县', 304),
(2945, '罗平县', 304),
(2946, '富源县', 304),
(2947, '会泽县', 304),
(2948, '沾益县', 304),
(2949, '宣威市', 304),
(2950, '市辖区', 305),
(2951, '红塔区', 305),
(2952, '江川县', 305),
(2953, '澄江县', 305),
(2954, '通海县', 305),
(2955, '华宁县', 305),
(2956, '易门县', 305),
(2957, '峨山彝族自治县', 305),
(2958, '新平彝族傣族自治县', 305),
(2959, '元江哈尼族彝族傣族自治县', 305),
(2960, '市辖区', 306),
(2961, '隆阳区', 306),
(2962, '施甸县', 306),
(2963, '腾冲县', 306),
(2964, '龙陵县', 306),
(2965, '昌宁县', 306),
(2966, '市辖区', 307),
(2967, '昭阳区', 307),
(2968, '鲁甸县', 307),
(2969, '巧家县', 307),
(2970, '盐津县', 307),
(2971, '大关县', 307),
(2972, '永善县', 307),
(2973, '绥江县', 307),
(2974, '镇雄县', 307),
(2975, '彝良县', 307),
(2976, '威信县', 307),
(2977, '水富县', 307),
(2978, '市辖区', 308),
(2979, '古城区', 308),
(2980, '玉龙纳西族自治县', 308),
(2981, '永胜县', 308),
(2982, '华坪县', 308),
(2983, '宁蒗彝族自治县', 308),
(2984, '市辖区', 309),
(2985, '思茅区', 309),
(2986, '宁洱哈尼族彝族自治县', 309),
(2987, '墨江哈尼族自治县', 309),
(2988, '景东彝族自治县', 309),
(2989, '景谷傣族彝族自治县', 309),
(2990, '镇沅彝族哈尼族拉祜族自治县', 309),
(2991, '江城哈尼族彝族自治县', 309),
(2992, '孟连傣族拉祜族佤族自治县', 309),
(2993, '澜沧拉祜族自治县', 309),
(2994, '西盟佤族自治县', 309),
(2995, '市辖区', 310),
(2996, '临翔区', 310),
(2997, '凤庆县', 310),
(2998, '云县', 310),
(2999, '永德县', 310),
(3000, '镇康县', 310),
(3001, '双江拉祜族佤族布朗族傣族自治县', 310),
(3002, '耿马傣族佤族自治县', 310),
(3003, '沧源佤族自治县', 310),
(3004, '楚雄市', 311),
(3005, '双柏县', 311),
(3006, '牟定县', 311),
(3007, '南华县', 311),
(3008, '姚安县', 311),
(3009, '大姚县', 311),
(3010, '永仁县', 311),
(3011, '元谋县', 311),
(3012, '武定县', 311),
(3013, '禄丰县', 311),
(3014, '个旧市', 312),
(3015, '开远市', 312),
(3016, '蒙自市', 312),
(3017, '屏边苗族自治县', 312),
(3018, '建水县', 312),
(3019, '石屏县', 312),
(3020, '弥勒县', 312),
(3021, '泸西县', 312),
(3022, '元阳县', 312),
(3023, '红河县', 312),
(3024, '金平苗族瑶族傣族自治县', 312),
(3025, '绿春县', 312),
(3026, '河口瑶族自治县', 312),
(3027, '文山县', 313),
(3028, '砚山县', 313),
(3029, '西畴县', 313),
(3030, '麻栗坡县', 313),
(3031, '马关县', 313),
(3032, '丘北县', 313),
(3033, '广南县', 313),
(3034, '富宁县', 313),
(3035, '景洪市', 314),
(3036, '勐海县', 314),
(3037, '勐腊县', 314),
(3038, '大理市', 315),
(3039, '漾濞彝族自治县', 315),
(3040, '祥云县', 315),
(3041, '宾川县', 315),
(3042, '弥渡县', 315),
(3043, '南涧彝族自治县', 315),
(3044, '巍山彝族回族自治县', 315),
(3045, '永平县', 315),
(3046, '云龙县', 315),
(3047, '洱源县', 315),
(3048, '剑川县', 315),
(3049, '鹤庆县', 315),
(3050, '瑞丽市', 316),
(3051, '芒市', 316),
(3052, '梁河县', 316),
(3053, '盈江县', 316),
(3054, '陇川县', 316),
(3055, '泸水县', 317),
(3056, '福贡县', 317),
(3057, '贡山独龙族怒族自治县', 317),
(3058, '兰坪白族普米族自治县', 317),
(3059, '香格里拉县', 318),
(3060, '德钦县', 318),
(3061, '维西傈僳族自治县', 318),
(3062, '市辖区', 319),
(3063, '城关区', 319),
(3064, '林周县', 319),
(3065, '当雄县', 319),
(3066, '尼木县', 319),
(3067, '曲水县', 319),
(3068, '堆龙德庆县', 319),
(3069, '达孜县', 319),
(3070, '墨竹工卡县', 319),
(3071, '昌都县', 320),
(3072, '江达县', 320),
(3073, '贡觉县', 320),
(3074, '类乌齐县', 320),
(3075, '丁青县', 320),
(3076, '察雅县', 320),
(3077, '八宿县', 320),
(3078, '左贡县', 320),
(3079, '芒康县', 320),
(3080, '洛隆县', 320),
(3081, '边坝县', 320),
(3082, '乃东县', 321),
(3083, '扎囊县', 321),
(3084, '贡嘎县', 321),
(3085, '桑日县', 321),
(3086, '琼结县', 321),
(3087, '曲松县', 321),
(3088, '措美县', 321),
(3089, '洛扎县', 321),
(3090, '加查县', 321),
(3091, '隆子县', 321),
(3092, '错那县', 321),
(3093, '浪卡子县', 321),
(3094, '日喀则市', 322),
(3095, '南木林县', 322),
(3096, '江孜县', 322),
(3097, '定日县', 322),
(3098, '萨迦县', 322),
(3099, '拉孜县', 322),
(3100, '昂仁县', 322),
(3101, '谢通门县', 322),
(3102, '白朗县', 322),
(3103, '仁布县', 322),
(3104, '康马县', 322),
(3105, '定结县', 322),
(3106, '仲巴县', 322),
(3107, '亚东县', 322),
(3108, '吉隆县', 322),
(3109, '聂拉木县', 322),
(3110, '萨嘎县', 322),
(3111, '岗巴县', 322),
(3112, '那曲县', 323),
(3113, '嘉黎县', 323),
(3114, '比如县', 323),
(3115, '聂荣县', 323),
(3116, '安多县', 323),
(3117, '申扎县', 323),
(3118, '索县', 323),
(3119, '班戈县', 323),
(3120, '巴青县', 323),
(3121, '尼玛县', 323),
(3122, '普兰县', 324),
(3123, '札达县', 324),
(3124, '噶尔县', 324),
(3125, '日土县', 324),
(3126, '革吉县', 324),
(3127, '改则县', 324),
(3128, '措勤县', 324),
(3129, '林芝县', 325),
(3130, '工布江达县', 325),
(3131, '米林县', 325),
(3132, '墨脱县', 325),
(3133, '波密县', 325),
(3134, '察隅县', 325),
(3135, '朗县', 325),
(3136, '市辖区', 326),
(3137, '新城区', 326),
(3138, '碑林区', 326),
(3139, '莲湖区', 326),
(3140, '灞桥区', 326),
(3141, '未央区', 326),
(3142, '雁塔区', 326),
(3143, '阎良区', 326),
(3144, '临潼区', 326),
(3145, '长安区', 326),
(3146, '蓝田县', 326),
(3147, '周至县', 326),
(3148, '户县', 326),
(3149, '高陵县', 326),
(3150, '市辖区', 327),
(3151, '王益区', 327),
(3152, '印台区', 327),
(3153, '耀州区', 327),
(3154, '宜君县', 327),
(3155, '市辖区', 328),
(3156, '渭滨区', 328),
(3157, '金台区', 328),
(3158, '陈仓区', 328),
(3159, '凤翔县', 328),
(3160, '岐山县', 328),
(3161, '扶风县', 328),
(3162, '眉县', 328),
(3163, '陇县', 328),
(3164, '千阳县', 328),
(3165, '麟游县', 328),
(3166, '凤县', 328),
(3167, '太白县', 328),
(3168, '市辖区', 329),
(3169, '秦都区', 329),
(3170, '杨陵区', 329),
(3171, '渭城区', 329),
(3172, '三原县', 329),
(3173, '泾阳县', 329),
(3174, '乾县', 329),
(3175, '礼泉县', 329),
(3176, '永寿县', 329),
(3177, '彬县', 329),
(3178, '长武县', 329),
(3179, '旬邑县', 329),
(3180, '淳化县', 329),
(3181, '武功县', 329),
(3182, '兴平市', 329),
(3183, '市辖区', 330),
(3184, '临渭区', 330),
(3185, '华县', 330),
(3186, '潼关县', 330),
(3187, '大荔县', 330),
(3188, '合阳县', 330),
(3189, '澄城县', 330),
(3190, '蒲城县', 330),
(3191, '白水县', 330),
(3192, '富平县', 330),
(3193, '韩城市', 330),
(3194, '华阴市', 330),
(3195, '市辖区', 331),
(3196, '宝塔区', 331),
(3197, '延长县', 331),
(3198, '延川县', 331),
(3199, '子长县', 331),
(3200, '安塞县', 331),
(3201, '志丹县', 331),
(3202, '吴起县', 331),
(3203, '甘泉县', 331),
(3204, '富县', 331),
(3205, '洛川县', 331),
(3206, '宜川县', 331),
(3207, '黄龙县', 331),
(3208, '黄陵县', 331),
(3209, '市辖区', 332),
(3210, '汉台区', 332),
(3211, '南郑县', 332),
(3212, '城固县', 332),
(3213, '洋县', 332),
(3214, '西乡县', 332),
(3215, '勉县', 332),
(3216, '宁强县', 332),
(3217, '略阳县', 332),
(3218, '镇巴县', 332),
(3219, '留坝县', 332),
(3220, '佛坪县', 332),
(3221, '市辖区', 333),
(3222, '榆阳区', 333),
(3223, '神木县', 333),
(3224, '府谷县', 333),
(3225, '横山县', 333),
(3226, '靖边县', 333),
(3227, '定边县', 333),
(3228, '绥德县', 333),
(3229, '米脂县', 333),
(3230, '佳县', 333),
(3231, '吴堡县', 333),
(3232, '清涧县', 333),
(3233, '子洲县', 333),
(3234, '市辖区', 334),
(3235, '汉滨区', 334),
(3236, '汉阴县', 334),
(3237, '石泉县', 334),
(3238, '宁陕县', 334),
(3239, '紫阳县', 334),
(3240, '岚皋县', 334),
(3241, '平利县', 334),
(3242, '镇坪县', 334),
(3243, '旬阳县', 334),
(3244, '白河县', 334),
(3245, '市辖区', 335),
(3246, '商州区', 335),
(3247, '洛南县', 335),
(3248, '丹凤县', 335),
(3249, '商南县', 335),
(3250, '山阳县', 335),
(3251, '镇安县', 335),
(3252, '柞水县', 335),
(3253, '市辖区', 336),
(3254, '城关区', 336),
(3255, '七里河区', 336),
(3256, '西固区', 336),
(3257, '安宁区', 336),
(3258, '红古区', 336),
(3259, '永登县', 336),
(3260, '皋兰县', 336),
(3261, '榆中县', 336),
(3262, '市辖区', 337),
(3263, '市辖区', 338),
(3264, '金川区', 338),
(3265, '永昌县', 338),
(3266, '市辖区', 339),
(3267, '白银区', 339),
(3268, '平川区', 339),
(3269, '靖远县', 339),
(3270, '会宁县', 339),
(3271, '景泰县', 339),
(3272, '市辖区', 340),
(3274, '秦州区', 340),
(3275, '清水县', 340),
(3276, '秦安县', 340),
(3277, '甘谷县', 340),
(3278, '武山县', 340),
(3279, '张家川回族自治县', 340),
(3280, '市辖区', 341),
(3281, '凉州区', 341),
(3282, '民勤县', 341),
(3283, '古浪县', 341),
(3284, '天祝藏族自治县', 341),
(3285, '市辖区', 342),
(3286, '甘州区', 342),
(3287, '肃南裕固族自治县', 342),
(3288, '民乐县', 342),
(3289, '临泽县', 342),
(3290, '高台县', 342),
(3291, '山丹县', 342),
(3292, '市辖区', 343),
(3293, '崆峒区', 343),
(3294, '泾川县', 343),
(3295, '灵台县', 343),
(3296, '崇信县', 343),
(3297, '华亭县', 343),
(3298, '庄浪县', 343),
(3299, '静宁县', 343),
(3300, '市辖区', 344),
(3301, '肃州区', 344),
(3302, '金塔县', 344),
(3304, '肃北蒙古族自治县', 344),
(3305, '阿克塞哈萨克族自治县', 344),
(3306, '玉门市', 344),
(3307, '敦煌市', 344),
(3308, '市辖区', 345),
(3309, '西峰区', 345),
(3310, '庆城县', 345),
(3311, '环县', 345),
(3312, '华池县', 345),
(3313, '合水县', 345),
(3314, '正宁县', 345),
(3315, '宁县', 345),
(3316, '镇原县', 345),
(3317, '市辖区', 346),
(3318, '安定区', 346),
(3319, '通渭县', 346),
(3320, '陇西县', 346),
(3321, '渭源县', 346),
(3322, '临洮县', 346),
(3323, '漳县', 346),
(3324, '岷县', 346),
(3325, '市辖区', 347),
(3326, '武都区', 347),
(3327, '成县', 347),
(3328, '文县', 347),
(3329, '宕昌县', 347),
(3330, '康县', 347),
(3331, '西和县', 347),
(3332, '礼县', 347),
(3333, '徽县', 347),
(3334, '两当县', 347),
(3335, '临夏市', 348),
(3336, '临夏县', 348),
(3337, '康乐县', 348),
(3338, '永靖县', 348),
(3339, '广河县', 348),
(3340, '和政县', 348),
(3341, '东乡族自治县', 348),
(3342, '积石山保安族东乡族撒拉族自治县', 348),
(3343, '合作市', 349),
(3344, '临潭县', 349),
(3345, '卓尼县', 349),
(3346, '舟曲县', 349),
(3347, '迭部县', 349),
(3348, '玛曲县', 349),
(3349, '碌曲县', 349),
(3350, '夏河县', 349),
(3351, '市辖区', 350),
(3352, '城东区', 350),
(3353, '城中区', 350),
(3354, '城西区', 350),
(3355, '城北区', 350),
(3356, '大通回族土族自治县', 350),
(3357, '湟中县', 350),
(3358, '湟源县', 350),
(3359, '平安县', 351),
(3360, '民和回族土族自治县', 351),
(3361, '乐都县', 351),
(3362, '互助土族自治县', 351),
(3363, '化隆回族自治县', 351),
(3364, '循化撒拉族自治县', 351),
(3365, '门源回族自治县', 352),
(3366, '祁连县', 352),
(3367, '海晏县', 352),
(3368, '刚察县', 352),
(3369, '同仁县', 353),
(3370, '尖扎县', 353),
(3371, '泽库县', 353),
(3372, '河南蒙古族自治县', 353),
(3373, '共和县', 354),
(3374, '同德县', 354),
(3375, '贵德县', 354),
(3376, '兴海县', 354),
(3377, '贵南县', 354),
(3378, '玛沁县', 355),
(3379, '班玛县', 355),
(3380, '甘德县', 355),
(3381, '达日县', 355),
(3382, '久治县', 355),
(3383, '玛多县', 355),
(3384, '玉树县', 356),
(3385, '杂多县', 356),
(3386, '称多县', 356),
(3387, '治多县', 356),
(3388, '囊谦县', 356),
(3389, '曲麻莱县', 356),
(3390, '格尔木市', 357),
(3391, '德令哈市', 357),
(3392, '乌兰县', 357),
(3393, '都兰县', 357),
(3394, '天峻县', 357),
(3395, '市辖区', 358),
(3396, '兴庆区', 358),
(3397, '西夏区', 358),
(3398, '金凤区', 358),
(3399, '永宁县', 358),
(3400, '贺兰县', 358),
(3401, '灵武市', 358),
(3402, '市辖区', 359),
(3403, '大武口区', 359),
(3404, '惠农区', 359),
(3405, '平罗县', 359),
(3406, '市辖区', 360),
(3407, '利通区', 360),
(3408, '盐池县', 360),
(3409, '同心县', 360),
(3410, '青铜峡市', 360),
(3411, '市辖区', 361),
(3412, '原州区', 361),
(3413, '西吉县', 361),
(3414, '隆德县', 361),
(3415, '泾源县', 361),
(3416, '彭阳县', 361),
(3417, '市辖区', 362),
(3418, '沙坡头区', 362),
(3419, '中宁县', 362),
(3420, '海原县', 362),
(3421, '市辖区', 363),
(3422, '天山区', 363),
(3423, '沙依巴克区', 363),
(3424, '新市区', 363),
(3425, '水磨沟区', 363),
(3426, '头屯河区', 363),
(3427, '达坂城区', 363),
(3428, '米东区', 363),
(3429, '乌鲁木齐县', 363),
(3430, '市辖区', 364),
(3431, '独山子区', 364),
(3432, '克拉玛依区', 364),
(3433, '白碱滩区', 364),
(3434, '乌尔禾区', 364),
(3435, '吐鲁番市', 365),
(3436, '鄯善县', 365),
(3437, '托克逊县', 365),
(3438, '哈密市', 366),
(3439, '巴里坤哈萨克自治县', 366),
(3440, '伊吾县', 366),
(3441, '昌吉市', 367),
(3442, '阜康市', 367),
(3444, '呼图壁县', 367),
(3445, '玛纳斯县', 367),
(3446, '奇台县', 367),
(3447, '吉木萨尔县', 367),
(3448, '木垒哈萨克自治县', 367),
(3449, '博乐市', 368),
(3450, '精河县', 368),
(3451, '温泉县', 368),
(3452, '库尔勒市', 369),
(3453, '轮台县', 369),
(3454, '尉犁县', 369),
(3455, '若羌县', 369),
(3456, '且末县', 369),
(3457, '焉耆回族自治县', 369),
(3458, '和静县', 369),
(3459, '和硕县', 369),
(3460, '博湖县', 369),
(3461, '阿克苏市', 370),
(3462, '温宿县', 370),
(3463, '库车县', 370),
(3464, '沙雅县', 370),
(3465, '新和县', 370),
(3466, '拜城县', 370),
(3467, '乌什县', 370),
(3468, '阿瓦提县', 370),
(3469, '柯坪县', 370),
(3470, '阿图什市', 371),
(3471, '阿克陶县', 371),
(3472, '阿合奇县', 371),
(3473, '乌恰县', 371),
(3474, '喀什市', 372),
(3475, '疏附县', 372),
(3476, '疏勒县', 372),
(3477, '英吉沙县', 372),
(3478, '泽普县', 372),
(3479, '莎车县', 372),
(3480, '叶城县', 372),
(3481, '麦盖提县', 372),
(3482, '岳普湖县', 372),
(3483, '伽师县', 372),
(3484, '巴楚县', 372),
(3485, '塔什库尔干塔吉克自治县', 372),
(3486, '和田市', 373),
(3487, '和田县', 373),
(3488, '墨玉县', 373),
(3489, '皮山县', 373),
(3490, '洛浦县', 373),
(3491, '策勒县', 373),
(3492, '于田县', 373),
(3493, '民丰县', 373),
(3494, '伊宁市', 374),
(3495, '奎屯市', 374),
(3496, '伊宁县', 374),
(3497, '察布查尔锡伯自治县', 374),
(3498, '霍城县', 374),
(3499, '巩留县', 374),
(3500, '新源县', 374),
(3501, '昭苏县', 374),
(3502, '特克斯县', 374),
(3503, '尼勒克县', 374),
(3504, '塔城市', 375),
(3505, '乌苏市', 375),
(3506, '额敏县', 375),
(3507, '沙湾县', 375),
(3508, '托里县', 375),
(3509, '裕民县', 375),
(3510, '和布克赛尔蒙古自治县', 375),
(3511, '阿勒泰市', 376),
(3512, '布尔津县', 376),
(3513, '富蕴县', 376),
(3514, '福海县', 376),
(3515, '哈巴河县', 376),
(3516, '青河县', 376),
(3517, '吉木乃县', 376),
(3518, '石河子市', 377),
(3519, '阿拉尔市', 377),
(3520, '图木舒克市', 377),
(3521, '五家渠市', 377),
(4000, '麦积区', 340),
(4001, '江津区', 270),
(4002, '合川区', 270),
(4003, '永川区', 270),
(4004, '南川区', 270),
(4006, '芜湖县', 1412),
(4100, '加格达奇区', 106),
(4101, '松岭区', 106),
(4102, '新林区', 106),
(4103, '呼中区', 106),
(4200, '南湖区', 125),
(4300, '共青城市', 162),
(4400, '红寺堡区', 360),
(4500, '瓜州县', 344),
(4600, '随县', 215),
(4700, '零陵区', 228),
(4800, '平桂管理区', 263),
(4900, '利州区', 279),
(5000, '华蓥市', 286);
-- --------------------------------------------------------
--
-- 表的结构 `bin_setting`
--
CREATE TABLE IF NOT EXISTS `bin_setting` (
`setting_id` int(10) unsigned NOT NULL,
`setting_title` varchar(32) NOT NULL DEFAULT '',
`setting_value` varchar(255) NOT NULL DEFAULT '',
`setting_key` varchar(32) NOT NULL DEFAULT '',
`type_id` int(10) unsigned NOT NULL DEFAULT '0',
`group_id` int(10) unsigned NOT NULL DEFAULT '0',
`option_list` varchar(255) NOT NULL DEFAULT '',
`sort_number` int(10) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_setting`
--
INSERT INTO `bin_setting` (`setting_id`, `setting_title`, `setting_value`, `setting_key`, `type_id`, `group_id`, `option_list`, `sort_number`) VALUES
(1, '商店名称', 'BuyPlus(败家)', 'shop_title', 1, 1, '', 0),
(2, '所在城市', '1', 'shop_city', 2, 1, '1-成都,2-广元,3-广安,4-达州', 0),
(3, '允许商品评论', '1', 'allow_comment', 3, 1, '0-不允许,1-允许', 0),
(4, '验证码页', '1,3', 'use_captcha', 4, 2, '1-注册,2-评论,3-退货,4-联系', 0),
(5, '联系地址', '四川省成都市高新西区天目路77号 成都光大网络科技有限公司', 'busines_address', 5, 1, '', 0),
(6, '后台商品展示数', '3', 'back_goods_list_pagesize', 1, 3, '', 0),
(7, '前台主页商品展示数', '4', 'Home_goods_list_number', 1, 4, '', 0),
(8, '前台商品图片宽度', '300', 'home_image_width', 1, 4, '', 0),
(9, '前台商品图片高度', '340', 'home_image_height', 1, 4, '', 0),
(10, 'SMTP服务器主机', 'smtp.163.com', 'mail_host', 1, 5, '', 0),
(11, 'SMTP邮箱名', 'hellozhou01', 'mail_user_name', 1, 5, '', 0),
(12, '发件人邮箱', 'hellozhou01@163.com', 'send_mail_name', 1, 5, '', 0),
(13, 'SMTP授权码', 'hellozhou01', 'smtp_password', 1, 5, '', 0),
(14, '发件人', 'BuyPlus_zhou', 'send_mail_user', 1, 5, '', 0),
(15, 'sms主账号', '8aaf07085bad886c015bc1b8857b0447', 'sms_account_id', 1, 6, '', 0),
(16, 'sms主账号令牌', '3c8fd2e0baa2462196bc321afae5ab29', 'sms_account_token', 1, 6, '', 0),
(17, '应用ID', '8aaf07085bad886c015bc1b8891d044d', 'sms_appId', 1, 6, '', 0),
(18, '生产环境地址', 'app.cloopen.com', 'sms_server_ip', 1, 6, '', 0),
(19, '生产环境端口', '8883', 'sms_server_port', 1, 6, '', 0),
(20, 'ytx版本号', '2013-12-26', 'soft_version', 1, 6, '', 0);
-- --------------------------------------------------------
--
-- 表的结构 `bin_setting_group`
--
CREATE TABLE IF NOT EXISTS `bin_setting_group` (
`setting_group_id` int(10) unsigned NOT NULL,
`group_title` varchar(32) NOT NULL DEFAULT '',
`group_key` varchar(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_setting_group`
--
INSERT INTO `bin_setting_group` (`setting_group_id`, `group_title`, `group_key`) VALUES
(1, '商店设置', 'shop_setting'),
(2, '安全配置', 'server_setting'),
(3, '后台设置', 'back_setting'),
(4, '前台设置', 'home_setting'),
(5, '邮件服务器配置', 'mail_setting'),
(6, '短信服务器配置', 'sms_setting');
-- --------------------------------------------------------
--
-- 表的结构 `bin_setting_type`
--
CREATE TABLE IF NOT EXISTS `bin_setting_type` (
`setting_type_id` int(10) unsigned NOT NULL,
`type_title` varchar(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_setting_type`
--
INSERT INTO `bin_setting_type` (`setting_type_id`, `type_title`) VALUES
(1, 'text'),
(2, 'select'),
(3, 'radio'),
(4, 'checkbox'),
(5, 'textarea');
-- --------------------------------------------------------
--
-- 表的结构 `bin_stock_status`
--
CREATE TABLE IF NOT EXISTS `bin_stock_status` (
`stock_status_id` int(11) NOT NULL,
`title` varchar(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_stock_status`
--
INSERT INTO `bin_stock_status` (`stock_status_id`, `title`) VALUES
(1, '库存充足'),
(2, '1-3周'),
(3, '1-3天'),
(4, '脱销'),
(5, '预定');
-- --------------------------------------------------------
--
-- 表的结构 `bin_tax`
--
CREATE TABLE IF NOT EXISTS `bin_tax` (
`tax_id` int(11) NOT NULL,
`value` varchar(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_tax`
--
INSERT INTO `bin_tax` (`tax_id`, `value`) VALUES
(1, '免税产品'),
(2, '缴税产品');
-- --------------------------------------------------------
--
-- 表的结构 `bin_user`
--
CREATE TABLE IF NOT EXISTS `bin_user` (
`user_id` int(10) unsigned NOT NULL,
`name` varchar(64) NOT NULL DEFAULT '',
`password` varchar(32) NOT NULL DEFAULT '',
`email` varchar(255) NOT NULL DEFAULT '',
`telephone` varchar(16) NOT NULL DEFAULT '',
`checked` tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_user`
--
INSERT INTO `bin_user` (`user_id`, `name`, `password`, `email`, `telephone`, `checked`) VALUES
(3, 'hellozhou', '2ca5227352fe4cb377515cf5f9447141', '', '17721679620', 1),
(11, 'zzz', '2ca5227352fe4cb377515cf5f9447141', '1412883587@qq.com', '', 1),
(12, 'zhou', '63a9f0ea7bb98050796b649e85481845', '569072412@qq.com', '', 1);
-- --------------------------------------------------------
--
-- 表的结构 `bin_user_address`
--
CREATE TABLE IF NOT EXISTS `bin_user_address` (
`user_address_id` int(10) unsigned NOT NULL,
`user_id` int(10) unsigned NOT NULL DEFAULT '0',
`default` tinyint(4) NOT NULL DEFAULT '0',
`name` varchar(64) NOT NULL DEFAULT '',
`telephone` varchar(16) NOT NULL DEFAULT '',
`privince_id` int(10) unsigned NOT NULL DEFAULT '0',
`city_id` int(10) unsigned NOT NULL DEFAULT '0',
`area_id` int(10) unsigned NOT NULL DEFAULT '0',
`address` varchar(255) NOT NULL DEFAULT '',
`postcode` varchar(16) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_user_address`
--
INSERT INTO `bin_user_address` (`user_address_id`, `user_id`, `default`, `name`, `telephone`, `privince_id`, `city_id`, `area_id`, `address`, `postcode`) VALUES
(1, 3, 0, 'zhou_one', '17721679620', 11, 113, 1232, '平望镇', '215225'),
(3, 3, 1, 'one_punch', '13423532432', 14, 268, 1235, '河里', '43253151');
-- --------------------------------------------------------
--
-- 表的结构 `bin_user_check`
--
CREATE TABLE IF NOT EXISTS `bin_user_check` (
`user_id` int(10) unsigned NOT NULL,
`check_code` varchar(16) NOT NULL DEFAULT '',
`check_time` int(11) NOT NULL DEFAULT '0',
`check_type` tinyint(4) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_user_check`
--
INSERT INTO `bin_user_check` (`user_id`, `check_code`, `check_time`, `check_type`) VALUES
(3, '11112', 1493732300, 2),
(11, '45335', 1499052430, 1),
(12, '72929', 1499093916, 1);
-- --------------------------------------------------------
--
-- 表的结构 `bin_weight_unit`
--
CREATE TABLE IF NOT EXISTS `bin_weight_unit` (
`weight_unit_id` int(11) NOT NULL,
`title` varchar(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `bin_weight_unit`
--
INSERT INTO `bin_weight_unit` (`weight_unit_id`, `title`) VALUES
(1, '克'),
(2, '千克'),
(3, '500克(斤)');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `bin_attribute`
--
ALTER TABLE `bin_attribute`
ADD PRIMARY KEY (`attribute_id`),
ADD KEY `goods_type_id` (`goods_type_id`),
ADD KEY `attribute_type_id` (`attribute_type_id`);
--
-- Indexes for table `bin_attribute_type`
--
ALTER TABLE `bin_attribute_type`
ADD PRIMARY KEY (`attribute_type_id`);
--
-- Indexes for table `bin_attribute_value`
--
ALTER TABLE `bin_attribute_value`
ADD PRIMARY KEY (`attribute_value_id`),
ADD KEY `attribute_id` (`attribute_id`);
--
-- Indexes for table `bin_brand`
--
ALTER TABLE `bin_brand`
ADD PRIMARY KEY (`brand_id`),
ADD UNIQUE KEY `title` (`title`);
--
-- Indexes for table `bin_cart`
--
ALTER TABLE `bin_cart`
ADD PRIMARY KEY (`cart_id`),
ADD KEY `user_id` (`user_id`);
--
-- Indexes for table `bin_cart_goods`
--
ALTER TABLE `bin_cart_goods`
ADD PRIMARY KEY (`cart_goods_id`),
ADD KEY `cart_id` (`cart_id`),
ADD KEY `goods_id` (`goods_id`),
ADD KEY `goods_attribute_value_id` (`goods_attribute_value_id`);
--
-- Indexes for table `bin_category`
--
ALTER TABLE `bin_category`
ADD PRIMARY KEY (`category_id`),
ADD KEY `parent_id` (`parent_id`),
ADD KEY `sort_number` (`sort_number`);
--
-- Indexes for table `bin_goods`
--
ALTER TABLE `bin_goods`
ADD PRIMARY KEY (`goods_id`),
ADD UNIQUE KEY `UPC` (`UPC`),
ADD KEY `sort_number` (`sort_number`),
ADD KEY `price` (`price`),
ADD KEY `name` (`name`),
ADD KEY `create_at` (`create_at`),
ADD KEY `brand_id` (`brand_id`),
ADD KEY `category_id` (`category_id`),
ADD KEY `tax_id` (`tax_id`),
ADD KEY `stock_status_id` (`stock_status_id`),
ADD KEY `length_unit_id` (`length_unit_id`),
ADD KEY `weight_unit_id` (`weight_unit_id`);
--
-- Indexes for table `bin_goods_attribute`
--
ALTER TABLE `bin_goods_attribute`
ADD PRIMARY KEY (`goods_attribute_id`),
ADD KEY `goods_id` (`goods_id`),
ADD KEY `attribute_id` (`attribute_id`);
--
-- Indexes for table `bin_goods_attribute_value`
--
ALTER TABLE `bin_goods_attribute_value`
ADD PRIMARY KEY (`goods_attribute_value_id`),
ADD KEY `goods_attribute_id` (`goods_attribute_id`),
ADD KEY `attribute_value_id` (`attribute_value_id`);
--
-- Indexes for table `bin_goods_image`
--
ALTER TABLE `bin_goods_image`
ADD PRIMARY KEY (`goods_image_id`),
ADD KEY `goods_id` (`goods_id`),
ADD KEY `sort_number` (`sort_number`);
--
-- Indexes for table `bin_goods_special`
--
ALTER TABLE `bin_goods_special`
ADD PRIMARY KEY (`goods_special_id`),
ADD KEY `goods_id` (`goods_id`);
--
-- Indexes for table `bin_goods_type`
--
ALTER TABLE `bin_goods_type`
ADD PRIMARY KEY (`goods_type_id`);
--
-- Indexes for table `bin_length_unit`
--
ALTER TABLE `bin_length_unit`
ADD PRIMARY KEY (`length_unit_id`);
--
-- Indexes for table `bin_order`
--
ALTER TABLE `bin_order`
ADD PRIMARY KEY (`order_id`);
--
-- Indexes for table `bin_order_goods`
--
ALTER TABLE `bin_order_goods`
ADD PRIMARY KEY (`order_goods_id`);
--
-- Indexes for table `bin_region`
--
ALTER TABLE `bin_region`
ADD PRIMARY KEY (`region_id`);
--
-- Indexes for table `bin_setting`
--
ALTER TABLE `bin_setting`
ADD PRIMARY KEY (`setting_id`),
ADD KEY `type` (`type_id`),
ADD KEY `group` (`group_id`),
ADD KEY `order` (`sort_number`);
--
-- Indexes for table `bin_setting_group`
--
ALTER TABLE `bin_setting_group`
ADD PRIMARY KEY (`setting_group_id`),
ADD UNIQUE KEY `uniquekey` (`group_key`);
--
-- Indexes for table `bin_setting_type`
--
ALTER TABLE `bin_setting_type`
ADD PRIMARY KEY (`setting_type_id`);
--
-- Indexes for table `bin_stock_status`
--
ALTER TABLE `bin_stock_status`
ADD PRIMARY KEY (`stock_status_id`);
--
-- Indexes for table `bin_tax`
--
ALTER TABLE `bin_tax`
ADD PRIMARY KEY (`tax_id`);
--
-- Indexes for table `bin_user`
--
ALTER TABLE `bin_user`
ADD PRIMARY KEY (`user_id`),
ADD UNIQUE KEY `name` (`name`);
--
-- Indexes for table `bin_user_address`
--
ALTER TABLE `bin_user_address`
ADD PRIMARY KEY (`user_address_id`),
ADD KEY `privince_id` (`privince_id`),
ADD KEY `city_id` (`city_id`),
ADD KEY `area_id` (`area_id`);
--
-- Indexes for table `bin_user_check`
--
ALTER TABLE `bin_user_check`
ADD PRIMARY KEY (`user_id`);
--
-- Indexes for table `bin_weight_unit`
--
ALTER TABLE `bin_weight_unit`
ADD PRIMARY KEY (`weight_unit_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `bin_attribute`
--
ALTER TABLE `bin_attribute`
MODIFY `attribute_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `bin_attribute_type`
--
ALTER TABLE `bin_attribute_type`
MODIFY `attribute_type_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `bin_attribute_value`
--
ALTER TABLE `bin_attribute_value`
MODIFY `attribute_value_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT for table `bin_brand`
--
ALTER TABLE `bin_brand`
MODIFY `brand_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `bin_cart`
--
ALTER TABLE `bin_cart`
MODIFY `cart_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `bin_cart_goods`
--
ALTER TABLE `bin_cart_goods`
MODIFY `cart_goods_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `bin_category`
--
ALTER TABLE `bin_category`
MODIFY `category_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=40;
--
-- AUTO_INCREMENT for table `bin_goods`
--
ALTER TABLE `bin_goods`
MODIFY `goods_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=27;
--
-- AUTO_INCREMENT for table `bin_goods_attribute`
--
ALTER TABLE `bin_goods_attribute`
MODIFY `goods_attribute_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=25;
--
-- AUTO_INCREMENT for table `bin_goods_attribute_value`
--
ALTER TABLE `bin_goods_attribute_value`
MODIFY `goods_attribute_value_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=40;
--
-- AUTO_INCREMENT for table `bin_goods_image`
--
ALTER TABLE `bin_goods_image`
MODIFY `goods_image_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=27;
--
-- AUTO_INCREMENT for table `bin_goods_special`
--
ALTER TABLE `bin_goods_special`
MODIFY `goods_special_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `bin_goods_type`
--
ALTER TABLE `bin_goods_type`
MODIFY `goods_type_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `bin_length_unit`
--
ALTER TABLE `bin_length_unit`
MODIFY `length_unit_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `bin_order`
--
ALTER TABLE `bin_order`
MODIFY `order_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `bin_order_goods`
--
ALTER TABLE `bin_order_goods`
MODIFY `order_goods_id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `bin_region`
--
ALTER TABLE `bin_region`
MODIFY `region_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5001;
--
-- AUTO_INCREMENT for table `bin_setting`
--
ALTER TABLE `bin_setting`
MODIFY `setting_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=21;
--
-- AUTO_INCREMENT for table `bin_setting_group`
--
ALTER TABLE `bin_setting_group`
MODIFY `setting_group_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `bin_setting_type`
--
ALTER TABLE `bin_setting_type`
MODIFY `setting_type_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `bin_stock_status`
--
ALTER TABLE `bin_stock_status`
MODIFY `stock_status_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `bin_tax`
--
ALTER TABLE `bin_tax`
MODIFY `tax_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `bin_user`
--
ALTER TABLE `bin_user`
MODIFY `user_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=13;
--
-- AUTO_INCREMENT for table `bin_user_address`
--
ALTER TABLE `bin_user_address`
MODIFY `user_address_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `bin_weight_unit`
--
ALTER TABLE `bin_weight_unit`
MODIFY `weight_unit_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4;
/*!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 */;
|
CREATE TABLE IF NOT EXISTS customers (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
customerFirstName VARCHAR(50) DEFAULT NULL,
customerLastName VARCHAR(50) DEFAULT NULL,
customerUsername VARCHAR(200) DEFAULT NULL,
customerPassword VARCHAR(200) DEFAULT NULL,
customerEmail NVARCHAR(50) DEFAULT NULL,
customerBirthDate DATE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS customerOrders
(customerOrderId INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
customerId INT UNSIGNED,
customerOrderDate DATE,
customerOrderQty SMALLINT,
FOREIGN KEY (customerId) REFERENCES customers(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS orderItems
(orderItemId INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
itemId INT UNSIGNED,
itemDesc VARCHAR(50),
itemPrice FLOAT,
itemSize SMALLINT,
FOREIGN KEY (itemId) REFERENCES customerOrders(customerOrderId) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
INSERT INTO customers (customerUsername, customerPassword)VALUES ("coffeecustomer", sha1("coffee"));
SELECT * FROM customers;
SELECT * FROM customerOrders;
SELECT * FROM customerOrders;
INSERT INTO customerOrders (customerOrderDate, customerOrderItem, customerCharge, customerReward) VALUES ("2020-10-08", "Cakepop", 4, 3);
INSERT INTO customers (customerFirstName, customerLastName, customerUsername, customerPassword, customerEmail, customerBirthDate) VALUES ("Nick", "Beck", "nick90", sha1("c0ff33"), "nick@aol.com", "1988-8-12")
|
CREATE TABLE "C##HOSPITAL3"."HISTORIAL"
( "RESCITA_ID" NUMBER(*,0) NOT NULL ENABLE,
"CITA_ID" NUMBER(*,0) NOT NULL ENABLE,
"DIAGNOSTICO" VARCHAR2(150 BYTE),
"COLUMN1" VARCHAR2(150 BYTE),
"MEDICINAS" VARCHAR2(150 BYTE),
"PASOSASEGUIR" VARCHAR2(150 BYTE),
"OBSERVACIONES" NVARCHAR2(150),
CONSTRAINT "HISTORIAL_PK" PRIMARY KEY ("RESCITA_ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" ENABLE
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" ;
|
/* Extracts patient demographic and admission information */
select
admissions.subject_id,
admissions.hadm_id,
admissions.admittime,
admissions.marital_status,
admissions.ethnicity,
admissions.diagnosis,
admissions.insurance,
admissions.religion,
admissions.admittime - patients.dob as age
from admissions
full outer join patients on admissions.subject_id = patients.subject_id; |
create table product_type
(
id bigint not null
constraint product_type_pkey
primary key,
base_price double precision not null,
description varchar(255) not null,
lessons_hours integer not null,
name varchar(50) not null,
product_category varchar(20) not null
);
create table student
(
id bigint not null
constraint student_pkey
primary key,
created_by bigint,
created_date timestamp default now(),
email varchar(50) not null,
first_name varchar(50) not null,
last_name varchar(50) not null,
phone_number integer not null
);
create table product
(
id bigint not null
constraint product_pkey
primary key,
book_online boolean,
hours_left integer not null,
is_paid boolean,
price double precision not null,
product_type_id bigint not null
constraint fk_product_type_id
references product_type,
student_id_id bigint not null
constraint fk_student_id
references student
);
create table user_app
(
id bigint not null
constraint user_app_pkey
primary key,
created_date timestamp default now(),
email varchar(50) not null
constraint user_email_unique
unique,
first_name varchar(50) not null,
last_name varchar(50) not null,
password varchar(120) not null,
phone_number integer not null,
username varchar(20) not null
constraint user_username_unique
unique
);
create table lesson
(
id bigint not null
constraint lesson_pkey
primary key,
date date,
time_end timestamp,
time_start timestamp,
instructor_id bigint not null
constraint fk_instructor_id
references user_app,
product_id bigint not null
constraint fk_product_id
references product
);
create table user_role
(
id serial not null
constraint user_role_pkey
primary key,
name varchar(20)
constraint user_role_unique
unique
);
create table user_roles_list
(
user_id bigint not null
constraint fk_user_id
references user_app,
role_id integer not null
constraint fk_role_id
references user_role,
constraint user_roles_list_pkey
primary key (user_id, role_id)
);
create table work_schedule
(
id bigint not null
constraint work_schedule_pkey
primary key,
date date,
time_end timestamp,
time_start timestamp,
instructor_id bigint not null
constraint fk_instructor_id
references user_app
);
INSERT INTO user_role(name)
VALUES ('ROLE_ADMIN');
INSERT INTO user_role(name)
VALUES ('ROLE_MODERATOR');
INSERT INTO user_role(name)
VALUES ('ROLE_STUDENT');
INSERT INTO user_role(name)
VALUES ('ROLE_INSTRUCTOR');
|
CREATE PROCEDURE test_procedure
AS
DROP PROCEDURE test_procedure |
alter table user_0 add column guide_pro smallint default 0;
alter table user_0 alter column pro set default 0;
|
create table users(
id serial primary key,
name varchar (100) NOT NULL,
email varchar (50) NOT NULL UNIQUE,
password varchar (20) NOT NULL
);
create table cars(
id serial primary key,
description varchar (1000),
mark varchar (50) NOT NULL,
body varchar (15) NOT NULL,
image varchar (255)
);
create table advts(
id serial primary key,
isSale boolean,
created timestamp,
price real,
car_id int not null references cars(id)
);
create table authors(
id serial primary key,
advt_id int references advts(id),
user_id int references users(id)
);
|
SELECT
SYS_DIVISION
FROM
AUTHORITY_OBJECT_MST
WHERE
PAGE_ID=/*pageId*/''
|
SELECT model, price
FROM Printer
WHERE price IN (SELECT MAX(price) AS price FROM Printer); |
drop table if exists employee_tbl;
create table employee_tbl (
id int not null AUTO_INCREMENT,
name varchar(30) not null,
gender char(2) null,
birthday datetime null,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
insert into employee_tbl(name, gender, birthday) values ('lily', '女', '1992-11-21');
insert into employee_tbl(name, gender, birthday) values ('lucy', '女', '1988-12-22');
insert into employee_tbl(name, gender, birthday) values ('jacky', '男', '1985-08-25');
insert into employee_tbl(name, gender, birthday) values ('keven', '男', '1983-05-12');
insert into employee_tbl(name, gender, birthday) values ('poly', '女', '1997-10-02');
drop procedure if exists get_employees_sp;
CREATE procedure get_employees_sp()
BEGIN
select * from employee_tbl;
END
;
call get_employees_sp; |
1. Выведите всю информацию о сотрудниках, с самым длинным именем.
select * from employees
where length(first_name) = (select max(length (first_name)) from employees);
2. Выведите всю информацию о сотрудниках, с зарплатой большей средней зарплаты всех сотрудников.
select first_name, salary, (select round(avg(salary)) from employees) avg_salary from employees
where salary > (select avg(salary) from employees);
select * from employees
where salary > (select avg(salary) from employees);
3. Получить город/города, где сотрудники в сумме зарабатывают меньше всего.
select * from employees;
Select * from departments;
select * from locations;
select l.location_id, l.city, d.department_id, d.department_name, first_name, salary
from employees e
join departments d on (d.department_id = e.department_id)
join locations l on (l.location_id = d.location_id);
select l.city, count(*), sum(salary), avg(salary)
from employees e
join departments d on (d.department_id = e.department_id)
join locations l on (l.location_id = d.location_id)
group by l.city
having sum(salary) =
(select min(sum(salary))
from employees e
join departments d on (d.department_id = e.department_id)
join locations l on (l.location_id = d.location_id)
group by l.city);
4. Выведите всю информацию о сотрудниках, у которых менеджер получает зарплату больше 15000.
select first_name, last_name, salary, manager_id from employees
where manager_id in (select employee_id from employees where salary > 15000);
5. Выведите всю информацию о департаментах, в которых нет ни одного сотрудника.
select * from employees;
select * from departments;
select * from departments where manager_id is null;
select * from departments where department_id not in (select distinct department_id from employees where department_id is not null);
6. Выведите всю информацию о сотрудниках, которые не являются менеджерами.
select * from employees where employee_id not in (select distinct manager_id from employees where manager_id is not null);
7. Выведите всю информацию о менеджерах, которые имеют в подчинении больше 6ти сотрудников.
select * from employees
where employee_id in
(select manager_id from employees group by manager_id having count(*) >= 6);
--correlated query.
select * from employees e
where (select count(*) from employees where manager_id = e.employee_id) > 6;
8. Выведите всю информацию о сотрудниках, которые работают в департаменте с названием IT .
select * from employees
where department_id in (select department_id from departments where upper(department_name) like '%IT%');
9. Выведите всю информацию о сотрудниках, менеджеры которых устроились на работу в 2005ом году, но при это сами работники
устроились на работу до 2005 года.
select * from employees
where hire_date < to_date('01-JAN-1999','DD-MON-YYYY') AND
manager_id in (select employee_id from employees where to_char(hire_date, 'YYYY')='1996');
10.Выведите всю информацию о сотрудниках, менеджеры которых устроились на работу в январе любого года, и длина job_title этих
сотрудников больше 15ти символов.
select * from employees e
where manager_id in (select employee_id from employees where to_char(hire_date,'MON') = 'JAN')
and (select length(job_title) from jobs where job_id = e.job_id) >= 15; |
CREATE TABLE roles (
role_id serial PRIMARY KEY,
role_key varchar(20) NOT NULL,
description varchar(80) NOT NULL,
created timestamp
);
CREATE TABLE users (
user_id serial PRIMARY KEY,
uuid uuid,
club_id serial NOT NULL,
username varchar(80),
password varchar(100),
first_name varchar(40),
last_name varchar(40),
email varchar(80),
enabled boolean NOT NULL DEFAULT TRUE,
chg_password boolean NOT NULL DEFAULT TRUE,
created timestamp,
CONSTRAINT FK_users_club_id FOREIGN KEY (club_id)
REFERENCES clubs (club_id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE user_roles (
user_role_id serial PRIMARY KEY,
user_id serial,
role_id serial,
created timestamp,
CONSTRAINT FK_user_roles_user_id FOREIGN KEY (user_id)
REFERENCES users (user_id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT FK_user_roles_role_id FOREIGN KEY (role_id)
REFERENCES roles (role_id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE password_resets (
password_reset_id serial PRIMARY KEY,
user_id serial NOT NULL,
reset_key uuid NOT NULL,
complete boolean NOT NULL DEFAULT FALSE,
created timestamp,
updated timestamp,
CONSTRAINT FK_password_resets_user_id FOREIGN KEY (user_id)
REFERENCES users (user_id) MATCH SIMPLE
); |
-- Sales and Profit by Customer
select customer_name, sum(sales), sum(profit) from orders
group by customer_name
;
--Sales per region
select region, sum(sales) from orders
group by region
order by sum(sales) desc
;
--Total Sales
select extract (year from order_date) as year_date, sum(sales) from orders
group by year_date
;
--Profit per order
select order_id, sum(profit) as profits from orders
group by order_id
having sum(profit) > 0
order by profits desc
;
-- Monthly Sales by Segment
select segment, extract (year from order_date) as order_year, extract (month from order_date) as order_month, sum(sales) from orders
group by segment, order_year, order_month
order by order_year desc, order_month desc |
-- 문제1) EMPLOYEES 테이블에서 급여가 3000이상인 사원의 사원번호, 이름, 담당업무, 급여를 출력하라.
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY
FROM EMPLOYEES
WHERE SALARY>=3000;
-- 문제2) EMPLOYEES 테이블에서 담당 업무가 ST_MAN인 사원의 사원번호, 성명, 담당업무, 급여, 부서번호를 출력하라.
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, DEPARTMENT_ID
FROM EMPLOYEES
WHERE JOB_ID='ST_MAN';
-- 문제3) EMPLOYEES 테이블에서 입사일자가 2006년 1월 1일 이후에 입사한 사원의 사원번호, 성명, 담당업무, 급여, 입사일자, 부서번호를 출력하라.
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY,HIRE_DATE, DEPARTMENT_ID
FROM EMPLOYEES
--WHERE HIRE_DATE > '06/01/01';
Where hire_date > To_DATE('060101','YYMMDD');
-- 문제4) EMPLOYEES 테이블에서 급여가 3000에서 5000사이의 사원의 성명, 담당업무, 급여, 부서번호를 출력하라.
SELECT FIRST_NAME, JOB_ID, SALARY, DEPARTMENT_ID
FROM EMPLOYEES
WHERE SALARY BETWEEN 3000 AND 5000;
-- 문제5) EMPLOYEES 테이블에서 사원번호가 145,152,203인 사원의 사원번호, 성명, 담당업무, 급여, 입사일자를 출력하라
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, HIRE_DATE
FROM EMPLOYEES
WHERE EMPLOYEE_ID = ANY(145,152,203);
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, HIRE_DATE
FROM EMPLOYEES
WHERE EMPLOYEE_ID IN (145,152,203);
-- 문제6) EMPLOYEES 테이블에서 입사일자가 05년도에 입사한 사원의 사원번호, 성명, 담당업무, 급여, 입사일자, 부서번호를 출력하라.
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, HIRE_DATE, DEPARTMENT_ID
FROM EMPLOYEES
WHERE HIRE_DATE BETWEEN '05/01/01' AND '05/12/31';
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, HIRE_DATE, DEPARTMENT_ID
FROM EMPLOYEES
WHERE HIRE_DATE like '05%';
-- 문제7) EMPLOYEES 테이블에서 보너스가 없는 사원의 사원번호, 성명, 담당업무, 급여, 입사일자, 보너스, 부서번호를 출력하라.
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, HIRE_DATE,COMMISSION_pct, DEPARTMENT_ID
FROM EMPLOYEES
WHERE COMMISSION_PCT IS NULL;
-- 문제8) EMPLOYEES 테이블에서 급여가 1100이상이고 JOB이 ST_MAN인 사원의 사원번호, 성명, 담당업무, 급여, 입사일자, 부서번호를 출력하라
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, HIRE_DATE, DEPARTMENT_ID
FROM EMPLOYEES
WHERE SALARY >= 8000 AND JOB_ID = 'ST_MAN';
-- 문제9) EMPLOYEES 테이블에서 급여가 10000이상이거나 JOB이 ST_MAN인 사원의 사원번호, 성명, 담당업무, 급여, 입사일자, 부서번호를 출력하라
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, HIRE_DATE, DEPARTMENT_ID
FROM EMPLOYEES
WHERE SALARY >= 10000 OR JOB_ID = 'ST_MAN';
-- 문제10) EMPLOYEES 테이블에서 JOB이 ST_MAN, SA_MAN, SA_REP가 아닌 사원의 사원번호, 성명, 담당업무, 급여, 부서번호를 출력하라
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, DEPARTMENT_ID
FROM EMPLOYEES
WHERE JOB_ID NOT IN ('ST_MAN', 'SA_MAN', 'SA_REP');
-- 문제11) 업무가 PRESIDENT이고 급여가 12000이상이거나 업무가 SA_MAN인 사원의 사원번호, 이름, 업무, 급여를 출력하라.
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY
FROM EMPLOYEES
WHERE JOB_ID ='AD_PRES'
AND SALARY >= 12000
OR JOB_ID = 'SA_MAN';
-- 문제12) 업무가 AD_PRES 또는 SA_MAN이고 급여가 12000이상인 사원의 사원번호, 이름, 업무, 급여를 출력하라.
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY
FROM EMPLOYEES
WHERE JOB_ID IN ('AD_PRES','SA_MAN') and SALARY>12000;
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY
FROM EMPLOYEES
WHERE JOB_ID = 'AD_PRES' or JOB_ID = 'SA_MAN' and SALARY>12000;
|
ALTER TABLE [prod].[DeliveryBindingsHistory]
ADD CONSTRAINT [PK_DeliveryBindingsHistory] PRIMARY KEY ([TriggerDate] ASC, [Id] ASC) |
\c hack1;
DROP TABLE IF EXISTS users CASCADE;
CREATE TABLE users (
id SERIAL PRIMARY KEY,
displayName VARCHAR(50),
);
|
-- phpMyAdmin SQL Dump
-- version 4.0.4
-- http://www.phpmyadmin.net
--
-- Máquina: localhost
-- Data de Criação: 27-Jul-2014 às 20:49
-- Versão do servidor: 5.6.12-log
-- versão do PHP: 5.4.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Base de Dados: `araruna_paiamab`
--
-- --------------------------------------------------------
--
-- Estrutura da tabela `1_backup`
--
CREATE TABLE IF NOT EXISTS `1_backup` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`contador` int(11) NOT NULL,
`data` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`arquivo` varchar(35) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
create user if not exists 'webapp'@'%' identified by 'webapp';
create database if not exists `webapp`;
use webapp;
grant all privileges on `webapp` to 'webapp'@'%';
grant all privileges on `webapp`.* to 'webapp'@'%';
|
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 13, 2019 at 01:19 PM
-- Server version: 10.1.39-MariaDB
-- PHP Version: 7.1.29
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: `complexity_graphs`
--
-- --------------------------------------------------------
--
-- Table structure for table `course`
--
CREATE TABLE `course` (
`course_description` text,
`course_code` varchar(7) NOT NULL,
`year` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `course`
--
INSERT INTO `course` (`course_description`, `course_code`, `year`) VALUES
('Basics of programming with java.', 'CSC2000', 2),
('CSC2202', 'CSC2202', 2),
('Software engineering.', 'CSC3600', 3);
-- --------------------------------------------------------
--
-- Table structure for table `prerequisites`
--
CREATE TABLE `prerequisites` (
`course_code` varchar(7) NOT NULL,
`prerequisite_code` varchar(7) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `prerequisites`
--
INSERT INTO `prerequisites` (`course_code`, `prerequisite_code`) VALUES
('CSC3600', 'CSC2000');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `course`
--
ALTER TABLE `course`
ADD PRIMARY KEY (`course_code`);
--
-- Indexes for table `prerequisites`
--
ALTER TABLE `prerequisites`
ADD PRIMARY KEY (`prerequisite_code`,`course_code`),
ADD KEY `course_code` (`course_code`);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `prerequisites`
--
ALTER TABLE `prerequisites`
ADD CONSTRAINT `prerequisites_ibfk_1` FOREIGN KEY (`course_code`) REFERENCES `course` (`course_code`),
ADD CONSTRAINT `prerequisites_ibfk_2` FOREIGN KEY (`prerequisite_code`) REFERENCES `course` (`course_code`);
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 */;
|
CREATE SEQUENCE messageIds;
CREATE TABLE messages(
id INTEGER NOT NULL PRIMARY KEY,
usr TEXT NOT NULL,
text TEXT NOT NULL
);
CREATE TABLE followers(
follower TEXT NOT NULL,
followed TEXT NOT NULL
);
CREATE TABLE hashtags(
tag TEXT NOT NULL,
message INTEGER NOT NULL REFERENCES messages(id),
PRIMARY KEY (tag, message)
);
CREATE INDEX ON messages(usr);
CREATE INDEX ON followers(follower);
|
CREATE table DOKTER
(kd_dokter varchar(100) not null, nama_dokter varchar(100), alamat_dokter varchar(100),
spesialis_dokter varchar(20),
constraint kd_dokter primary key(kd_dokter));
CREATE table ruang
(kd_ruang varchar(20) not null, nama_ruang varchar(20), nama_gedung varchar(20),
constraint kd_ruang primary key(kd_ruang));
CREATE table petugas
(id_petugas varchar(20) not null, nama_petugas varchar(20), alamat_petugas varchar(20),
jam_jaga timestamp,
constraint id_petugas primary key(id_petugas));
CREATE table pembayaran
(kd_pembayaran varchar(20) not null, id_petugas varchar(20), id_pasien varchar(20),
jumlah_harga INT,
constraint kd_pembayaran primary key(kd_pembayaran));
CREATE table pasien
(id_pasien varchar(20) not null, nama_pasien varchar(100), alamat_pasien varchar(100),
tanggal_datang date, keluhan varchar(1000),kd_dokter varchar(100),
constraint id_pasien primary key(id_pasien));
CREATE table rawat_inap
(id_rawatinap varchar(20) not null, kd_ruang varchar(20), id_pasien varchar(20),
constraint id_rawatinap primary key(id_rawatinap));
ALTER TABLE rawat_inap ADD CONSTRAINT inap_pasien_FK FOREIGN KEY ( id_pasien ) REFERENCES pasien ( id_pasien ) ;
ALTER TABLE rawat_inap ADD CONSTRAINT ruang_inap_FK FOREIGN KEY ( kd_ruang ) REFERENCES ruang ( kd_ruang ) ;
ALTER TABLE pasien ADD CONSTRAINT pasien_dokter_FK FOREIGN KEY ( kd_dokter ) REFERENCES dokter ( kd_dokter ) ;
ALTER TABLE pembayaran ADD CONSTRAINT bayar_pasien_FK FOREIGN KEY ( id_pasien ) REFERENCES pasien ( id_pasien ) ;
ALTER TABLE pembayaran ADD CONSTRAINT bayar_petugas_FK FOREIGN KEY ( id_petugas ) REFERENCES petugas ( id_petugas ) ;
ALTER TABLE petugas MODIFY jam_jaga VARCHAR(20);
|
REM Monitoring and tuning script for Oracle databases all versions
REM This script has no adverse affects. There are no DML or DDL actions taken
REM Parts will not work in all versions but useful info should be returned from other parts
REM Uses anonymous procedures to avoid storing objects in the SYS schema
REM therefore this script must be run as sys
REM calls to v$parameter need to be moved into subblocks to prevent NO_DATA_FOUND exceptions
REM parameter numbers are different between Oracle Versions
REM
REM This daily script is a subset of the weekly script
REM This script monitors only those things that might cause an application or database failure
REM and not all of those
REM
REM For nicer formatting run the following in vi: %s/ *$//
REM This strips the trailing whitespace returned from oracle
REM
REM These scripts have been collected from many sources and I am sure there are
REM acknowledgements missing from below. Among those are Steve Adams, Rachel Carmichael,
REM Jared Still and other members of the oracle-l mailing list
REM
REM Unknown authors 1990 - 1995
REM Oracle Corporation 1990 -
REM Bill Beaton, QC Data 1995
REM D. Morgan, QC Data 1997
REM Hari Krishnamoorthy, QC Data 1999
REM J. J. Wang, Bartertrust 2000
REM D. Morgan, 1001111 Alberta Ltd. 2002
REM
set pause off
set verify off
set echo off
set term off
set heading off
REM Set up dynamic spool filename
spool tmp7_spool.sql
select 'spool '||name||'_'||'daily'||'_'||to_char(sysdate,'yymondd')||'.dat'
from sys.v_$database;
spool off
set heading on
set verify on
set term on
set serveroutput on size 1000000
set wrap on
set linesize 200
set pagesize 1000
/**************************************** START REPORT ****************************************************/
/* Run dynamic spool output name */
@tmp7_spool.sql
set feedback off
set heading off
select 'Report Date: '||to_char(sysdate,'Monthdd, yyyy hh:mi')
from dual;
set heading on
prompt =================================================================================================
prompt . DATABASE (V$DATABASE) (V$VERSION)
prompt =================================================================================================
select NAME "Database Name",
CREATED "Created",
LOG_MODE "Status"
from sys.v_$database;
select banner "Current Versions"
from sys.v_$version;
prompt =================================================================================================
prompt . UPTIME (V$DATABASE) (V$INSTANCE)
prompt =================================================================================================
set heading off
column sttime format A30
SELECT NAME, ' Database Started on ',TO_CHAR(STARTUP_TIME,'DD-MON-YYYY "at" HH24:MI')
FROM V$INSTANCE, v$database;
set heading on
prompt .
prompt =================================================================================================
prompt . SGA SIZE (V$SGA) (V$SGASTAT)
prompt =================================================================================================
column Size format 99,999,999,999
select decode(name, 'Database Buffers',
'Database Buffers (DB_BLOCK_SIZE*DB_BLOCK_BUFFERS)',
'Redo Buffers',
'Redo Buffers (LOG_BUFFER)', name) "Memory",
value "Size"
from sys.v_$sga
UNION ALL
select '------------------------------------------------------' "Memory",
to_number(null) "Size"
from dual
UNION ALL
select 'Total Memory' "Memory",
sum(value) "Size"
from sys.v_$sga;
prompt .
prompt .
prompt Current Break Down of (SGA) Variable Size
prompt ------------------------------------------
column Bytes format 999,999,999
column "% Used" format 999.99
column "Var. Size" format 999,999,999
select a.name "Name",
bytes "Bytes",
(bytes / b.value) * 100 "% Used",
b.value "Var. Size"
from sys.v_$sgastat a,
sys.v_$sga b
where a.name not in ('db_block_buffers','fixed_sga','log_buffer')
and b.name='Variable Size'
order by 3 desc;
prompt .
set feedback ON
declare
h_char varchar2(100);
h_char2 varchar(50);
h_num1 number(25);
result1 varchar2(50);
result2 varchar2(50);
cursor c1 is
select lpad(namespace,17)||': gets(pins)='||rpad(to_char(pins),9)||
' misses(reloads)='||rpad(reloads,9)||
' Ratio='||decode(reloads,0,0,to_char((reloads/pins)*100,999.999))||'%'
from v$librarycache;
begin
dbms_output.put_line
('=================================================================================================');
dbms_output.put_line('. SHARED POOL: LIBRARY CACHE (V$LIBRARYCACHE)');
dbms_output.put_line
('=================================================================================================');
dbms_output.put_line('.');
dbms_output.put_line('. Goal: The library cache ratio < 1%' );
dbms_output.put_line('.');
Begin
SELECT 'Current setting: '||substr(value,1,30) INTO result1
FROM V$PARAMETER
WHERE NUM = 23;
SELECT 'Current setting: '||substr(value,1,30) INTO result2
FROM V$PARAMETER
WHERE NUM = 325;
EXCEPTION
WHEN NO_DATA_FOUND THEN
h_num1 :=1;
END;
dbms_output.put_line('Recommendation: Increase SHARED_POOL_SIZE '||rtrim(result1));
dbms_output.put_line('. OPEN_CURSORS ' ||rtrim(result2));
dbms_output.put_line('. Also write identical sql statements.');
dbms_output.put_line('.');
open c1;
loop
fetch c1 into h_char;
exit when c1%notfound;
dbms_output.put_line('.'||h_char);
end loop;
close c1;
dbms_output.put_line('.');
select lpad('Total',17)||': gets(pins)='||rpad(to_char(sum(pins)),9)||
' misses(reloads)='||rpad(sum(reloads),9),
' Your library cache ratio is '||
decode(sum(reloads),0,0,to_char((sum(reloads)/sum(pins))*100,999.999))||'%'
into h_char,h_char2
from v$librarycache;
dbms_output.put_line('.'||h_char);
dbms_output.put_line('. ..............................................');
dbms_output.put_line('. '||h_char2);
dbms_output.put_line('.');
end;
/
declare
h_num1 number(25);
h_num2 number(25);
h_num3 number(25);
result1 varchar2(50);
begin
dbms_output.put_line
('=================================================================================================');
dbms_output.put_line('. SHARED POOL: DATA DICTIONARY (V$ROWCACHE)');
dbms_output.put_line
('=================================================================================================');
dbms_output.put_line('.');
dbms_output.put_line('. Goal: The row cache ratio should be < 10% or 15%' );
dbms_output.put_line('.');
dbms_output.put_line('. Recommendation: Increase SHARED_POOL_SIZE '||result1);
dbms_output.put_line('.');
select sum(gets) "gets", sum(getmisses) "misses", round((sum(getmisses)/sum(gets))*100 ,3)
into h_num1,h_num2,h_num3
from v$rowcache;
dbms_output.put_line('.');
dbms_output.put_line('. Gets sum: '||h_num1);
dbms_output.put_line('. Getmisses sum: '||h_num2);
dbms_output.put_line(' .......................................');
dbms_output.put_line('. Your row cache ratio is '||h_num3||'%');
end;
/
declare
h_char varchar2(100);
h_num1 number(25);
h_num2 number(25);
h_num3 number(25);
h_num4 number(25);
result1 varchar2(50);
begin
dbms_output.put_line('.');
dbms_output.put_line
('=================================================================================================');
dbms_output.put_line('. BUFFER CACHE (V$SYSSTAT)');
dbms_output.put_line
('=================================================================================================');
dbms_output.put_line('.');
dbms_output.put_line('. Goal: The buffer cache ratio should be > 70% ');
dbms_output.put_line('.');
Begin
SELECT 'Current setting: '||substr(value,1,30) INTO result1
FROM V$PARAMETER
WHERE NUM = 125;
EXCEPTION
WHEN NO_DATA_FOUND THEN
result1 := 'Unknown parameter';
END;
dbms_output.put_line('. Recommendation: Increase DB_BLOCK_BUFFERS '||result1);
dbms_output.put_line('.');
select lpad(name,15) ,value
into h_char,h_num1
from v$sysstat
where name ='db block gets';
dbms_output.put_line('. '||h_char||': '||h_num1);
select lpad(name,15) ,value
into h_char,h_num2
from v$sysstat
where name ='consistent gets';
dbms_output.put_line('. '||h_char||': '||h_num2);
select lpad(name,15) ,value
into h_char,h_num3
from v$sysstat
where name ='physical reads';
dbms_output.put_line('. '||h_char||': '||h_num3);
h_num4:=round(((1-(h_num3/(h_num1+h_num2))))*100,3);
dbms_output.put_line('. .......................................');
dbms_output.put_line('. Your buffer cache ratio is '||h_num4||'%');
dbms_output.put_line('.');
end;
/
declare
h_char varchar2(100);
h_num1 number(25);
h_num2 number(25);
h_num3 number(25);
cursor buff2 is
SELECT name
,consistent_gets+db_block_gets, physical_reads
,DECODE(consistent_gets+db_block_gets,0,TO_NUMBER(null)
,to_char((1-physical_reads/(consistent_gets+db_block_gets))*100, 999.999))
FROM v$buffer_pool_statistics;
begin
dbms_output.put_line
('=================================================================================================');
dbms_output.put_line('. BUFFER CACHE (V$buffer_pool_statistics)');
dbms_output.put_line
('=================================================================================================');
dbms_output.put_line('.');
dbms_output.put_line('.');
dbms_output.put_line('Buffer Pool: Logical_Reads Physical_Reads HIT_RATIO');
dbms_output.put_line('.');
open buff2;
loop
fetch buff2 into h_char, h_num1, h_num2, h_num3;
exit when buff2%notfound;
dbms_output.put_line(rpad(h_char, 15, '.')||' '||lpad(h_num1, 10, ' ')||' '||
lpad(h_num2, 10, ' ')||' '||lpad(h_num3, 10, ' '));
end loop;
close buff2;
dbms_output.put_line('.');
end;
/
declare
h_char varchar2(100);
h_num1 number(25);
result1 varchar2(50);
cursor c2 is
select name,value
from v$sysstat
where name in ('sorts (memory)','sorts (disk)')
order by 1 desc;
begin
dbms_output.put_line
('=================================================================================================');
dbms_output.put_line('. SORT STATUS (V$SYSSTAT)');
dbms_output.put_line
('=================================================================================================');
dbms_output.put_line('.');
dbms_output.put_line('. Goal: Very low sort (disk)' );
dbms_output.put_line('.');
BEGIN
SELECT 'Current setting: '||substr(value,1,30) INTO result1
FROM V$PARAMETER
WHERE NUM = 320;
EXCEPTION
WHEN NO_DATA_FOUND THEN
result1 := 'Unknown parameter';
END;
dbms_output.put_line(' Recommendation: Increase SORT_AREA_SIZE '||result1);
dbms_output.put_line('.');
dbms_output.put_line('.');
dbms_output.put_line(rpad('Name',30)||'Count');
dbms_output.put_line(rpad('-',25,'-')||' -----------');
open c2;
loop
fetch c2 into h_char,h_num1;
exit when c2%notfound;
dbms_output.put_line(rpad(h_char,30)||h_num1);
end loop;
close c2;
end;
/
prompt .
prompt =================================================================================================
prompt . TABLESPACE USAGE (DBA_DATA_FILES, DBA_FREE_SPACE)
prompt =================================================================================================
column Tablespace format a30
column Size format 999,999,999,999
column Used format 999,999,999,999
column Free format 999,999,999,999
column "% Used" format 999.99
select tablespace_name "Tablesapce",
bytes "Size",
nvl(bytes-free,bytes) "Used",
nvl(free,0) "Free",
nvl(100*(bytes-free)/bytes,100) "% Used"
from(
select ddf.tablespace_name, sum(dfs.bytes) free, ddf.bytes bytes
FROM (select tablespace_name, sum(bytes) bytes
from dba_data_files group by tablespace_name) ddf, dba_free_space dfs
where ddf.tablespace_name = dfs.tablespace_name(+)
group by ddf.tablespace_name, ddf.bytes)
order by 5 desc;
set feedback off
set heading off
select rpad('Total',30,'.') "Tablespace",
sum(bytes) "Size",
sum(nvl(bytes-free,bytes)) "Used",
sum(nvl(free,0)) "Free",
(100*(sum(bytes)-sum(free))/sum(bytes)) "% Used"
from(
select ddf.tablespace_name, sum(dfs.bytes) free, ddf.bytes bytes
FROM (select tablespace_name, sum(bytes) bytes
from dba_data_files group by tablespace_name) ddf, dba_free_space dfs
where ddf.tablespace_name = dfs.tablespace_name(+)
group by ddf.tablespace_name, ddf.bytes);
set feedback on
set heading on
prompt .
prompt =================================================================================================
prompt . FREE SPACE FRAGMENTATION (DBA_FREE_SPACE)
prompt =================================================================================================
column Tablespace format a30
column "Available Size" format 99,999,999,999
column "Fragmentation" format 99,999
column "Average Size" format 9,999,999,999
column " Max" format 9,999,999,999
column " Min" format 9,999,999,999
select tablespace_name Tablespace,
count(*) Fragmentation,
sum(bytes) "Available Size",
avg(bytes) "Average size",
max(bytes) Max,
min(bytes) Min
from dba_free_space
group by tablespace_name
order by 3 desc ;
prompt .
prompt ============================================================================================
prompt . SUMMARY OF INVALID OBJECTS (DBA_OBJECTS)
prompt ============================================================================================
select owner, object_type, substr(object_name,1,30) object_name, status
from dba_objects
where status='INVALID'
order by object_type;
prompt .
prompt ============================================================================================
prompt . LAST REFRESH OF SNAPSHOTS (DBA_SNAPSHOTS)
prompt ============================================================================================
select owner, name, last_refresh
from dba_snapshots
where last_refresh < (SYSDATE - 1);
prompt .
prompt ============================================================================================
prompt . LAST JOBS SCHEDULED (DBA_JOBS)
prompt ============================================================================================
set arraysize 10
set linesize 65
col what format a65
col log_user format a10
col job format 9999
select job, log_user, last_date, last_sec, next_date, next_sec,
failures, what
from dba_jobs
where failures > 0;
set linesize 100
prompt .
prompt =================================================================================================
prompt . ERROR- These segments will fail during NEXT EXTENT (DBA_SEGMENTS)
prompt =================================================================================================
column Tablespaces format a30
column Segment format a40
column "NEXT Needed" format 999,999,999
column "MAX Available" format 999,999,999
select a.tablespace_name "Tablespaces",
a.owner "Owner",
a.segment_name "Segment",
a.next_extent "NEXT Needed",
b.next_ext "MAX Available"
from sys.dba_segments a,
(select tablespace_name,max(bytes) next_ext
from sys.dba_free_space
group by tablespace_name) b
where a.tablespace_name=b.tablespace_name(+)
and b.next_ext < a.next_extent;
prompt =================================================================================================
prompt . WARNING- These segments > 70% of MAX EXTENT (DBA_SEGMENTS)
prompt =================================================================================================
column Tablespace format a30
column Segment format a40
column Used format 9999
column Max format 9999
select tablespace_name "Tablespace",
owner "Owner",
segment_name "Segment",
extents "Used",
max_extents "Max"
from sys.dba_segments
where (extents/decode(max_extents,0,1,max_extents))*100 > 70
and max_extents >0;
prompt =================================================================================================
prompt . LIST OF OBJECTS HAVING > 12 EXTENTS (DBA_EXTENTS)
prompt =================================================================================================
column Tablespace_ext format a30
column Segment format a40
column Count format 9999
break on "Tablespace_ext" skip 1
select tablespace_name "Tablespace_ext" ,
owner "Owner",
segment_name "Segment",
count(*) "Count"
from sys.dba_extents
group by tablespace_name,owner,segment_name
having count(*)>12
order by 1,3 desc;
prompt =================================================================================================
prompt End of Report
spool off
/* Remove temp spool scripts */
host rm tmp7_*.sql
exit;
|
DROP TABLE IF EXISTS `XXX_plugin_cotent_client`; ##b_dump##
CREATE TABLE `XXX_plugin_cotent_client` (
`plugin_cotent_client_id` int(11) NOT NULL AUTO_INCREMENT,
`plugin_cotent_client_url_der_zentrale` text,
`plugin_cotent_client_token_key_kommt_aus_der_zentrale` text,
`plugin_cotent_client_domain_key` text,
PRIMARY KEY (`plugin_cotent_client_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 ; ##b_dump##
INSERT INTO `XXX_plugin_cotent_client` SET plugin_cotent_client_id='1', plugin_cotent_client_url_der_zentrale='', plugin_cotent_client_token_key_kommt_aus_der_zentrale='xy', plugin_cotent_client_domain_key='' ; ##b_dump##
|
insert into TREATMENT_DETAILS values('P140', '2018-11-26', '2', '4');
insert into TREATMENT_DETAILS values('P141', '2018-11-26', '4', '5');
insert into TREATMENT_DETAILS values('P142', '2018-11-26', '2', '4');
insert into TREATMENT_DETAILS values('P143', '2018-11-26', '1', '5');
insert into TREATMENT_DETAILS values('P144', '2018-11-26', '2', '1');
insert into TREATMENT_DETAILS values('P145', '2018-11-26', '4', '1');
insert into TREATMENT_DETAILS values('P146', '2018-11-26', '2', '1');
insert into TREATMENT_DETAILS values('P147', '2018-11-26', '4', '5');
insert into TREATMENT_DETAILS values('P148', '2018-11-26', '2', '4');
insert into TREATMENT_DETAILS values('P149', '2018-11-26', '4', '4');
insert into TREATMENT_DETAILS values('P150', '2018-11-26', '2', '2');
commit; |
CREATE DATABASE chat;
USE chat;
CREATE TABLE users (
username text not null, password text, id integer auto_increment primary key
);
CREATE TABLE messages (
/* Describe your table here.*/
user_id integer not null, message text, roomname text not null, createdat integer not null auto_increment primary key,
foreign key (user_id) references users(id)
);
/* Create other tables and define schemas for them here! */
/* Execute this file from the command line by typing:
* mysql -u root < server/schema.sql
* to create the database and the tables.*/ |
SELECT (SELECT count(memid) FROM cd.members),firstname, surname
FROM cd.members
ORDER BY joindate |
-- phpMyAdmin SQL Dump
-- version 4.9.5
-- https://www.phpmyadmin.net/
--
-- Хост: localhost
-- Время создания: Июл 12 2021 г., 08:40
-- Версия сервера: 10.3.29-MariaDB-0+deb10u1
-- Версия PHP: 7.3.27-1~deb10u1
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 */;
--
-- База данных: `orthanc`
--
-- --------------------------------------------------------
--
-- Структура таблицы `Users`
--
CREATE TABLE `Users` (
`uid` int(20) NOT NULL,
`uname` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
`ruName` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
`ruMiddleName` text COLLATE utf8mb4_unicode_ci NOT NULL,
`ruFamily` text COLLATE utf8mb4_unicode_ci NOT NULL,
`role` text COLLATE utf8mb4_unicode_ci NOT NULL,
`ugroup` int(5) NOT NULL,
`uTheme` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`hasBlockStudy` tinyint(1) NOT NULL DEFAULT 0,
`blockStudy` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`successStudyCount` int(11) NOT NULL DEFAULT 0,
`returnStudyCount` int(11) NOT NULL DEFAULT 0,
`rating` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Дамп данных таблицы `Users`
--
INSERT INTO `Users` (`uid`, `uname`, `password`, `ruName`, `ruMiddleName`, `ruFamily`, `role`, `ugroup`, `uTheme`, `hasBlockStudy`, `blockStudy`, `successStudyCount`, `returnStudyCount`, `rating`) VALUES
(40, 'admin', 'admin', 'm', 'in', 'ad', 'admin', 1, 'saga', 0, NULL, 0, 0, '0'),
(41, 'local', 'local', 'c', 'al', 'lo', 'localuser', 1, NULL, 1, '5', 0, 0, '0'),
(42, 'remote', 'remote', 'mo', 'te', 're', 'remoteuser', 38, NULL, 0, '0', 0, 0, '0'),
(43, 'onlyview', 'onlyview', 'ко ', 'просмотр', 'Толь', 'onlyview', 1, NULL, 0, NULL, 0, 0, '0');
--
-- Индексы сохранённых таблиц
--
--
-- Индексы таблицы `Users`
--
ALTER TABLE `Users`
ADD PRIMARY KEY (`uid`),
ADD KEY `ugroup` (`ugroup`);
--
-- AUTO_INCREMENT для сохранённых таблиц
--
--
-- AUTO_INCREMENT для таблицы `Users`
--
ALTER TABLE `Users`
MODIFY `uid` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=44;
--
-- Ограничения внешнего ключа сохраненных таблиц
--
--
-- Ограничения внешнего ключа таблицы `Users`
--
ALTER TABLE `Users`
ADD CONSTRAINT `Users_ibfk_1` FOREIGN KEY (`ugroup`) REFERENCES `Usergroup` (`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 */;
|
DROP TABLE IF EXISTS `rda`.`rdadata`.`usg_2017_hetoua_x`;
CREATE TABLE `rda`.`rdadata`.`usg_2017_hetoua_x`
(model_id,
group_id,
uniq_sa_id,
calendar_date,
month_of_year,
day_of_month,
train_year,
predict_year,
day_of_week,
week_of_year,
quarter_of_year,
day_of_year,
day_of_year_shift,
wea_data_typ_id,
wea_data_typ_cd,
baseline_terr_cd,
opr_area_cd,
usg_hr,
rt_sched_cd,
tou_cd, usg_amt)
PARITION BY (day_of_year)
(SELECT cust.model_id,
cust.group_id,
cust.uniq_sa_id,
cust.deriv_baseline_terr_cd,
cust.opr_area_cd,
xref.calendar_date,
xref.month_of_year,
xref.day_of_month,
xref.train_year,
xref.predict_year,
xref.day_of_week,
xref.week_of_year,
xref.quarter_of_year,
xref.day_of_year,
xref.day_of_year_shift,
tou.rt_sched_cd,
tou.tou_cd,
usg.usg_amt,
DATE_PART('hour', usg.elec_intvl_end_dttm) AS usg_hr
FROM `rda`.`rdadata`.`model_population_x` AS cust
INNER JOIN `rda`.`rdatables`.`elec_intvl_usg_all` AS usg
ON cust.uniq_sa_id = usg.uniq_sa_id
INNER JOIN `rda`.`rdadata`.`time_shift_xref` AS xref
ON usg.usg_dt = xref.calendar_date
JOIN `rda`.`rdadata`.`tou_lookup_2017_hetoua` AS tou
ON usg.usg_dt = tou.calendar_date
AND usg.elec_intvl_end_dttm BETWEEN tou.tou_data_from_dttm AND tou.tou_data_to_dttm
WHERE usg.ener_dir_cd = 'D'
LIMIT 10
);
DROP VIEW IF EXISTS `rda`.`rdatables`.`usg_2017_hetoua_x`;
CREATE VIEW `rda`.`rdatables`.`usg_2017_hetoua_x`
AS(SELECT * FROM `rda`.`rdadata`.`usg_2017_hetoua_x`);
|
SELECT
tc.table_schema,
tc.constraint_name,
tc.table_name,
kcu.column_name,
ccu.table_schema AS foreign_table_schema,
ccu.table_name AS foreign_table_name,
ccu.column_name AS foreign_column_name
FROM
information_schema.table_constraints AS tc
JOIN information_schema.key_column_usage AS kcu
ON tc.constraint_name = kcu.constraint_name
AND tc.table_schema = kcu.table_schema
JOIN information_schema.constraint_column_usage AS ccu
ON ccu.constraint_name = tc.constraint_name
AND ccu.table_schema = tc.table_schema
WHERE tc.constraint_type = 'FOREIGN KEY'
AND ccu.table_name in ('vocabulary_concept', 'table_column')
-- AND tc.table_name='table_column'
ORDER BY ccu.table_name, tc.table_name
;
|
-- Lists all genres in database by rating
-- Display tv_genres.name - rating sum
-- DESC by rating
SELECT tv_genres.name, SUM(tv_show_ratings.rate) AS rating
FROM tv_show_ratings INNER JOIN
(tv_shows INNER JOIN
(tv_genres INNER JOIN tv_show_genres
ON tv_genres.id = tv_show_genres.genre_id)
ON tv_shows.id = tv_show_genres.show_id)
ON tv_shows.id = tv_show_ratings.show_id
GROUP BY tv_genres.name
ORDER BY rating DESC, tv_genres.name ASC;
|
SELECT *
FROM CELLS X
WHERE DOMAIN_ID = :domainId
AND EQUIP_CD IN (:equipCds)
AND ACTIVE_FLAG = 1
AND
(
SIDE_CD =
(SELECT
CASE
WHEN RACK_TYPE = 'P'
THEN 'F'
ELSE 'R'
END
FROM RACKS
WHERE DOMAIN_ID = X.DOMAIN_ID
AND RACK_CD = X.EQUIP_CD
)
OR SIDE_CD = 'F'
)
ORDER BY EQUIP_CD,
CELL_SEQ,
SIDE_CD
|
/*
Warnings:
- The migration will change the primary key for the `Libro` table. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `Libro` table. All the data in the column will be lost.
- You are about to drop the column `prestamoId` on the `Libro` table. All the data in the column will be lost.
- The migration will change the primary key for the `Prestamo` table. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `Prestamo` table. All the data in the column will be lost.
- The migration will change the primary key for the `Usuario` table. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `Usuario` table. All the data in the column will be lost.
- Added the required column `libroId` to the `Prestamo` table without a default value. This is not possible if the table is not empty.
*/
-- DropIndex
DROP INDEX "Libro_prestamoId_unique";
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Libro" (
"libroId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"titulo" TEXT NOT NULL,
"autor" TEXT NOT NULL,
"editorial" TEXT NOT NULL,
"sinopsis" TEXT,
"edicion" TEXT
);
INSERT INTO "new_Libro" ("titulo", "autor", "editorial", "sinopsis", "edicion") SELECT "titulo", "autor", "editorial", "sinopsis", "edicion" FROM "Libro";
DROP TABLE "Libro";
ALTER TABLE "new_Libro" RENAME TO "Libro";
CREATE UNIQUE INDEX "Libro.titulo_unique" ON "Libro"("titulo");
CREATE TABLE "new_Prestamo" (
"prestamoId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"usuarioId" INTEGER NOT NULL,
"libroId" INTEGER NOT NULL,
"estado" INTEGER NOT NULL DEFAULT 0,
"fPrestado" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"fEntregaEstimada" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"fEntregaReal" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY ("usuarioId") REFERENCES "Usuario" ("usuarioId") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("libroId") REFERENCES "Libro" ("libroId") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_Prestamo" ("usuarioId", "estado") SELECT "usuarioId", "estado" FROM "Prestamo";
DROP TABLE "Prestamo";
ALTER TABLE "new_Prestamo" RENAME TO "Prestamo";
CREATE UNIQUE INDEX "Prestamo_libroId_unique" ON "Prestamo"("libroId");
CREATE TABLE "new_Usuario" (
"usuarioId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"email" TEXT NOT NULL,
"name" TEXT,
"clave" TEXT NOT NULL,
"activo" INTEGER NOT NULL DEFAULT 0,
"role" INTEGER NOT NULL DEFAULT 3
);
INSERT INTO "new_Usuario" ("email", "name", "clave", "activo", "role") SELECT "email", "name", "clave", "activo", "role" FROM "Usuario";
DROP TABLE "Usuario";
ALTER TABLE "new_Usuario" RENAME TO "Usuario";
CREATE UNIQUE INDEX "Usuario.email_unique" ON "Usuario"("email");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;
|
/*eliminar nuestra base de datos si tiene el mismo nombre*/
drop schema if exists fes_aragon;
/*crear una base de datos*/
create schema if not exists fes_aragon default character set utf8 collate utf8_spanish2_ci;
/*seleccionar la base de datos*/
USE fes_aragon;
/*CREAR UN TABLA*/
CREATE TABLE ALUMNO(
nombre_alumno text not null,
carrera text not null,
no_cuenta int (10) not null,
direccion varchar (8) not null,
telefono varchar (8) not null,
email text not null,
password varchar (8) not null,
fecha_registro datetime not null default current_timestamp,
permisos int (11) not null default '1'
);
/*agregar un registro*/
insert into ALUMNO(nombre_alumno,carrera,no_cuenta,direccion,telefono,email,password,fecha_registro,permisos)values
('aaron Velasco', 'ico', '413112576', 'gloria15', '12354894', 'aaronvelascovea@outlook.com', '13515', '2021-03-09 12:49:56',1);
/*definir nuestras PK*/
alter table alumno
add primary key (no_cuenta);
commit;
/*los cambios son de manera permanente*/
/*codigo de la base de datos*/
|
SELECT
OFERTA.IDOFERTA,
OFERTA.IDTIENDA,
OFERTA.IDPRODUCTO,
OFERTA.NOMBREOFERTA,
OFERTA.MINIMOPRODUCTO,
OFERTA.MAXIMOPRODUCTO,
OFERTA.PRECIOOFERTA,
OFERTA.DESCUENTOOFERTA,
OFERTA.STOCKPRODUCTOOFERTA,
OFERTA.IDESTADO,
OFERTA.IMAGENOFERTA,
OFERTA.VISITAS,
TO_CHAR(OFERTA.FECHAVISITA) ,
TIENDA.IDTIENDA,
PRODUCTO.IDPRODUCTO,
ESTADO.GLOSAESTADO,
PRODUCTO.NOMBREPRODUCTO,
ESTADO.IDESTADO,
TIENDA.NOMBRETIENDA
FROM
PRODUCTO INNER JOIN OFERTA ON PRODUCTO.IDPRODUCTO = OFERTA.IDPRODUCTO
INNER JOIN ESTADO ON OFERTA.IDESTADO = ESTADO.IDESTADO
INNER JOIN TIENDA ON OFERTA.IDTIENDA = TIENDA.IDTIENDA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.