Questions tagged [sql-scripts]

SQL Scripts are lists of SQL sentences written in a single file, meant to be executed sequentially. Depending on the particular RDBMS system, SQL scripts can have procedural language characteristics, such as control-of-flow constructs.

408 questions
221
votes
10 answers

Export specific rows from a PostgreSQL table as INSERT SQL script

I have a database schema named: nyummy and a table named cimory: create table nyummy.cimory ( id numeric(10,0) not null, name character varying(60) not null, city character varying(50) not null, CONSTRAINT cimory_pkey PRIMARY KEY (id) ); I…
null
  • 7,598
  • 14
  • 55
  • 94
66
votes
6 answers

SQL Server - Running large script files

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…
tags2k
  • 70,860
  • 30
  • 74
  • 105
65
votes
4 answers

Executing script file in h2 database

First of all I would like to say am new to h2 database. I need to execute a sql script file in h2 database. I have a script file test.sql and I want to execute this in h2 database. Is it possible?
Kamalam
  • 1,124
  • 4
  • 16
  • 31
60
votes
9 answers

T-SQL STOP or ABORT command in SQL Server

Is there a command in Microsoft SQL Server T-SQL to tell the script to stop processing? I have a script that I want to keep for archival purposes, but I don't want anyone to run it.
Phillip Senn
  • 43,069
  • 83
  • 242
  • 359
38
votes
12 answers

How to Execute SQL Script File in Java?

I want to execute an SQL script file in Java without reading the entire file content into a big query and executing it. Is there any other standard way?
Vladimir
  • 11,563
  • 18
  • 58
  • 76
37
votes
4 answers

How can I describe a table in Oracle without using the DESCRIBE command?

I'm having a hard time with a class I am taking. We need to write an Oracle script that will act just like the DESCRIBE command. The book we are using describes how to work with the Data Dictionary very poorly. Not looking for answers, but a point…
patricksweeney
  • 3,496
  • 7
  • 41
  • 52
35
votes
1 answer

executing a .sql file in sql plus terminal

I have written couple of sql scripts in a text file and saved them with a .sql extension. I want to execute these scripts in the sql plus terminal without having to manually type the standalone sql scripts, but i'm struggling with it. If someone…
shashwatZing
  • 1,407
  • 1
  • 13
  • 23
26
votes
2 answers

MySQL columns with DEFAULT NULL - stylistic choice, or is it?

In many flavors of SQL, there are three ways you can implicitly set a column to NULL on every row insertion. These are: columnname type NULL columnname type DEFAULT NULL columnname type NULL DEFAULT NULL I.e. the first one sets the NULL flag (as…
Kevin Jin
  • 1,436
  • 4
  • 17
  • 20
24
votes
7 answers

How to run SQL scripts and get data on application startup?

I am developing a Spring Boot application. At the moment some of my configs are hard coded (e.g. Hystrix properties). So I would like to get these configs on my application start up time or just after that. Is it possible to do that using Spring…
Laurynas
  • 812
  • 2
  • 8
  • 24
23
votes
3 answers

script to restore database sql server from bak file, doesn't work

I have an empty database: DB_Clients And I want to restore the database from a .bak file: OldDBClients.bak This is the path: C:\OldDBClients.bak And this is my script: USE [master] GO RESTORE DATABASE DB_Clients FROM DISK =…
Esraa_92
  • 1,481
  • 1
  • 15
  • 43
22
votes
1 answer

Mysql: How to call sql script file from other sql script file?

Suppose I have wrote script Table_ABC.sql which creates table ABC. I have created many such scripts for each of required tables. Now i want to write a script that call all of these script files in a sequence so basically I want another script file…
Maddy.Shik
  • 6,241
  • 15
  • 62
  • 98
15
votes
7 answers

How do I generate a script of all database objects in Toad for MySQL

In the freeware version of Toad for MySQL (latest version), I can generate a script of all tables in my database in one file. However, for stored procedures and functions, Toad generates a separate script/file for each one. Ideally, I'd like a…
JohnB
  • 15,593
  • 15
  • 91
  • 109
14
votes
7 answers

How to run multiple SQL scripts using a batch file?

I have a case where i have got 10+ SQL script. I don't want to go and run all my scripts 1 by 1. Is there a way that i can run all my scripts in succession in SQL Management studio. I found this post. Creating a batch file seems easier. This is all…
Willem
  • 8,348
  • 16
  • 63
  • 87
13
votes
1 answer

Any easy way to generate a build script from an H2 database?

let's image that one creates an H2 database with table, indexes, etc... Is there an easy way to extract a SQL script to recreate the structure of this database in another H2 database? I am not referring to the content of the tables, indexes, etc...…
Jérôme Verstrynge
  • 51,859
  • 84
  • 263
  • 429
12
votes
3 answers

SQL Server database last updated date time

Is there any sql script to find out when the database in SQL server is last updated? I want to know the last updated date time for the changes done on meta data of the database rather than actual data inside the table. Particularly when: Any new…
Nagendra Baliga
  • 215
  • 1
  • 5
  • 14
1
2 3
27 28