12
Mysql.
..
2 40 01 01
__ ____________
1.1 , , .
2.1
2.2 :
IBM PC.
3.1
3.2 MySQL,
3.3
3.4
3.5
, create domain. , . , , , .
:
Create domain <name_domain> as <data_type>
[Default {litaral | Null | User}]
[Not null] [Check (<dom_condition>)];
Name_domain ;
Data_type ;
Default {litaral | Null | User} ;
, .
litaral , Null , User , .
now ( ).
Not null ;
Check (<dom_condition>) ( ).
: value ( , ), is null/is not null, between and , like, in, .
, , check .
check.
check . , , check, , .
|
|
:
Create_domain username as varchar (20)
Default user;
Create domain month as smallint
Check (value between 1 and 12);
Create domain d_elem as char (2)
Check (value in (Au, Ag, Pr, Pd, Os));
Create domain pveight as numeric (12,2)
Default null check ((value is null) or (value >125));
drop domain, - , .
:
Drop domain name_doman;
MySQL
. mysql-u root, . , .
, root . mysql , 1.
1 mysql
-?,--help | |
-h,--hostname=[hostname] | mysql. |
-u,--user=[user] | mysql. |
-p,--password=[password] | mysql. |
-P,--port=[port] | . |
-V,--version |
, 1, mysql, , .
mysqlbin>mysql -u root mysql Welcome to the MySQL monitor.Commands end with; or g. Your MySQL connection id is 1 to server version: 3.23.19 Type 'help' for help. mysql> |
1 MySql
, (. 2).
2 - winmysqladmin
5 , . , 3.
mysql> UPDATE user SET Password=PASSWORD('new_password') WHERE user='root'; mysql>quit mysqlbin>mysqladmin -u root reload |
3
root mysqladmin reload, . .
mysql monitor, . , , .
.
, , 4.
mysql>show tables;
|
4
.
User - , , . , . show columns from user.
root , '%'. root , . '%', , .
|
|
, 5.
insert into user (host,user,password) values ('%.domain.com','john',password('df456');
insert into user (host,user,password) values ('localhost,'mary',password('kitchen');
select host,user,password from user;
|
5
Db - , . . show columns from db;.
, 'N'.
Host db. , - , host db, host . show columns from host;.
. . db , host . , , , , , . db select, insert 'Y', host 'N', 'Y'.
3 . MySQL, 3.22 2 - tables_priv columns_priv, . db, . , 3.22 GRANT , , db,tables_priv columns_priv.
MySQL 2.
2 - , MySQL
select | Select_priv | |
insert | Insert_priv | |
update | Update_priv | |
delete | Delete_priv | |
index | Index_priv | |
alter | Alter_priv | |
create | Create_priv | ,, |
drop | Drop_priv | |
grant | Grant_priv | |
references | References_priv | |
reload | Reload_priv | |
shutdown | Shutdown_priv | |
process | Process_priv | |
file | File_priv |
MySQL 3 : monty,admin dummy.
Monty - . , . , root , monty .
dmin - , Reload Process. admin mysqladmin reload, mysqladmin refresh mysqladmin flush-*, mysqladmin processlist.
admin . db, GRANT.
|
|
Dummy - , , . 'N' "USAGE", dummy . root'.
MySQL mysqladmin. mysql test, . , 6.
mysqlbin>mysqladmin -u root -p create data1 Enter password:****** Database "data1" created. mysqlbin> |
6
, root . , mysql (. 7).
mysqlbin>mysql -u root -p data1 Enter password:****** Welcome to MySQL monitor. |
7
.
customers data1 , 8.
mysql>use data1 Database changed. mysql>create table customers ( emp_id int(4) not null auto_increment, emp_name varchar(10) not null, emp_lname varchar(15) not null, address varchar(60) not null, phone int(10), primary key(emp_id)); |
8
:
, insert into;
, , .
mysqlimport .
9.
mysql>insert into customers (emp_id,emp_name,emp_lname,address,phone) -->values ('1001','John','Walker','New York','1236458794'); mysql>insert into customers values ('1001','John','Walker','New York','1236458794'); |
9
uto_increment emp_id, , . , .
LOAD DATA INFILE.
DATA [LOW_PRIORITY] [LOCAL] INFILE 'file_name.txt' [REPLACE | IGNORE]
INTO TABLE tbl_name
[FIELDS
[TERMINATED BY 't']
[OPTIONALLY] ENCLOSED BY '']
[ESCAPED BY '' ]]
[LINES TERMINATED BY 'n']
[IGNORE number LINES]
[(col_name,...)]
, 123.txt, 2000 , . , , ( ). , . , . :
LOAD DATA INFILE '123.txt' into table customers fields terminated by ',';
.
5.1 MySQL. , .
5.2 Mysqlshow Mysql.
|
|
5.3 , 10.
5.4 , 10 , , Ms Excel.
(S)
Hp | |||
S1 | |||
S2 | |||
S3 | |||
S4 | |||
S5 |
(P)
P1 | ||||
P2 | ||||
P3 | ||||
P4 | ||||
P5 | ||||
P6 |
(J)
J1 | ||
J2 | ||
J3 | ||
J4 | ||
J5 | - | |
J6 | ||
J7 |
(SPJ)
S1 | P1 | J1 | |
S1 | P1 | J4 | |
S2 | P3 | J1 | |
S2 | P3 | J2 | |
S2 | P3 | J3 | |
S2 | P3 | J4 | |
S2 | P3 | J5 | |
S2 | P3 | J6 |
10
6.1
6.2
6.3
7.1 .
7.2 . .
7.3 , ?
1 , . MySQL/ . 3- . .:-, 2007, . 38-185