文件名称:
Head First SQL - Your Brain on SQL.pdf
开发工具:
文件大小: 47mb
下载次数: 0
上传时间: 2019-07-03
详细说明:Your brain on SQL. Here you are trying to learn something, while here
your brain is doing you a favor by making sure the learning doesn’t stick. Your
brain’s thinking, “Better leave room for more important things, like which wild
animals to avoid and whether naked snowboarding is a bad idea.” Stable of contents
Table of Contents ( Summary)
I
ntro
Data and Tables: A place for everything
2 The seleCT Statement: Gifted data retrieval
53
8 DELETE and UPDATE: A change will do you good
119
4 Smart Table Design: Why be normal?
159
5 ALTER: Rewriting the past
197
Advanced SELECT: Seeing your data weith newe eyes
235
7 Multi-table Database Design: Outgrowing your table
281
8 Joins and Multi-table Operations: Cant wee alljust get along?
343
9 Subqueries: Queries Within Qu
10 Outer Joins, Self Joins, and Unions: Newe maneuvers
11 Constraints, Views, and Transactions: T00 many cooks spoil the database 455
12 Security: Protecting your assets
493
Table of Contents(the real thing)
Intro
Your brain on sQL. Here you are trying to learn something, while here
your brain is doing you a favor by making sure the learning doesn 't stick. Your
brains thinking Better leave room for more important things like which wild
animals to avoid and whether naked snowboarding is a bad idea. "So how do you
trick your brain into thinking that your life depends on knowing SQL?
Who is this book for?
We know what you're thinking
Metacognition
Bend your brain into submission
Read me
The technical review team
Acknowledgments
X
table of contents
data and tables
A place for everything
Dont you just hate losing things? Whether it's your car
keys, that 25%off coupon for Urban Outfitters, or your applications
data, there's nothing worse than not being able to keep up with what
you need. when you need it. And when it comes to your applications,
there's no better place to store your important information than in a
table So turn the page, come on in, and take a walk through the world
of relational databases
Defining your data
Look at your data in categories
What's in a database?
Your database viewed through x-ray specs
10
Databases contain connected data
12
Tables up close
13
Take command!
17
Setting the table: the CREaTE Table statement
19
Creating a m
Look how easy it is to write SOL
21
Create the my contacts table. finally
22
Your table
3
Take a meeting with some data types
24
our table. DESCribec
28
You cant recreate an existing table or database!
Out with the old table in with the new
32
To add data to your table you'll use the Insert statement
34
Your database viewed
through x-ray specs
Create the insert statement
37
Think of a database
Variations on an Insert statement
41
like a container that
holds in formation
Columns without values
42
Peek at your table with the selectstatement
43
A七able
SQL Exposed: Confessions of a NUlL
Controlling your inner NULL
Another
NOT NULL appears in DESC
Fill in the blanks with default
Another table
Your sol toolbox
Some other
table of contents
the Select statement
Gifted data retrieval
Is it really better to give than retrieve? When it comes to
databases chances are you'l need to retrieve your data as often than
you'l need to insert it. That' s where this chapter comes in: you'll meet the
powerful SELECT statement and learn how to gain access to that important
information you've been putting in your tables. You'l even learn how to
use WHERE, AND, and oR to selectively get to your data and even avoid
displaying the data that you dont need
Date or no date?
a better select
What the i is th
58
How to query your data types
64
More punctuation problems
Unmatched single quotes
Single quotes are special characters
inSerT data with single quotes in it
68
SELECT Specific columns to limit results
73
SELECT Specific columns for faster results
Combining your querie
80
Finding numeric values
83
mooth Comparison Operators
Finding numeric data with Comparison Operators
Text data roping with Comparison Operators
91
To be or not to be
The difference between ANd and Or
Use is null to find nulls
Im a star
Saving time with a single keyword LIKE
101
The call of the Wild(card)
Selecting ranges using AND and comparison operators
105
Just BETWEEN us.. there's a better way
After the dates, you are either IN
109
or you are NOT iN
More not
Your SOl Toolbox
116
table of contents
dELETE and UPDATE
A change will do you good
Keep changing your mind? Now it's oK! with the commands
you're about to learn-DELETE and UPDATE-you're no longer stuck with
a decision you made six months ago, when you first inserted that data about
mullets coming back into style soon. With UPDATE, you can change data, and
DELETE lets you get rid of data that you don 't need anymore. But we're not just
giving you the tools; in this chapter, you'll learn how to be selective with your nev
powers and avoid dumping data that you really do need
Clowns are scary
120
Clown tracking
121
The clowns are on the move
122
How our clown data gets entered
126
Bonzo, we've got a problem
128
Getting rid of a record with DELete
129
Using our new delete statement
13l
DELETE rules
132
The INSERT-DELETE two step
135
Be careful with your DELETE
140
The trouble with imprecise delete
144
Change your data with UPDate
146
UPDATE rules
147
UPDATE is the new INsErt-delete
UPDATE in action
149
Updating the clowns'movements
152
UPDATEⅴ our prices
154
All we need is one uPDate
156
Your sol Toolbox
158
Do we scare you?
table of contents
smart table design
Why be normal?
You've been creating tables without giving much
thought to them. and that's fine they work You can SElECT
INSERT, DELETE, and UPDATE with them. But as you get more data,
you start seeing things you wish you' d done to make your WHERE
clauses simpler. What you need is to make your tables more norma
Two fishy tables
160
A table is all about relationships
164
ato
data
ate
data and your tables
170
Atomic data rules
171
Reasons to be norma
The benefits of normal tables
Clowns arent normal
Halfw
INF
177
PRIMARY KEY rules
178
Getting to NORMaL
181
Fix
1g
able
182
The CREaTE table we wrote
183
Show me the meney
Time-saving command
The CREATE Table with a PRIMArY Key
1.2.3... auto incrementally
188
Adding a PRIMARY Key to an existing table
192
ALTer TaBLE and add a PRImary Key
193
Your Sol Toolbox
194
Wait a second, I already have a table full of data
you can t seriously expect me to use the DROP TABLE
command like i did in chapter 1 and type in all that data
again, just to create a primary key for each record
table of contents
ALTER
Rewriting the Past
ver wished you could correct the mistakes of your past?
Well, now is your chance. By using the ALTER command, you can apply all the
lessons you ve been learning to tables you designed days, months even years ago
Even better, you can do it without affecting your data. By the time you're through
here, you'l know what normal really means, and you'll be able to apply it to all your
tables, past and present
We need to make some changes
198
Table altering
203
Extreme table makeover
Renaming the table
We need to make some plans
Retooling our columns
Structural changes
209
alter and change
Change two columns with one sol statement
Ouick! DROP that column
215
a closer look at the non-atomic location column
Look for patterns
a few handy string functions
224
Use a current column to fill a new column
229
How our uPdate and set combo works
230
It's time to turn your tired old
Your sol toole
232
hooptie table into a date magnet
and take it to a level of table
pimpification you never knew existed
table of contents
ad vanced select
Seeing your data with new eyes
It's time to add a little finesse to your toolbox you already
know how to select data and use Where clauses. but sometimes you need
more precision than SELECT and WHERE provide. In this chapter, you'll learn
about how to order and group your data, as well as how to perform math
operations on your results
Dataville video is reorganizing
236
Problems with our current table
237
Matching up existing data
238
Populating the new column
239
UPDATE with a Case expression
242
Looks like we have a problem
244
Tables can get messy
We need a way to organize the data we select
250
Try a little ORDER BY
253
ORDER a single column
254
ORDER with two columns
257
DATAVILLO
ORDER with multiple columns
An orderly movietable
Reverse the order with desc
261
The Girl Sprout cookie sales leader problem
263
ITIT
SUM can add them for u
265
SUM all of them at once with group by
266
AVG with GroUP BY
267
miN and maX
COUNT the days
SELECT DISTINGT Values
271
LIMIT the number of results
274
liMiT to just second place
Your SOl Toolbox
278
XV
table of contents
multi-table database design
Outgrowing your table
Sometimes your single table isn 't big enough anymore.
Your data has become more complex, and that one table you've been using just
isn't cutting it. Your single table is full of redundant data, wasting space and
slowing down your queries. You've gone as far as you can go with a single table
It's a big world out there, and sometimes you need more than one table to
contain your data, control it, and ultimately, be the master of your own database
g Nigel a date
All is lost . But wait
DO
Think outside of the single table
The multi-table clown tracking database
The clowntracking database schema
How to go from one table to tv
Connecting your tables
Constraining your foreign ke
305
Why bother with foreign keys?
306
CREATE a table with a FOREIgn Key
307
Relationships between tables
Patterns of data: one-to-one
Patterns of data: when to use one-to-one tables
activity_id
Patterns of data: one-to-many
uclivily_id
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.