Sie sind auf Seite 1von 4

create usEnter password: ****

Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 2
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database db;


Query OK, 1 row affected (0.03 sec)

mysql> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| db |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.06 sec)

mysql> use db;


Database changed
mysql> create table user(name varchar(20), age int,password varchar(20));
Query OK, 0 rows affected (0.19 sec)

mysql> insert into user(name,age,password) values('krishna',12,'abc');


Query OK, 1 row affected (1.27 sec)

mysql> insert into user(name,age,password) values('Vaidehi',19,'yrt');


Query OK, 1 row affected (1.40 sec)

mysql> insert into user(name,age,password) values('Navneet',79,'aaa');


Query OK, 1 row affected (0.12 sec)

mysql> insert into user(name,age,password) values('varun',7,'8u7);


---------------------------------------------------------------------------------

Enter password: ****


Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use db;
Database changed
mysql> select *from user;
+---------+------+----------+
| name | age | password |
+---------+------+----------+
| krishna | 12 | abc |
| Vaidehi | 19 | yrt |
| Navneet | 79 | aaa |
+---------+------+----------+
3 rows in set (0.02 sec)

mysql> select *from user where name='vaidehi';


+---------+------+----------+
| name | age | password |
+---------+------+----------+
| Vaidehi | 19 | yrt |
+---------+------+----------+
1 row in set (0.06 sec)

mysql> select *from user where age>12;


+---------+------+----------+
| name | age | password |
+---------+------+----------+
| Vaidehi | 19 | yrt |
| Navneet | 79 | aaa |
+---------+------+----------+
2 rows in set (0.00 sec)

mysql> update user set password='vvv' where name='vaidehi';


Query OK, 1 row affected (0.13 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select *from user where age>12;


+---------+------+----------+
| name | age | password |
+---------+------+----------+
| Vaidehi | 19 | vvv |
| Navneet | 79 | aaa |
+---------+------+----------+
2 rows in set (0.00 sec)

mysql> delete from user where name = 'Navneet';


Query OK, 1 row affected (0.04 sec)

mysql> select *from user;


+---------+------+----------+
| name | age | password |
+---------+------+----------+
| krishna | 12 | abc |
| Vaidehi | 19 | vvv |
+---------+------+----------+
2 rows in set (0.00 sec)

mysql> insert into user (name,age,password) values('hitesh',20,'hhhh');


Query OK, 1 row affected (0.13 sec)

mysql> insert into user (name,age,password) values('Anuj',20,'yte');


Query OK, 1 row affected (0.03 sec)
mysql> insert into user (name,age,password) values('Akash',27,'abc');
Query OK, 1 row affected (0.12 sec)

mysql> insert into user (name,age,password) values('Ram',67,'avi');


Query OK, 1 row affected (0.13 sec)

mysql> select *from user;


+---------+------+----------+
| name | age | password |
+---------+------+----------+
| krishna | 12 | abc |
| Vaidehi | 19 | vvv |
| hitesh | 20 | hhhh |
| Anuj | 20 | yte |
| Akash | 27 | abc |
| Ram | 67 | avi |
+---------+------+----------+
6 rows in set (0.00 sec)

mysql> insert into user (name,age,password) values('krishna',20,'hhhh');


Query OK, 1 row affected (0.03 sec)

mysql> select *from user;


+---------+------+----------+
| name | age | password |
+---------+------+----------+
| krishna | 12 | abc |
| Vaidehi | 19 | vvv |
| hitesh | 20 | hhhh |
| Anuj | 20 | yte |
| Akash | 27 | abc |
| Ram | 67 | avi |
| krishna | 20 | hhhh |
+---------+------+----------+
7 rows in set (0.00 sec)

mysql> delete from user where name = 'krishna';


Query OK, 2 rows affected (0.02 sec)

mysql> insert into user (name,age,password) values('krishna',20,'hhhh');


Query OK, 1 row affected (0.32 sec)

mysql> insert into user (name,age,password) values('krishna',28,'765');


Query OK, 1 row affected (0.30 sec)

mysql> select *from user;


+---------+------+----------+
| name | age | password |
+---------+------+----------+
| Vaidehi | 19 | vvv |
| hitesh | 20 | hhhh |
| Anuj | 20 | yte |
| Akash | 27 | abc |
| Ram | 67 | avi |
| krishna | 20 | hhhh |
| krishna | 28 | 765 |
+---------+------+----------+
7 rows in set (0.00 sec)
mysql> select *from user where name = 'krishna';
+---------+------+----------+
| name | age | password |
+---------+------+----------+
| krishna | 20 | hhhh |
| krishna | 28 | 765 |
+---------+------+----------+
2 rows in set (0.00 sec)

mysql> select *from user where name = 'krishna' and pasword='765';


ERROR 1054 (42S22): Unknown column 'pasword' in 'where clause'
mysql> select *from user where name = 'krishna' and password='765';
+---------+------+----------+
| name | age | password |
+---------+------+----------+
| krishna | 28 | 765 |
+---------+------+----------+
1 row in set (0.00 sec)

mysql> select *from user where name = 'krishna' and password='765s';


Empty set (0.00 sec)

mysql> select *from user where name = 'krishna' or password='765s';


+---------+------+----------+
| name | age | password |
+---------+------+----------+
| krishna | 20 | hhhh |
| krishna | 28 | 765 |
+---------+------+----------+
2 rows in set (0.00 sec)

mysql> create table employee(id int primary key,name varchar(20));


Query OK, 0 rows affected (0.17 sec)

mysql> insert into employee(3,'amit'):


-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'3,'amit'):' at line 1
mysql> insert into employee values(3,'amit');
Query OK, 1 row affected (0.12 sec)

mysql> insert into employee values(3,'varun');


ERROR 1062 (23000): Duplicate entry '3' for key 'PRIMARY'
mysql>

Das könnte Ihnen auch gefallen