Hacker News new | past | comments | ask | show | jobs | submit login

If you exploring a set of tables you have never touched before, it really neat if you could just type in:

FROM tablename t SELECT t.<press tab>

and some form of autocomplete mechanism, either prefills all the column names from table "t" or suggests the list of columns and/or types associated with it.

This is much better than having to: 1. Run a SELECT with LIMIT statement just to get an idea of the layout. 2. Point and click through the IDE treeview.

Honestly, I don't think it helps a whole lot beyond this functionality, but I can see why folks who are accustomed to thinking in functional pipelines (from -> select -> map -> filter -> collect) can prefer this way of querying.

I think PRQL is one attempt at building something this way.[1]

[1]. https://github.com/prql/prql




In SSMS and almost certainly many other SQL editors Intellisense works on the select list as soon as you have a working from clause, the only caveat being you can’t autocomplete columns reading when writing a statement purely left to right.

But I think that’s not a big deal at all, and the SQL approach has a certain advantage in putting the type of action (select/update/delete/drop etc) front and centre, which is really quite helpful.


SELECT FROM widgets VALUES id, factory_origin_id, frobbable_knobs


DESCRIBE TABLE is a command that pretty much does exactly this (explain what a table contains) and it's a part of MySQL.

If you use PostgreSQL then you can use \d instead.

I'm sure the other RDBMSes have their own equivalent (except for maybe SQLite but if you're using SQLite outside of toy environments or hobby projects, you're doing it wrong).


> except for maybe SQLite

.schema

> if you're using SQLite outside of toy environments or hobby projects, you're doing it wrong

That's an uninformed statement. SQLite is extremely solid production quality code. Of course it's not the universally applicable database solution, nothing is. Sometimes you need Cassandra or its kind, often MySQL|Postgres, other times SQLite is the correct answer.


It's kind of funny to see a claim that the most widely deployed database in the world is useful only for toy projects.

https://www.sqlite.org/mostdeployed.html


I guess there are more toy projects than serious ones.


Yeah, I mean MacOS, Android, iOS, Chrome, Firefox ... all typical toy projects.


sheesh lets hope there are no vulnerabilities in there


SQLite has an 608 times more lines of code for tests than the original code![0] I’d wager it’s the highest test/production ratio there is.

[0]: https://www.sqlite.org/testing.html


Most of those tests are generated. It's wrong to focus on this metric IMO.


Auto generated or not, the point being made, in regards to @bot41's comment, was that SQLite is thoroughly tested.


It's well tested, but that's still not a guarantee that there are no security issues. Latest acknowledged CVE bug is a month old: https://www.sqlite.org/cves.html


> if you're using SQLite outside of toy environments or hobby projects, you're doing it wrong

https://www.sqlite.org/mostdeployed.html

> Every Android device

> Every iPhone and iOS device

> Every Mac

> Every Windows 10 machine

> Every Firefox, Chrome, and Safari web browser

> Every instance of Skype

> Every instance of iTunes

> Every Dropbox client

> Every TurboTax and QuickBooks

> PHP and Python

> Most television sets and set-top cable boxes

> Most automotive multimedia systems

> Countless millions of other applications

Look at all those toys.


everyone is doing it wrong :(


Not necessarily.

If you ponder the importance of proper (robust, reliable, dependable) data management for data that keeps nuclear plants going, for farmaceutical research data, for anything happening on the financial markets, for medical records, for data concerning payroll and the like, etc. etc. then you might appreciate that all the stuff mentioned in the list is indeed really "just toys".


You're missing the point: until you have typed the FROM TableName t in your IDE, SELECT t.<press tab> can not do autocompletion. That has nothing to do with whether SQL supports querying metadata (the ANSI portable way would be through INFORMATION_SCHEMA btw, not DESCRIBE). It's a consequence of the brain not responding to think-ahead queries by the IDE.


This may be true, but you've missed the point that this is about aiding autocompletion while you're writing the query the first time.


Couldn’t the IDEA understand

FROM table SELECT

And when done switch the code to be correct?


Every RDMBS has this, including SQLite.


in sqlite3 it is .schema


SQLite absolutely has production level applications, it's much more than a toy.

https://www.sqlite.org/whentouse.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: