All Questions

0
votes
1answer
9 views

SQL operators Doubt

I have a doubt about SQL. Sometimes is necessary to have some sort of ifs in queries, however, there are no ifs in SQL right? So it seems that we should handle these cases with logic operators but I'm ...
0
votes
0answers
6 views

How do I see the mysql status message in bash stdout over ssh?

If I'm passing a command to mysql in bash via ssh: mysql --defaults-file=~/.my.cnf -e "SELECT orderdate FROM marketdata LIMIT 1;" I see the following output: +------------+ | orderdate | +--------...
1
vote
2answers
18 views

Converted a Scalar function to a TVF function for parallel execution-Still running in Serial mode

One of my query in was running in serial execution mode after a release and i noticed that two new functions were used in a view which is referenced in the LINQ to SQL Query generated from the ...
0
votes
0answers
5 views

How to restore the missing mysql db schema?

My DB schema is missing/deleted by someone without my knowledge from ASW EC2 windows machine. Seems some unauthorized user entered into the system illegally and did something. Since I can find some ...
0
votes
0answers
14 views

pivot vs multiple columns

I have a table that I've been tasked to look at for optimization (both for entering data through stored procedure, and for views based off the table). The table has (currently) 115 columns, 2 make up ...
0
votes
1answer
9 views

Oracle Data Pump imported table, some columns not selectable

Imported a table into Oracle 12g using data pump. Some of the columns, though present in the table as shown by describe, cannot be selected but they show up in select *. Cannot select them ...
-1
votes
0answers
8 views

removing value and adding in percent of total column

‘Table_1’ ‘Date’ - Date format dd/mm/yyyy ‘Campaign_Id’ -- Integer Variable ‘Campaign Name’ -- Categorical Variable ‘Conversions’ -- Continuous Variable ‘Device’ -- Categorical ...
0
votes
0answers
10 views

Is it possible to setup MySQL replication through ProxySQL?

We currently have replication working through haproxy so that if a node goes down replication continues with one of the other nodes. We're trying to completely replace haproxy with proxysql. Due to ...
0
votes
1answer
7 views

GCP MySQL query logging

