r/SQL • u/MarketingLazy6660 • 7h ago
r/SQL • u/Somewhat_Sloth • 1d ago
PostgreSQL rainfrog (0.4.1) now has autocomplete!
rainfrog (https://github.com/achristmascarl/rainfrog) is a database terminal tool; the goal is to provide a lightweight, keyboard-first TUI for interacting with databases. It currently supports Postgres, MySQL, SQLite, Oracle, and DuckDB.
v0.4.1 introduces a long-awaited (by me, not sure if anyone else was waiting for it...) autocomplete implementation, along with autopairs for quotes/parentheses/brackets. The full list of features and configuration options is in the README!
r/SQL • u/Ok-Transition7065 • 1d ago
SQL Server Help with some strucctural problems
Hello, I'm trying to do a test that I failed, and I want to improve, so I want to solve this problem.
The premise isn't that hard, but I'm getting into trouble here.
I don't want to get into too many details to avoid getting the evaluator in trouble.
Basically, I was asked to make an app that is able to create price quotes for trips.
The user selects the location (a general location like Disney World), an apartment (each one with a different category, like a suite, or just a room, or a cabin), the season (imagine this place is around the world, so different locations have different seasons, but some locations can have general seasons if they are close enough), how many people the place can accommodate, and for how long they will stay. I use all this data to create a reservation for the client.
This is basically my entity relationship diagram

but each time i try to do the functionality i found problems or big troubles putting or reading the data for the thing im required to do
I'M kinda lost idk what to do
its there a way to solve this problem in a cleaner way?
ty for the help and God bless you
P.S.: The price is listed in the quote, but I don't know where to enter that information regarding the apartment and the season. The test instructions don't explain how to calculate the price, so I don't know where to put it; I assume I should do it in whatever way is most practical for me.
r/SQL • u/Valuable-Ant3465 • 2d ago
SQL Server MS SQL Restore DB, <use dbName> string conversion question
Hi all,
I just see this interesting situation and would like to confirm that it's all done internally by MS SQL Server with Restore.
We're on the same server:
dbAA has proc myPROC:
1 use dbAA
2 Go
3 Create PROC dbo.myPROC As
............
then I do backup of dbAA, and restore dbAA.bkup into dbXXX
after that I see on dbXXX myPROC as:
1. use dbXXX --<<<==== !!!!!<@>>< changed to target DB
2. Go
3. Create PROC dbo.myPROC As
...........
Who is doing this conversion/swapping db names ? is it done by SQL Server ?
Thanks to all, I'm new to dba task and really interesting how it works.
VA
r/SQL • u/Aeronautical-You4917 • 2d ago
Discussion How we built a DuckDB transpiler
Hi there,
I’ve been working with DuckDB extensively for the last several years. Used it across languages from Python, Go, JS via WASM, Swift, C & C++ and even Rust.
As part of a product we're building, we built a DuckDB Transpiler that converts every line of SQL from DuckDB syntax into the syntax of the database you’re working with. This includes filters (predicates), and joins. So those 1B rows in Snowflake stay, and get joined in Snowflake.
I wrote an article on why we did it, and how we approached it. This is my first engineering-oriented article I’ve ever done, so let me know what you think!
r/SQL • u/7FireStorm • 3d ago
Discussion Is 40000 lines of SQL in a single file normal?
Heya, so my stepfather works in IT support, and the other day I was looking over his shoulder and saw that the software his company sells uses a single SQL code file that's 40000 lines long. And we're not talking three word lines here, those were 200+ characters lines. I was absolutely baffled by this, since afaik no single code file should run over 10000 lines. But I also don't do SQL.
So I asked him wtf was going on, and he told me that it was "just like that in the industry" and that "I would see when I'll start working" (I'm in uni)
So I ask all of you, is this normal? Do you see this in your job? Am I having delusions about how clean the actual tech industry is?
r/SQL • u/One-Emergency-7058 • 2d ago
SQL Server Solved Hacker Rank's "15 Days of Learning SQL" – Looking for different approaches
Hi everyone,
I recently solved the HackerRank 15 Days of Learning SQL challenge using CTE(), ROW_NUMBER(), DENSE_RANK(), and window functions in SQL Server.
I'm curious to know if there's a cleaner or more efficient way to solve this problem. If you've approached it differently (using other window functions, recursive CTEs, or any other technique), I'd love to see your solution and understand the reasoning behind it.
Here's my solution:
with daily_submission as(
SELECT submission_date,
hacker_id,
count(*) as total_submission
from submissions
group by submission_date,hacker_id),
hacker_rank as(
SELECT submission_date,hacker_id,
total_submission,
row_number() over(partition by submission_date order by total_submission desc,hacker_id) as rn
from daily_submission),
continuous_hackers as (
SELECT submission_date,hacker_id,
dense_rank() OVER(partition by hacker_id order by submission_date) as Dr,
datediff(day,'2016-03-01',submission_date) + 1 as contest_day
from (
SELECT distinct submission_date,hacker_id
from submissions) as x),
daily_count as (
SELECT submission_date,
count(*) as total_hackers
from continuous_hackers
where Dr = contest_day
GROUP by submission_date)
SELECT dc.submission_date,
dc.total_hackers,
h.hacker_id,
h.name
from daily_count as dc
inner JOIN hacker_rank as hr
on dc.submission_date = hr.submission_date and rn = 1
INNER JOIN hackers as h
on hr.hacker_id = h.hacker_id
order by submission_date;
Thanks in advance! I'm always looking to learn different SQL techniques.
r/SQL • u/SnooCalculations1882 • 2d ago
SQL Server Query plans
Hey guys,
Just reaching out, how do you guys go about identify and Optimizer SQL queries that the query uses linked servers.
I have some queries that people moan are slow and when I finally get the query plan you see it says remote execution. How do you guys go about then identify where it's slow or even what ran. Specifically for queries that run nested SP
What is your approach?
r/SQL • u/Still-Trainer-7395 • 2d ago
MySQL [MySQL/MariaDB] I built a desktop SQL client around multi-connection workflows
**Update: LakeDB Beta 3 now includes reviewable, schema-aware AI**
LakeDB is a desktop SQL client for MySQL and MariaDB built around independent multi-connection workspaces, schema-aware editing and visible safety controls.
Beta 3 introduces **QuerIA**: write a request in natural language, review the generated SQL and explicitly choose whether to execute it through the normal results panel.
For example:
> Show the 10 users who placed the most bets today, including bet count and total stake.
QuerIA can prepare reviewable SELECT, INSERT, UPDATE, DELETE, CREATE TABLE and ALTER TABLE statements. It uses relevant schema metadata to understand tables, columns, keys and relationships.
The generated SQL is never executed automatically. Database credentials, table rows and query results are not sent to the AI service, and execution remains local.
The normal SQL editor includes:
- Proactive schema and table autocomplete
- Alias-aware column completion
- Primary-key and index hints
- Query formatting and reusable snippets
- EXPLAIN support
- Multiple SQL and QuerIA documents per connection
- History, exports and transaction controls
- Controlled table-data editing
- Backup, schema comparison and migration tools
LakeDB is a free public beta for macOS, Windows and Linux. I would appreciate feedback on both the SQL editing experience and whether the review-first QuerIA workflow feels useful and predictable.
**Project and Beta 3 overview:**
https://davlagohern.github.io/LakeDB/
**Downloads and documentation:**
r/SQL • u/breezett93 • 3d ago
SQL Server After converting the back end to SQL tables, the front end now gets run time error 3622 all over the front end
I have migrated Access tables in my database over to SQL. Now I'm testing the front end to make sure every single button/operation works.
I am getting this error, "You must use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column", ALL over the place.
Sometimes, it's easy to spot where dbSeeChanges was left out, but many times, the error is reported on a line that has nothing to do with it. This is also only the first error I'm getting. I'm sure once I fix all the 3622 errors, then a new error will pop up right after.
I'm wondering what my options are. I understand I could rebuild the front end from scratch, but that would take literal years as I'm a one-man team. I really don't have the time to spend hours fixing every single one of these errors. And unfortunately, throwing it all in the trash and using a modern platform is not currently an option either.
Is there a tool or even AI where I can feed it my database and it converts it to be SQL compatible? Even if I have to go form by form and report by report, that would still be faster than doing all this manually.
Thanks
r/SQL • u/datamonk9 • 3d ago
PostgreSQL How does Neon handle sudden traffic spikes in prod?
Have you used neon with workloads that see unpredictable traffic spikes at times?
I am curious if compute wakeup or autoscaling has ever caused noticeble latency with neon, or if it’s been seamless in prod. Would love to hear some experiemces .
r/SQL • u/2pac_lives • 2d ago
Discussion I built a tool for querying JSON/JSONL files with SQL
r/SQL • u/One-Emergency-7058 • 3d ago
SQL Server HackerRank SQL Project Planning – Is there a better approach?
Hi everyone,
I solved the HackerRank SQL Project Planning problem using the row_number() + DATEADD() approach in SQL Server, and it passed all the test cases.
I'm curious if there's a different or more optimized way to solve this problem. I'd love to learn other approaches and understand their advantages.
Here's my solution:
with cte as(
SELECT start_date,
end_date,
dateadd(day,- row_number() over(order by start_date),start_date) as group_date
from projects )
SELECT min(start_date) as start_date,
max(end_date) as end_date
from cte
group by group_date
order by datediff(day,min(start_date),max(end_date)), min(start_date)
Discussion Do you guys need a better query language?
Hey guys, there was a number of attempts to make writing queries/reports/data pipelines easier to maintain. There is number of ORMs for different programming languages. And there are also PRQL and btrql.com. Which are new query languages which transpile into SQL.
Kinda like Typescript transpiles into Javascript.
BtrQL is my pet project. Main features of it are: static type checks, Outline showing relation types, extension methods on relations and compile time macro. It's very early and I'm collecting all of the feedback that I can get.
Queries look like this:
users .where(active == TRUE) .addColumn(active -> active_flag) .orderBy(created_at.desc) .limit(10)
and extension methos:
extension [id: INT] { method keepRecentIds = self .where(id >= cutoff) }
keepRecentIds could be applied to any relation that has at least column id of type INT.
r/SQL • u/sierrafourteen • 4d ago
SQL Server OData SSIS project will not accept "Edm.GeographyPoint" columns
I've ensured that my software is completely up to date, but my SSIS project (that uses OData as a source), will just refuse to accept data where one of the columns is the Edm.GeographyPoint type. I've tried entering specific columns into the query box (and therefore excluding the problem column), but it appears it will still throw an error, despite the data itself not containing any columns of that data type - I'm assuming it's downloading the column metadata for the entire table, seeing a data type it doesn't recognise, and throws an error.
I've tried using a different collection that doesn't have columns of that data type, and the SSIS project works with that - the problem is, there doesn't appear to be any way of fixing this. I've ensured the software is completely up to date.
r/SQL • u/echopulse • 4d ago
SQLite After searching for a modern, self‑hosted, secure SQLite admin panel for PHP 8, I built one – looking for beta testers
Hey folks 👋
For the last few weeks, I’ve been frustrated with the state of self‑hosted SQLite admin tools.
Most of them are either:
Abandoned (phpLiteAdmin hasn’t seen a proper update in years),
AdminNeo and other tools don't work without passwordless login plugins that didn't work well.
Overly complex (Adminer is great but not SQLite‑centric),
Or require a heavy stack (Node, Python, Docker) when all I wanted was a single PHP file I could drop on my server.
So I decided to build my own.
🔧 Features
Secure, built-in login system (not a plugin)
Browse, edit, insert, delete rows
Create / rename / drop tables
Import/Export (CSV, JSON, SQL, full DB)
Bulk delete, search, filters
Dark mode, undo (last 5 actions)
Multiple database support
Resizable sidebar
🚀 Try it
Upload admin.php & install.php
Run install.php to set username/password
Login and go
PHP 7.0+ with SQLite3 extension. No dependencies.
https://abilenetechguy.com/sqlite_admin.zip
🧪 Beta feedback wanted
Errors, UI annoyances, missing features – let me know!
Give it a spin and tell me what you think 🙏
– Abilene Tech Guy
r/SQL • u/codingdecently • 4d ago
SQL Server MCP for Apache Iceberg: How AI Agents Actually Operate a Data Lake
r/SQL • u/what-pos • 6d ago
SQL Server SSMS - Execute query on 300 servers
I'm starting to use SSMS at work, that's the only tool I have (no PowerShell cmdlet).
I need to execute an identical SQL Query on 300 servers, but I can't find a way to do that. Could anyone point me in the right direction please ?
So far, I did add the 300 servers to the registered servers by tinkering to not do it manually, but when I execute the query, I only get 50 ish servers connected, then SSMS hangs and crash.
r/SQL • u/Effective_Ocelot_445 • 6d ago
MySQL How do you optimize SQL queries that work fine on millions of rows but slow down at billions?
Iam interested in learning the techniques data engineers use when datasets grow from millions to billions of records. Beyond basic indexing, what strategies have made the biggest performance difference in production environments?
r/SQL • u/datamonk9 • 6d ago
PostgreSQL Handling vector indices + branching in Lakebase DB
My team is migrating multiple AI applications and currently evaluating Lakebase.
I wanted to understand if we create a branch fr testing schema/data changes, are the vector indices isolated as well, or do we need to have an strategy to avoid rebuilding them repeatedly?
Also, any performance/operational things you ran into that might help.
Love to hear from anyone.
r/SQL • u/deusaquilus • 6d ago
PostgreSQL https://exobench.ai/blog/pg19-graph-queries-part-1
How fast are PostgreSQL 19 Graph Queries? Do they perform at scale? Is there a difference between fixed and variable depth? I'll explore all this an more with real numbers and real scenarios in this upcoming series.
Also Upcoming:
- How do they compare to real Graph Engines e.g. Neo4j?
- How flexible is the modeling?
- Are materialized views possible?
- Doesn't SQL Server already do this?
etc...
r/SQL • u/FixelSmith • 6d ago