About SQL
Partly I'm learning SQL for my long-term marketability as a combined
System Administrator / Database Administrator. Mostly I'm doing this
because it looks like knowing SQL might be fun, because I think
relational database engines are just fantastically complex and
therefore interesting.
Little SQL Notes
- Use single quotes around strings.
'string'
- The pattern-matching operator is "LIKE". Versus shell wildcard
filename matching, % matches like *; _
(underscore) matches like ?
... WHERE
passwd.shell LIKE '%/_sh'
- ORDER BY is how you sort the displayed results of a
query. The thing is, you can't ORDER BY on fields that
aren't part of the relation that you project on, even though those
fields should be available at join-time. I don't immediately see why
this is.
Example:
How I'm learning SQL
First, I downloaded the source to "mSQL", a free-to-nonprofits SQL
database. It compiles and installs fine right out of the box on
Linux. You run "msqld" which is the server daemon, and it sits and
listens for connections on a socket; then you run the client "msql" to
interact with the database. Simply typing SQL queries by hand isn't
that much use for transactions though; so it comes with C libraries so
you can embed SQL queries in your C programs.
Someone took those libraries and linked them into a Perl extension
module, so you can connect to mSQL with Perl as well. So learning
Perl and the DBI interface, with which you can connect to any major
database, is better than hogtying yourself to any particular
manufacturer's 4GL. And Perl is probably a better language than any
of those anyway.
So, I'm going to write mSQL programs in Perl for laughs.
Daniel F. Boyd / boyd@csgeeks.org
Last modified: Sun Jun 29 02:15:33 1997