I have a managed MySQL instance on GCP. Where would I find a query log? Is this something I need to enable first somewhere? I have read their documentation ( https://cloud.google.com/sql/docs/mysql/...
0
votes
0answers
27 views

My Temp db is full [duplicate]

What to do when tempdb is full ? I would like to know if tempdb has become full and what to do if you can't truncate the log? I want to understand the process why you can't truncate it.
1
vote
1answer
19 views

Why Subquery do not filter the result in multiple Subquery

This is Query (skipped selection for simplicity and also it work perfect): SELECT * FROM (SELECT a.striker FROM ball_by_ball a LEFT JOIN batsman_scored b USING (...
1
vote
1answer
13 views

Random row selection but with distinct values for a subset of columns

I have a table that looks like this : Key1 | Key2 | Key3 | Data | -----|------|------|-------| 1 | 1 | 1 | a | 1 | 1 | 2 | b | 1 | 2 | 1 | c | 1 | 2 | ...
0
votes
0answers
7 views

Windows Application MySQL Error Log Activity

I have a MySQL DB that has a publicly exposed port w/ limited IPs. I started getting errors in my Windows Application Error Log with Source=MySql and EventId=100. They are all some form of IP ...
-1
votes
0answers
14 views

create unique index

I am working on working hours data and facing issue for people working in night shifts. I am trying to create unique index according to alias and timestamp of badge swipe on the reader. An example of ...
5
votes
2answers
165 views

Is it possible for SQL statements to execute concurrently within a single session in SQL Server?

I have written a stored procedure which makes use of a temporary table. I know that in SQL Server, temporary tables are session-scoped. However, I have not been able to find definitive information on ...
1
vote
2answers
43 views

Query takes 10+ minutes to execute

I'm supposed to find out why this query takes more than 10 minutes to execute. Things is SQL is not my strong suit. I know it has to do with all the group by in part... But what approach am I supposed ...
3
votes
2answers
29 views

Merge Only Events that Start immediately after the Previous Event without any Gap

How can i merge only the dates occur subsequently.? (i.e, The Next Event begins immediately after the previous event completed). Here, we need to consider some other Columns also for getting the ...
0
votes
1answer
15 views

SQL Job Agent Service Account - Access is denied to run Powershell

I am trying to run a PowerShell script via the command line via SQL Job. "C:\Windows\System32\WindowsPowerShell\v1.0" "C:\Test\TestScript.ps1" I am running the SQL Job from a SQL Server 2008 R2 ...
0
votes
1answer
11 views

Multiple inserts using select row and variable combination with one SQL statement

I'm working with SQL 2008 R2 and have a need to find a specific row in a table that has three fields and then insert multiple rows into the same table with each insert using two values from the found ...
2
votes
1answer
28 views

How can you have a Buffer cache hit ratio of 100% with PLE of 103? [duplicate]

I found What does a "Buffer cache hit ratio" of 9990 mean? (I was getting result of 9000+ from a blog that was wrong) and used the solution by LowlyDBA/Denis Gobo combined with the PLE ...
0
votes
0answers
15 views

What database should I use locally if I'm going to use Aurora Serverless?

I'm planning to use Aurora Serverless in QA/PROD and then a docker container for running a compatible engine locally. Should I use MariaDB 10.0 or MySQL 5.6? Database need is low, we're not doing ...
1
vote
1answer
20 views

Overlap of group of scripts

I have a group of scripts set to run in a certain order, but sometimes I find the group running long and overlapping into the next group run. Is there a way to prevent that? group.sh: script1.sh &...
1
vote
0answers
19 views

How to setup encryption on a column that joins two tables in two different databases

What is the best method to encrypt a column that exists in two tables (BUID) in two different database on a 2012 server, at the end should be able to join on the encrypted columns between two tables ...
5
votes
1answer
231 views

Why doesn't SQL Optimizer use my constraint?

I want to create a table with a NOT NULL bool column. I use TINYINT with CHECK constraint BETWEEN 0 and 1. The constraint is new and thus trusted Now I would expect that SQL optimizer now knows that ...
1
vote
1answer
16 views

Azure SQL Server - Cannot get rid of the sort operator

I'm using Azure SQL Server (Microsoft SQL Azure (RTM) - 12.0.2000.8 Apr 3 2019 13:27:00 Copyright (C) 2019 Microsoft Corporation), Premium tier 4 (500 DTUs). Query: offer progress has a history ...
0
votes
1answer
19 views

mysql - can a slave have a different primary key than the master?

I have a table with PRIMARY KEY (`id`) and I want to change it to PRIMARY KEY (`username`, `id`). These columns are defined as: `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `username` ...
10
votes
3answers
501 views

What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?

Currently, we have an existing database and application that is fully functional. I do not have the ability to change the architecture at this point. Today, each table in the database has an "...
3
votes
2answers
99 views

Run Powershell Script From Agent As Administrator

I need to recycle an AppPool in IIS on my server when the SQL Server Service starts. The route I am taking is to have a startup stored procedure which runs an Agent job that has a Powershell job ...
1
vote
0answers
16 views

view current session roles for another session

In Oracle, I can view the currently set roles for my current session using the query SELECT * FROM SESSION_ROLES. Is there any way that I can see this information for another session?
0
votes
0answers
13 views

deadlock when transaction is waiting for itself

Sypnosis: percona-server 5.7.12, sometimes deadlocking Am I right interpreting this output in a way that transaction 2 is waiting on itself ? And, if yes - why ? ------------------------ LATEST ...
0
votes
1answer
26 views

Restart my primary server with Log shipping

I have configured log shipping with 20 minutes for backup, copy and restore, if i need to restart my primary server. do i need to stop All Jobs(Backup, copy and restore). Please advise. Regards ...
1
vote
1answer
44 views

I want to change to Dynamic SQL Query instead of CASE statement

I have two tables as below and description is given in below Employee table id EmployeeID departmentid department1 department2 department3 1 300 100 IT Finance ...
0
votes
0answers
13 views

Quiz System Database Schema

I want to create a database schema for quiz system which is little different from the rest of the typical schema(s). As we are all aware of the entities involved in it which are therefore Quiz-type(...
2
votes
1answer
14 views

How to allow connection for edb database in Postgres

By mistake we have executed disallow connections for all databases after that we are not able to connect any of the database, see below for reference: Executed Query: edb=# update pg_database set ...
0
votes
0answers
18 views

How can I import table records in HeidiSql?

Im using HeidiSQL and I have imported database from another one. All table structures are imported but not records. I want to import all records for all tables. I have tried to import records for one ...
3
votes
2answers
53 views

SQL Server Internal Memory Error

I am using SQL Server 2016 Standard Edition that shows the following errors on DBCC CHECKDB and also on updating statistics. MAX Memory set at 215GB from 244GB x1e.2xlarge AWS EC2 There are around ...
1
vote
0answers
17 views

sqlite Json grouping json_each

I want to generate json grouping users by year. I have got a "user" table in sqlite with the following columns: date name surname value I would like to create a JSON with the following structure: ...
0
votes
1answer
15 views

MongoDB failed to start after adding keyFile config

I have issue with mongod service after adding keyFile in config. I follow instruction from here : https://docs.mongodb.com/manual/tutorial/deploy-replica-set-with-keyfile-access-control/ after adding ...
0
votes
0answers
9 views

Unable to view MySQL db stored procedure

We have many stored procedures created with SQL SECURITY DEFINER by user A Now user B is responsible for maintaining some of the stored procedure. However user B is unable to view/update the stored ...
0
votes
0answers
32 views

Writing CSV directly to a BYTEA column from PostgreSQL tables

Assuming these two tables: CREATE TABLE data (day DATE, kpi INTEGER); CREATE TABLE reports (csv BYTEA); Is it possible to (pseudocode): INSERT INTO reports (csv) (SELECT to_csv(SELECT day, kpi FROM ...
0
votes
0answers
28 views

how to copy table data into different table structure in postgresql

My requirement is to copy data from one table of old database to new database, the problem is the new database have few different relation and structure compared to old database, how can I copy data ...
1
vote
2answers
34 views

Can a user with readonly access change SQL server settings

Database administration is not a strong point of mine, and I was wondering if a user with read only access can change the server settings. In their query I can see this at the beginning: SET ...
0
votes
0answers
7 views

How to reset Maintenance User password in Replication Server version 15.7.1

I am going to reset a Sybase ID (abc) in my primary data server (pubs1). This ID abc@pubs1 is used as my maintenance user when I setup Replication Agent for pubs1 in my replication server. If I am ...
0
votes
1answer
29 views

How do I measure performance of a single sql execution in oracle

I need to measure the duration of individual sql executions in Oracle DB. I have the following query but it has two major problems. SELECT instance_name, host_name, sql_id, sql_fulltext, ...
0
votes
0answers
4 views

Search path for DMS postgres 10 wrapper functions

I'm setting up DMS to perform replication from a non-RDS database. After running the suggested code to create wrapper functions, I'm finding our migrations are breaking with errors that indicate ...
1
vote
1answer
17 views

Is there any way to find information of index fragmentation, Statistics information with the help of system tables in SQL Server

I am working on a report which will give information for different segments like blocking process, slow running queries, disk space etc. I also want to add one more segment where I can get information ...
0
votes
0answers
22 views

PostgreSQL 11: how to partition 1000 tenants

Setup We have a multi-tenant app that has about 1000 customers more or less. When a customer churns we delete all their data after a period. We have a few tables that are pretty big and we're ...
-2
votes
1answer
21 views

Azure SQL Server - big query choosing bad execution plan [on hold]

I'm using Azure SQL Server v12 and I have big, complex query that runs ok but when I add more joins, it doesn't matter which table I'm joining to, it gets super slow. The important thing to point out ...
10
votes
1answer
633 views

If a VARCHAR(MAX) column is included in an index, is the entire value always stored in the index page(s)?

I'm asking this out of curiosity, being inspired by this question. We know that VARCHAR(MAX) values longer than 8000 bytes are not stored in rows, but in separate LOB pages. Subsequently retrieving a ...
0
votes
0answers
17 views

Query using up all temp disc space - but only on one server

I've run into a strange situation where a query uses up all available disc space on one server (and then crashes, when there is no space left), but not on the other, and I'm not sure how to correct ...

15 30 50 per page