Hacker News new | ask | show | jobs
by noirscape 1401 days ago
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).

8 comments

> 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