mysql>
drop table if exists my_table;
mysql>
create table my_table (ID int not null primary key, l_name
-> varchar(20) not null, f_name
varchar(20));
Query
OK, 0 rows affected (0.08 sec)
mysql>
describe my_table;
+--------+-------------+------+-----+---------+-------+
|
Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
|
ID | int(11) |
| PRI | 0 | |
|
l_name | varchar(20) | | |
| |
|
f_name | varchar(20) | YES | | NULL
| |
+--------+-------------+------+-----+---------+-------+
3
rows in set (0.04 sec)
mysql>
insert into my_table values (1,"Frost",'Robert');
Query
OK, 1 row affected (0.03 sec)
mysql>
insert into my_table (ID,l_name) values (2,'Smith');
Query
OK, 1 row affected (0.00 sec)
mysql>
select * from my_table;
+----+--------+--------+
|
ID | l_name | f_name |
+----+--------+--------+
| 1 | Frost
| Robert |
| 2 | Smith
| NULL |
+----+--------+--------+
2
rows in set (0.01 sec)
mysql>
update my_table set f_name='Linda' where l_name='Smith'
-> and ID=2;
Query
OK, 1 row affected (0.01 sec)
Rows
matched: 1 Changed: 1 Warnings: 0
mysql>
select * from my_table;
+----+--------+--------+
|
ID | l_name | f_name |
+----+--------+--------+
| 1 | Frost
| Robert |
| 2 | Smith
| Linda |
+----+--------+--------+
2
rows in set (0.00 sec)
mysql>
delete from my_table where ID=1;
mysql>
select * from my_table;
+----+--------+--------+
|
ID | l_name | f_name |
+----+--------+--------+
| 2 | Smith
| Linda |
+----+--------+--------+
1
row in set (0.01 sec)
mysql>
create table table_name select * from bank.BANK_WORKER;
(copy
table bank.BANK_WORKER into table_name)
Comments
Post a Comment