mysql> SHOW databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| tcdb |
| test |
| webserver |
| wordpress |
| xedb |
+--------------------+
7 rows in set (0.07 sec)
mysql> USE test;
Database changed
mysql> CREATE TABLE student(
-> no int,
-> name varchar(10),
-> city varchar(10),
-> email varchar(20)
-> );
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO student(no, name, ciry) value (1, 'aaa','Seoul');
ERROR 1054 (42S22): Unknown column 'ciry' in 'field list'
mysql> INSERT INTO student(no, name, city) value (1, 'aaa','Seoul');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO student(no, name, city) value (2, 'bbb','Busan');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO student(no, name, city) value (3, 'ccc','Daegu');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO student(no, name, city) value (4, 'ddd','Suwon');
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM student;
+------+------+-------+-------+
| no | name | city | email |
+------+------+-------+-------+
| 1 | aaa | Seoul | NULL |
| 2 | bbb | Busan| NULL |
| 3 | ccc | Daegu| NULL |
| 4 | ddd |Suwon| NULL |
+------+------+-------+-------+
4 rows in set (0.00 sec)
mysql> UPDATE student SET email='aaa@abc.com' WHERE no=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM student;
+------+------+-------+-------------+
| no | name | city | email |
+------+------+-------+-------------+
| 1 | aaa | Seoul | aaa@abc.com|
| 2 | bbb | Busan| NULL |
| 3 | ccc | Daegu| NULL |
| 4 | ddd |Suwon| NULL |
+------+------+-------+-------------+
4 rows in set (0.00 sec)
mysql> UPDATE student SET city='Busan' WHERE no='3';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM student;
+------+------+-------+---------------+
| no | name | city | email |
+------+------+-------+---------------+
| 1 | aaa | Seoul | aaa@abc.com |
| 2 | bbb | Busan | NULL |
| 3 | ccc | Busan | NULL |
| 4 | ddd | Suwon | NULL |
+------+------+-------+---------------+
4 rows in set (0.00 sec)
mysql> SELECT no, name FROM student WHERE city='Busan';
+------+------+
| no | name |
+------+------+
| 2 | bbb |
| 3 | ccc |
+------+------+
2 rows in set (0.01 sec)
'DATABASE' 카테고리의 다른 글
SQL Gate 단축키 (0) | 2013.06.18 |
---|---|
PL/SQL (0) | 2013.06.18 |
oracle (0) | 2013.04.24 |
Oracle_130402 (0) | 2013.04.02 |
Oracle _ 20130329 (0) | 2013.03.29 |