Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sql]

The tag has no usage guidance.

1
vote
3answers
28 views

Prevent Script from Inserting Space in File Name

I have an Oracle database table that is storing the full path and name of a file in a table column. In a SQL client I can run: select file_name from table where request_id=12345 and I will get this ...
1
vote
3answers
55 views

Search for a dynamic pattern in a file in a file and replace it with variables

I have written the below commands that will generate three different shuffled vales A=`echo 'abcdefghijklmnopqrstuvwxyz' | sed 's/./&\n/g' | shuf | tr -d "\n"` B=`echo '...
0
votes
1answer
46 views

Postfix: Whitelist all entries in address book

my postfix currently rejects emails that are potentially SPAM. Howver, some of my contacts have servers that are not correctly configured and I want to avoid rejecting their email. ...
0
votes
1answer
37 views

Forgot sql password for a certain user (debian)

I have two sql users on my sql server: root and bob. I know the root password, but I forgot bob's password. How can I view/reset bob's password?
0
votes
2answers
60 views

Adding headers to a CSV

I have an SQL command which fetches you an output like 70 138 200 This is stored in a csv and I have added headers to it but appears like A,B,C 70 138 200 I wanted it to look like A 70 B 138 C ...
1
vote
1answer
95 views

PhpMyadmin times out with small SQL file

I am trying to upload bump to phpmyadmin, which has has only 2MB but it has 12 thousand lines. I always get this error: Service Unavailable The server is temporarily unable to service your request ...
0
votes
1answer
152 views

make json from SQL query output

I have this query: select hostname,size from tableinfo output is like this: hostname size ------------------------- ----------- host1 28 host2 ...
-1
votes
4answers
288 views

SQL operation on csv file using bash or shell

This is my input file 0164318,001449,001452,001922 0164318,001456,001457,001922 0842179,002115,002118,001485 0846354,001512,001513,001590 0841422,001221,001224,001860 0841422,001227,...
14
votes
2answers
847 views

How does this shebang that starts with a double hyphen (--) work?

I have found the following kind of shebang in the RosettaCode page: --() { :; }; exec db2 -txf "$0" It works for Db2, and a similar thing for Postgres. However, I do not understand the whole line. ...
0
votes
1answer
112 views

How to compile a “.pc” file on Debian 9?

I need to compile a Pro*C - .pc file on Ubuntu. So far what I have realised is that I need a Pro*C compiler to translate the Pro*C - .pc file into pure / standard C code.  But I need to have Oracle ...
0
votes
1answer
77 views

Use sed to prefix and suffix multiple strings per line

I have a .sql file with some 15,000,000 INSERT commands on each line, which look something like this: INSERT INTO tableName (col1,col2,col3,col4,col5,col6,col7,col8) VALUES ('Jan 7 2018 12:33PM', 'R'...
1
vote
0answers
19 views

MySQL - query to show guests with same last_name + booking_date [closed]

I have a guest table and a booking table and I am attempting to query how to find guests who share the same last names with the same booking date. The result should output their last_name and ...
0
votes
1answer
102 views

Incorrect syntax error in unix script while using if exists command (sybase as database)

I have the below script presenting me the following error: isql -U$DBLogin -PDBPAss -S$DBName -e <<! use $db go if exists (select 1 from syscolumns where id = object_id('Main_table') and ...
0
votes
1answer
235 views

Installing Oracle SQL Developer in Arch

I've spent >3 hrs trying to figure this out. I've done both methods shown in the wiki. Both seem to have worked fine. When I search I can't find any newly installed software with any name like "...
-2
votes
1answer
55 views

Delete remotely oracle schema using shell script [closed]

I have a remote instance like database-ora12 with existing user tester / password and SID=orac How I can delete remotely database or schema from this system for this user using shell script without ...
0
votes
1answer
132 views

REGEX search & replace with sed or other command

I have a big SQL file with content like [code language="bash"] git checkout master git pull origin master ... [/code] Lorem ipsum dolor sit amet, consectetur adipiscing elitUt enim ad minim [code]...
-1
votes
1answer
44 views

What happens if I specify nonexisting join field(s) for one or both of the input files?

I have two files $ cat file1 c c1 b b1 $ cat file2 a a2 c c2 b b2 What happens if I specify nonexisting join field(s) for one or both of the input files? Why do the following outer joins generate ...
-1
votes
1answer
60 views

What does `join` do in terms of equijoin in SQL or operations in relational algebra?

join in coreutils reminds me of equijoin in SQL. join writes to standard output a line for each pair of input lines that have identical join fields. I am not very clear about what join does from ...
0
votes
0answers
407 views

How to update data of a field in an oracle table?

My table name: KEY_PARAMETER It consists two fields named SET_NO. and MES_VAL SET_NO. is fixed which doesn't change but my MES_VAL filed is getting changed is every on minute. My intention is to ...
0
votes
1answer
107 views

AWK Script to read some parameters from log file and Insert that data to Oracle DB table

I have a requirement to read some parameters from log file and then use this data in an Insert statement to create records in a a database table. Input is log file testapi.log which may consists of ...
0
votes
1answer
474 views

Split SQL file with multiple databases in it

I've recently received a SQL-dump file, but it contains multiple databases in it. Is there any tool I can use to easily split this up into multiple .sql files, one per database?
0
votes
1answer
730 views

pass a variable value as an input to an oracle sql file that is being called from a shell script

Wanted to know if it is possible to "pass a variable value as an input to an oracle sql file that is being called from a shell script" I am trying like this, but its not working: SQL file: set head ...
1
vote
2answers
56 views

Finding and extracting immediate characters

I have a file with some SQLs and I want to find out the fields that have cast by using shell scripting. For example, I have a file abc.txt with the below sql SELECT field1,field2,field3,field4,...
0
votes
2answers
616 views

SQLite3 Query storing IP address syntax error

I'm trying to run a sqlite3 query against a small DB to update a table. While the script is more complicated, for testing I set the following variables: DN=123 UP=123 downlocalip=10.1.2.3 ...
0
votes
1answer
583 views

DROP USER IF EXISTS syntax error in MySQL CLI

I use Ubuntu 16.04 with Bash and MySQL Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using EditLine wrapper. I try to create a DB stack for a webapp (WordPress) directly from command line and I share ...
1
vote
0answers
340 views

Referencing dynamically created table names in Create statement written in shell script

I need to write a script to automatically generate a month end report. The generation process involved creating tables in database and then accessing them later in the same script to create another ...
0
votes
1answer
108 views

Running a Python that calls a SQL in BASH W10

Trying to run this Python file python pid_info.py 12345 which looks like #!/usr/bin/env python import subprocess import sys, getopt # add if -b or -e then look for username/email like etc... # ...
1
vote
1answer
29 views

ansi: two fast questions about this term

I'm a little confused about ANSI and sql. Is the ansi/sql relationship the same as posix/unix? Is sql language an ansi standard?
0
votes
2answers
192 views

how to import customers to dolibarr

I have a rough and ready table as: mysql> mysql> show tables; +----------------------+ | Tables_in_businesses | +----------------------+ | 2017july | +----------------------+ 1 row ...
0
votes
1answer
737 views

MySQL Select with function IN () with bash array

How can I do this with an array? (without storing the array as regular variable) VAR='String1 String2 String3' SELECT * FROM db.table WHERE xy IN ( ${VAR// /, } ); not working example: SELECT * ...
0
votes
1answer
41 views

Having trouble with sqlite3 ssh command (I am assuming bad quotes)

The following works great: ssh plxch1035.pdx.xxxxxx.com "sqlite3 /p/hdk/rtl/proj_data/shdk74/fe_data/ipci/ipci.db 'select * from tools'" When I want a specific tool row though: ssh plxch1035.pdx....
3
votes
3answers
261 views

converting insert into to select

I have a file with the following format INSERT INTO table1(field1,field2,field3) VALUES('values1','value2','value3'); INSERT INTO table1(field1,field2,field3) VALUES('other_values1','other_value2','...
3
votes
3answers
174 views

Delete multi-line strings

There have been several questions here regarding replacing multi-line strings using the Unix shell, but I haven't found one that will work in this situation. I am trying to remove keys and ...
0
votes
1answer
42 views

How do I extract a portion of an SQL statement for the purposes of searching and replacing?

I'm using bash shell attempting to do a search and replace. I have a file of lines that look like ... INSERT INTO currency (name, code, symbol) VALUES ('Baht', 'THB', '฿'); ... and I want to ...
0
votes
2answers
2k views

Read mysql column result in awk variable

I am unable to read single VALUE from mysql Query in awk.I am able to read it in bash but not in awk. I want to read the result variable in awk as I want to fire the query only based on some dynamic ...
2
votes
3answers
92 views

How to remove spaces from the line after a given word?

Suppose I have a file.txt; the content of the file is: insert into x values('a ',' b',' c '); insert into x values(' m ',' n ',' p '); I just want to remove spaces from each line after the ...
0
votes
1answer
670 views

How to insert null for missing column? [closed]

I want to write a script that inserts values into a list of tables as follows. Example: insert into TABLE1 ( a,b,c) select a,b,c from TABLE2; But TABLE2 does not have column C, so I want to insert ...
2
votes
0answers
1k views

How to Install and run python and database over busybox

I purchased a a WiFi server terminal which runs Busybox and only comes with a http web implementation which pops up once you connect to the WiFi. I'd like to support for SQL (or some variation) and ...
0
votes
2answers
943 views

Extract table columns from a create table query

I have a .sql file that has a create table query: <<<<< some text >>>>> CREATE EXTERNAL TABLE table_name ( key1 int , key2 ...
1
vote
0answers
25 views

How to make an SQL statement display how many rows it has counted so far?

Suppose there is a table with billion rows, and I issue a select statement as below, SQL> select * from big_table; During the statement execution is it possible to print the number the rows it ...
0
votes
3answers
796 views

How to select on CSV files by R sqldf/data.table/dplyr?

I know the thread How can I inner join two csv files in R which has a merge option, which I do not want. I have two data CSV files. I am thinking how to query like them like SQL with R. Two CSV ...
1
vote
1answer
217 views

Get specific line below grepped line

I have a challenging issue that I am facing below I have the below text in a file: create table "ctronsys".activity_codes ( code_list_id varchar(8), code_id varchar(10), record_type varchar(...
0
votes
1answer
346 views

How to extract one query at a time from an SQL file?

I am trying to extract one query at a time from an SQL file. This is what I have tried index1=1 index2=1 while read -n1 char; do if [[ $char == ";" ]] then SUBSTRING=$(awk 'substr($index1,$...
0
votes
1answer
74 views

Alignment of text in a text file generated by a pl/sql file executed in bash

I want to left-align text in a .txt file generated by a pl/sql query (.sql file) being called inside a shell script, and send the .txt file over an email using email command. The issue is, the text ...
0
votes
2answers
998 views

File input for select statement in shell scipt

I have a text file which has inputs for select statement. sqlplus -s $USERNAME/$PASSWORD@$HOST<<EOF spool $DIRECTORY/UPDATE.xls select acc,cr,dr from count where acc in ***$DIRECTORY/acc.txt**...
1
vote
2answers
390 views

Use a list of strings to replace a sql parameter printing the whole file for each replacement

I have a txt file with string values in a single column : File.txt A B . . . Z I have a sql script with a variable called 'parameter'. script.sql declare @var varchar(255) set @var = 'parameter'...
0
votes
1answer
153 views

fill mySQL database with text file information

I have been using awk and some cisco commands to get information about devices connected to a network, the script connects via telnet to certain device, take the IP, serial number, and the name (...
0
votes
1answer
2k views

Unix variable not able to store sql query output

I am getting some issue when running sql from sqlplus and want to assign the o/p to a Unix variable.The Output is showing correct in log file but not assign to variable. code : PASSWD variable ...
0
votes
1answer
25 views

Having trouble printing out concatenated data after using awk statement

I'm using Amazon Linux, bash shell. I have this statement, which extracts and prints the second row from a file with comma-delimited data ... awk -F',' 'select * FROM {print $2}' myfile.csv I would ...
2
votes
2answers
563 views

Compare two sql output files which have column names and print the difference into another file

I am new to Unix Shell scripting. I need to write a shell script for comparing 2 sql output files (basically in .txt format) which are the outputs of the same sql query (before and after a maintenance ...