Server Side Programming: by Dr. Babaousmail Hassen Lecturer at Binjiang College of NUIST
Server Side Programming: by Dr. Babaousmail Hassen Lecturer at Binjiang College of NUIST
1
Modifying Stored Data
2
Modifying Stored Data
So, for example, if we wanted to change the date on the joke we
entered above, we have to use the following command:
This next command, for example, changes the date of all entries that
contain
the word “chicken”:
To delete all chicken jokes from your table, you’d use the following
query:
4
Operator Name Example Description
(If Applicable)
= equality customerid = 3 Tests whether two values are equal
> greater than amount > 60.00 Tests whether one value is greater
than another
< less than amount < 60.00 Tests whether one value is less than
another
>= greater than or amount >= 60.00 Tests whether one value is
equal greater than or equal
to another
<= less than or equal amount <= 60.00 Tests whether one value is less than
or equal to another
!= or <> not equal quantity != 0 Tests whether two values are not
Useful IS NOT n/a address is not
equal
Tests whether field actually
contains a value
Comparison NULL
IS NULL n/a
null
address is null Tests whether field does not contain
a value
Operator for BETWEEN n/a amount between
0 and 60.00
Tests whether a value is greater
than or equal to a minimum value
and less than or equal to a maxi-
WHRE Clauses mum value
IN n/a city in Tests whether a value is in a
("Carlton", particular set
"Moe")
NOT IN n/a city not in Tests whether a value is not
("Carlton", in a set
"Moe")
LIKE pattern match name like Checks whether a value matches
("Fred %") a pattern using simple SQL pattern
matching
NOT LIKE pattern match name not like Checks whether a value doesn’t
("Fred %") match a pattern
REGEXP regular expression name regexp Checks whether a value matches a
5
regular expression
Summary of Privilege and
related Commands
6
1. Privileges for Users
Table 8.1 Privileges for Users
Privilege Applies To Description
SELECT tables, Allows users to select rows
columns (records) from tables.
INSERT tables, Allows users to insert new rows
columns into tables.
UPDATE tables, Allows users to modify values in
columns existing table rows.
DELETE tables Allows users to delete existing table rows.
INDEX tables Allows users to create and drop indexes on
particular tables.
ALTER tables Allows users to alter the structure of existing
tables by, for example, adding columns,
renaming columns or tables, and changing
data types of columns.
CREATE databases, Allows users to create new
tables databases or tables. If a
particular database or table is
specified in the GRANT, they can
only CREATE that database or table,
which means they will
have to DROP it first.
DROP databases, Allows users to drop (delete)
tables databases or tables.
7
2. Privileges for Administrators
8
3. Special privileges
9
GRANT & REVOKE Command
The GRANT command is used to give privileges to a user. The opposite of GRANT
is REVOKE. It is used to take privileges away from a user.
10
Examples Using GRANT and
REVOKE
To set up an administrator, you can type:
This grants all privileges on all databases to a user called Fred with the password
mnb123, and allows him to pass on those privileges.
If you don’t want this user in your system, so go ahead and revoke him:
11
To set up a regular user with no privileges:
And later, when she doesn’t need to use the database any more, we can revoke her
privileges:
mysql> revoke all
-> on books.*
-> from sally;
12