Copying records
Lower case-insensitive functions
Password encryption function
CREATE TABLE Employee
> CREATE TABLE employee (ID int,name char (), AGI int,sex enum (' M ', ' F '), Department char (10));
> INSERT into employee values (g, ' John ', ', ' m ', ' Engi '), ("Sue", "F", ' fiance '), (113, ' David ', num, ' m ', ' Admin ');
> select * from Employee;
+------+-------+------+------+------------+
| ID | name | AGI | sex | Department |
+------+-------+------+------+------------+
| 23 | John | 27 | M | Engi |
| 31 | Sue | 31 | F | Fiance |
| 113 | David | 26 | M | Admin |
+------+-------+------+------+------------+
CREATE TABLE User
> CREATE table User (UID int primary key Auto_increment,uname char (), UPass char (10));
Copying records
> INSERT into User (Uname,upass) select lower (name), password (lower (name)) from employee;
> select * from User;
+-----+-------+------------+
| UID | uname | UPass |
+-----+-------+------------+
| 1 | John | *dacde7f57 |
| 2 | Sue | *934b89788 |
| 3 | David | *8201e0c1b |
+-----+-------+------------+
When you copy a record, you can add a where condition
> INSERT into User (Uname,upass) Select (name), password (name) from employee where department= ' fiance ';
> select * from User;
+-----+-------+------------+
| UID | uname | UPass |
+-----+-------+------------+
| 1 | John | *dacde7f57 |
| 2 | Sue | *934b89788 |
| 3 | David | *8201e0c1b |
| 4 | Sue | *287E48EAA |
+-----+-------+------------+
--------------------------------------------------------------------------------------------------------------- -----------------------------------------
Import data
Load Data infile ...
Grammar:
Load data infile ' file absolute path ' into table name fields terminated by ' field delimiter ' lines terminated by ' record separator ';
Sample Example:
> Load Data infile '/tmp/a.txt ' into table T20 fields terminated by ': ' Lines terminated by ' n ';
Export data
Select...into outfile ...
Grammar:
Select field from table name into outfile ' File absolute path ' fields terminated by ' field segmentation service ' lines terminated by ' record delimiter ';
Sample Example:
> select * from T20 to outfile '/tmp/b.txt ' fields terminated by ': ' Lines terminated by ' n ';