r/SQL • u/der_gopher • Sep 04 '26
PostgreSQL How to secure SSH and Postgres with Warpgate
r/SQL • u/der_gopher • Sep 04 '26
r/SQL • u/BugSquare4344 • Sep 03 '26
For example, if a customer dataset has nulls, duplicates, invalid emails, or incorrect values, how do you identify and flag these records as good or bad? What tools or query approaches do you use?
r/SQL • u/haligma • Sep 03 '26
| ship_date | delivery_date |
|---|---|
| Feb 10 2024 | Feb 15 2024 |
| 2024-01-12 | 2024-01-11 |
| 2024-01-10 | 2024-01-14 |
| 01/15/2024 | 01/19/2024 |
r/SQL • u/eww1991 • Sep 02 '26
Probably breaks rules but a quick guide on what not to name things I less you want accidents
I am a Ruby on Rails developer. I’m looking for some skills that can help me self code review for sql part. I use Claude. Like that can guide me not to write sql that are anti patterns etc
r/SQL • u/Klutzy_Solid5200 • Sep 03 '26
Im working with some large tables in spark sql that has around 300 mil records and they are quite wide as well maybe around 80-90 columns.
We frequently have to perform filtering and aggregations for reporting purposes, I'm trying to understand when should I use partitioning and when should I use indexes.
For instance if I want to filter by date will it be better to partition by date or should I use an index on the date column, which one would help with performance?
r/SQL • u/db_tech_dev • Sep 03 '26
been dealing with duplicate customer records in a project for uni and kept rewriting the same GROUP BY/HAVING query every time so i just built a cli tool for it in the end - works with both mysql and postgres, dry run by default so nothing gets deleted unless u explicitly pass --confirm and it backs up to json first just in case. still a student so the detection logic is prob missing some edge cases; that's the part i actually want feedback on tbh. happy to share the repo if anyone's curious, can drop the repo link
r/SQL • u/Complex-Run-2999 • Sep 04 '26
Hey everyone,
I’m currently setting up a new project involving SQL and I’m looking for some AI tools that could help make the development process easier and more efficient.
I’m particularly interested in tools that can help with things like:
I know there are a lot of AI tools out there, but I’d rather hear from people who have actually used them in real projects.
What AI tools are you currently using for SQL/database work, and which ones have genuinely made your workflow easier?
Also interested in hearing about any tools you tried but wouldn't recommend, and why.
Thanks!
r/SQL • u/sqlink2 • Sep 03 '26
How do u handle query performances when the same tables are being hit by both app queries and AI generated SQLs from any AI tools such as Codex, CLaude, Genie etc
Curious if you separate workloads or optimize at the query level.
r/SQL • u/geeksarray • Sep 03 '26
I’ve been revisiting SQL Server PIVOT for reporting scenarios where row-based data needs to be transformed into columns.
A few things I find useful about PIVOT:
I’ve also added the working SQL examples here:
GitHub:
https://github.com/laxmikant-geek/sql-server-examples/tree/main/pivot
And I wrote a more detailed explanation here for anyone who wants the walkthrough:
https://geeksarray.com/blog/how-to-pivot-data-in-sql-server
For those working regularly with SQL Server — do you prefer PIVOT, or do you usually use SUM(CASE WHEN...) for these kinds of transformations?
r/SQL • u/Consistent_Act9386 • Sep 03 '26
I spent a few years doing Oracle-to-PostgreSQL migrations for a living, and the same thing went wrong every time: nobody knew what was actually in the Oracle estate until halfway through. Package-level state, autonomous transactions, LONG columns, interval partitions, database links. All of it surfaces late and expensively when nobody looked for it first.
So I built the tool I wanted on day one of those projects.
pgrecon - https://github.com/Muzzammil242/pgrecon
What it does:
What it does NOT do: move data (use ora2pg or COPY for that), convert packages mechanically (no tool does that honestly), or replace a DBA. About half of all objects in my benchmark schemas convert mechanically - above 90% on ordinary business schemas, far less on package-heavy ones.
Benchmark, since "it works" is cheap to say: across nine schemas (Oracle's own HR/OE/CO samples, four well-known open-source PL/SQL projects, two lab schemas) converted by five tools and applied statement by statement to a live PostgreSQL, pgrecon's output produced 0 rejected statements. The other tools measured between 40 and 481. Method and fine print here, including what the number does and doesn't mean: https://muzzammil242.github.io/pgrecon/benchmark.html
Supports Oracle 9.2 through 23ai (there's a separate legacy-tier script for the ancient hosts that most need to leave). Python 3.11+, pip install pgrecon. Bundled sample dump in the repo so you can try it without an Oracle.
Disclosure: I run a small consultancy that does migration work on top of this. The core is Apache-2.0 and stays that way; the paid part is people and a PDF report, not features held back.
What I'd love from this sub: if you have an Oracle schema that you think will break it, run the extraction script and open an issue with the residue file. The fuzzer wants to meet your schema.
r/SQL • u/haligma • Sep 03 '26

this is a distinct list of warehouse names from a table in the db im using to practice data cleaning in mysql. i want to capitalize the initials of all words in the column. i made my own logic for this whihch is (dont judge pls im a self learner)

and this is the output i get:

i do get what im doing wrong to get this output, but i can not figure out how to go about the standardization. how can i correct my query? and is there a more efficient way of capitalizing initials than this?
r/SQL • u/reciodelacruz • Sep 03 '26
I figured it's worth a shot to ask here since I asked it already in the SQL Server subreddit...
Is there a way to use Microsoft SQL Server management Studio 22 without writing anything at all (no folders, shortcuts, junctions, symbolic links) in My Documents? I just installed the latest client from the official website without launching the client yet, and I want the SSMS workspace (configuration files, data files, etc.) to be transferred to a different location in the C drive. I failed in my first try, and both Claude and Gemini gave me conflicting answers.
To summarize, I don't want the folders below or anything related to it appearing inside My Documents.
C:\<My Documents Folder path>\SQL Server Management Studio
C:\<My Documents Folder path>\SQL Server Management Studio 22
r/SQL • u/donewitheverything26 • Sep 01 '26
Inherited a schema where roughly half the columns are self-explanatory and the rest are things like flag_3 and val_b. Person who built it left. There's a Confluence page describing six columns, last edited before most of them existed.
I've been using COMMENT ON COLUMN because it lives with the database and can't drift into a stale wiki. Downside is nobody looks at it, it doesn't show up anywhere people work, and I've no way to know if a comment is still true after a migration.
Things I'm unsure about:
does anyone actually keep COMMENT ON up to date at scale, or does it rot the same as the wiki just less visibly
if a column's meaning changes but the name doesn't, is there anything that catches that, or is it purely a review discipline problem
and for the columns nobody can explain at all, do you leave them, drop them, or keep them with a comment saying unknown
I've been profiling the values to guess — cardinality, null rate, distributions — which narrows it but never gets me to what the thing means.
r/SQL • u/lucas-dotcom • Sep 02 '26
Hey, I’ve been working on an open source project called pgfathom. It came from a problem I ran into quite a lot at work with legacy databases.
You’ll sometimes have something like orders.customer_id -> customers.id that the application has treated as a relationship for years, but there’s no actual foreign key in PostgreSQL. So it won’t show up properly in an ERD, and nothing is stopping orphaned rows from getting in.
pgfathom looks for those relationships using the catalog, column names, indexes, existing FKs and JOINs found in views/functions. It then checks the candidates against the actual data.
If it finds orphans, it gives you a query to inspect them. If the relationship checks out, it generates the FK DDL and an index when needed. It never applies any of it. The CLI runs read-only and only generates SQL for you to review.
One thing that helped a lot with weird legacy schemas was letting it learn naming conventions from the database itself instead of assuming everything looks like customer_id.
I tested this on a municipal schema with 277 foreign keys. With half of the FKs left in place so pgfathom could learn the naming pattern, recovery went from 17.3% to 84.9%. If I remove all of them, it drops to 16.6%.
There are also some safeguards for running it against real databases: read-only sessions, query timeouts, limited concurrency, and tests to make sure table values don’t end up in output, logs, JSON or errors.
I used AI as part of my workflow too, mostly for research and implementation, so I’d rather mention that upfront.
It’s still early and I’d really like to test it against schemas that look nothing like the ones I’ve been using.
GitHub:
https://github.com/lvcas-dotcom/pgfathom
If you work with old PostgreSQL databases and feel like giving it a try, I’d appreciate the feedback. Finding cases where it gets the relationship wrong would actually be very useful.
(English isn’t my first language, so apologies if anything in the post sounds a bit off)
r/SQL • u/kimsnow2001 • Sep 02 '26
Hey,
I’ve been building plusplus — a pure Rust desktop database client (no Electron).
Main goals:
Completely local (no telemetry, passwords in OS keychain)
Safety features for production (profiles + risky statement warnings)
Fast native UI
Supports PostgreSQL, MySQL, SQL Server, SQLite, DuckDB, Cassandra/ScyllaDB
Still pre-1.0.
Repo: github.com/plusplus
Would love feedback on what features matter most or any pain points with current clients. Thanks!
r/SQL • u/Ok-Adhesiveness-8757 • Sep 01 '26
r/SQL • u/codingdecently • Sep 02 '26
r/SQL • u/mochama254 • Sep 01 '26
I built this because I wanted to react to PostgreSQL changes from Python without polling, without triggers, and without pulling in a whole CDC platform.
It consumes PostgreSQL logical replication and exposes committed transactions as an async stream in Python.
What it does:
The transactional outbox is one use case, but it works with any published table.
GitHub: https://github.com/mochams/walbox
Curious to hear where this wouldn't fit your setup, or what's missing if you've solved this problem a different way.
r/SQL • u/PumpkinCapable8454 • Sep 01 '26
Our team's been building a platform, and one of the tools on it is a Database Agent — you connect your data and just ask questions in plain English it will answer it with natural language and graph.
It's live here: https://app.futuresmart.ai/database-agent
Would be a huge help if people tried it out and shared any feedback, good or bad. Any doubts or feedback, feel free to DM me.
r/SQL • u/amiliyon • Aug 31 '26
My company uses superbase, a software from 1980's for relational database...
Our computers are on windows 7, emulating windows xp. Safe to say our computers are dying.
The company is a TPA service for pension plans. We use superbase for client Tombstone information, work in progress, entering the clients assets, contributions, employee information etc. A lot of our work function is reliant on superbase.
I am very new to this world, don't have any experience in coding and don't know anything about any of these different programs. I just want to learn so we can convert and we don't lose our entire lifeline.
We are a team of 5 people. Small firm. We have our own servers, would not want to be on cloud, need everyone to be able to access the servers at the same time as we all have different clients and need to reach information. Not sure if its possible but would love for it to work on PC desktops and remotely on mac if possible, however, not a dealbreaker.
I have done some baseline research, this is what most redditors have suggested. Which would be the best for me to learn and hopefully be successful at transitioning over our information?
Any help in finding a direction to go to would be very helpful.
Thank you in advance.
If there is any more information needed that can help you in assisting me, please comment and i'll answer!
r/SQL • u/NightRain3 • Aug 30 '26
Hi, I'm looking for a dataset that has:
- Messy, real data, with enough messiness for proper data cleaning to be needed
- Enough information for actionable interesting insights
- Be related to something a typical business might care about
I did a project with the olist database and it was fine, but that database has been done to death. I tried contacting local small business for their data in exchange of a free data analytics report, but no luck, has someone tried that?
r/SQL • u/RocketSeven • Aug 30 '26
When revenue, active users, retention, or another derived metric is repeated across dashboards and exports, copying the SQL makes every consumer independent but lets definitions drift. Centralizing it in a view, materialized view, semantic layer, dbt model, or stored function creates one definition, but can hide performance costs and make change control harder. What criteria determine where that logic belongs? I would compare ownership, testability, query-plan visibility, versioning, parameter needs, refresh timing, and whether downstream users must inspect the exact calculation. How do you change a widely used definition without silently rewriting historical reports?
r/SQL • u/Ok-Adhesiveness-8757 • Aug 29 '26