sql-scripts

Spring Boot Database initialization MySQLException for Trigger

柔情痞子 提交于 2019-12-24 00:38:27
问题 I am using Spring Boot Database initialization using Spring JDBC with schema.sql file.I am using MYSQL If I have simple table creation in schema.sql as follows it works fine CREATE TABLE Persons ( PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) ); But when I add one trigger as follows which runs correctly in MySQL Workbench DROP TRIGGER IF EXISTS Persons_log_update; CREATE TRIGGER Persons_log_update BEFORE UPDATE ON Persons FOR EACH ROW

Script all views/functions/procedures in a Sql Server database in dependency order

三世轮回 提交于 2019-12-22 08:38:19
问题 Sql Server 2008 (and probably most other versions): Management Studio has a 'generate scripts' option that can in theory script a whole database with all objects (Right click, tasks, Generate Scripts). It works OK for most things but when you use it to script all views/stored procedures/functions in a database, it generates a script that does not take account of dependencies between the objects. e.g. If View A references Function B it won't necessarily put Function B in the script first. It

SQL Server - Running large script files

我的未来我决定 提交于 2019-12-17 15:23:35
问题 I have a database table on a development server that is now fully populated after I set it running with an import routine for a CSV file containing 1.4 million rows. I ran the Database Publishing Wizard on the table, and now I have a 286MB SQL script on my local machine. The problem is, I can't figure out how to run it. If I load it into SQL Server Management Studio Express I get an alert window that says "The operation could not be completed". Any ideas on how I can get this SQL script to

How to create a oracle sql script spool file

时光怂恿深爱的人放手 提交于 2019-12-17 13:54:51
问题 I have a question about spooling the the results of my program. My sample sql script looks like this. whenever sqlerror exit failure rollback set heading off set arraysize 1 set newpage 0 set pages 0 set feedback off set echo off set verify off declare ab varchar2(10) := 'Raj'; cd varchar2(10); a number := 10; c number; d number; begin c := a+10; select ab,c into cd,d from dual; end; SPOOL select cd,d from dual; SPOOL OFF EXIT; The above script does not work, but I want to do something like

why is 'create table' in sql script executing 3 times when only using 1 create statement? [duplicate]

本小妞迷上赌 提交于 2019-12-14 04:13:12
问题 This question already has answers here : When do I need to use a semicolon vs a slash in Oracle SQL? (6 answers) Closed 2 years ago . I have an SQL script in which I want to automate the creation of a table. However, when I exec it, it seems as though it's trying to create the table 3 times. The first time, it creates the table. The next 2 times, it complains it already exists by throwing an "ORA-00955: name is already used by an existing object" Here my sql script(@/vagrant/scripts/db_tables

Error: Column doesn't exist in table (Foreign Key referencing)

和自甴很熟 提交于 2019-12-14 03:26:17
问题 Question I am trying to link the ID column from the Customer's table to C_ID in the Purchases table. I am still learning SQL so I have a light knowledge and am not sure why this error is occuring. If someone could offer up a solution and point where I've went wrong that would be great. Error Message SQL Code CREATE TABLE Customer ( ID INTEGER, Firstname VARCHAR (15), Lastname VARCHAR (15), Address VARCHAR (254), Postcode VARCHAR (8), Email VARCHAR (254), Phoneno INTEGER, Points INTEGER,

Executing several SQL queries with MySQLdb

末鹿安然 提交于 2019-12-12 12:52:21
问题 How would you go about executing several SQL statements (script mode) with python? Trying to do something like this: import MySQLdb mysql = MySQLdb.connect(host='host...rds.amazonaws.com', db='dbName', user='userName', passwd='password') sql = """ insert into rollout.version (`key`, `value`) VALUES ('maxim0', 'was here0'); insert into rollout.version (`key`, `value`) VALUES ('maxim1', 'was here1'); insert into rollout.version (`key`, `value`) VALUES ('maxim2', 'was here1'); """ mysql.query

Conditional update on Hana Studio (SQL Script) trigger

核能气质少年 提交于 2019-12-11 18:15:14
问题 I have two example tables: TABLE1: ID | COLUMN_B| COLUMN_C _________|_________|_________ 1 | 0 | 1 ________|_________|_________ 2 | 0 | 1 ________|_________|_________ 3 | 0 | 1 TABLE2: ID | COLUMN_E| COLUMN_F ________|_________|________ 1 | Y | X ________|_________|_________ 2 | Y | X ________|_________|_________ 3 | Y | X What I would like to do is to write a trigger on Hana Studio using SQL Script to update column E from table 2 when column B from table 1 is updated to a specific value (let

Initialize a database with a script using Spring JDBC fails

浪子不回头ぞ 提交于 2019-12-11 05:34:54
问题 I am trying to initialize my database with a view and a rule following 75.3 Initialize a database using Spring JDBC. 75.3 Initialize a database using Spring JDBC Spring JDBC has a DataSource initializer feature. Spring Boot enables it by default and loads SQL from the standard locations schema.sql and data.sql (in the root of the classpath). In addition Spring Boot will load the schema-${platform}.sql and data-${platform}.sql files (if present), where platform is the value of spring

Quickly generate ascii text sql scripts based off of sql 2008 database

≡放荡痞女 提交于 2019-12-11 01:29:52
问题 This is starting to frustrate me, mostly because it should be easy to do but I can't find anything. I am trying to version control my database. The method I have decided upon is to generate scripts at each check-in that creates a sql script for every object in my database. Most of my edits are done via the visual designer in SSMS and I don't trust myself to remember to generate change scripts every time. I am only concerned with the schema for now, although soon I would like data from certain