Anda di halaman 1dari 8

C:\Documents and Settings\TheBasu>mysql -h localhost -u root -p --default-charac

ter-set=utf8
Enter password: *
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.12 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> \h
For information about MySQL products and services, visit:
http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
https://shop.mysql.com/
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?
(\?) Synonym for `help'.
clear
(\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
ego
(\G) Send command to mysql server, display result vertically.
exit
(\q) Exit mysql. Same as quit.
go
(\g) Send command to mysql server.
help
(\h) Display this help.
notee
(\t) Don't write into outfile.
print
(\p) Print current command.
prompt
(\R) Change your mysql prompt.
quit
(\q) Quit mysql.
rehash
(\#) Rebuild completion hash.
source
(\.) Execute an SQL script file. Takes a file name as an argument.
status
(\s) Get status information from the server.
tee
(\T) Set outfile [to_outfile]. Append everything into given outfile.
use
(\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog
with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
For server side help, type 'help contents'
mysql> \c
mysql> create database mineru;
Query OK, 1 row affected (0.14 sec)
mysql> show databases;
+--------------------+
| Database
|
+--------------------+
| information_schema |
| dbt
|

| mineru
|
| mysql
|
| performance_schema |
| test
|
| uab29mar
|
| uage25mai
|
+--------------------+
8 rows in set (0.25 sec)
mysql> drop database mineru;
Query OK, 0 rows affected (0.50 sec)
mysql> show databases;
+--------------------+
| Database
|
+--------------------+
| information_schema |
| dbt
|
| mysql
|
| performance_schema |
| test
|
| uab29mar
|
| uage25mai
|
+--------------------+
7 rows in set (0.00 sec)
mysql> create database mineru character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.03 sec)
mysql> show databases;
+--------------------+
| Database
|
+--------------------+
| information_schema |
| dbt
|
| mineru
|
| mysql
|
| performance_schema |
| test
|
| uab29mar
|
| uage25mai
|
+--------------------+
8 rows in set (0.00 sec)
mysql> show create database mineru;
+----------+---------------------------------------------------------------------------------+
| Database | Create Database
|
+----------+---------------------------------------------------------------------------------+
| mineru | CREATE DATABASE `mineru` /*!40100 DEFAULT CHARACTER SET utf8 COLLAT
E utf8_bin */ |
+----------+---------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> rename database;
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 'datab

ase' at line 1
mysql> rename database mineru;
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 'datab
ase mineru' at line 1
mysql> rename mineru;
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 'miner
u' at line 1
mysql> rename
-> ;
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 '' at
line 1
mysql> rename database mineru to Mineru;
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 'datab
ase mineru to Mineru' at line 1
mysql> use mineru
Database changed
mysql> create table animale;
ERROR 1113 (42000): A table must have at least 1 column
mysql> create table animale (animale_id int(3) , nume char(20) , mancare char(20
);
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 '' at
line 1
mysql> create table animale (animale_id int(3) , nume char(20) , mancare char(20
));
Query OK, 0 rows affected (0.22 sec)
mysql> show tables;
+------------------+
| Tables_in_mineru |
+------------------+
| animale
|
+------------------+
1 row in set (0.03 sec)
mysql> create table zonegeografice (zonegeografice_id int(2) , denumire char(20)
, animale_fk int(2));
Query OK, 0 rows affected (0.09 sec)
mysql> show tables;
+------------------+
| Tables_in_mineru |
+------------------+
| animale
|
| zonegeografice |
+------------------+
2 rows in set (0.02 sec)
mysql> alter table zonegeografice remove
ERROR 1064 (42000): You have an error in
corresponds to your MySQL server version
n animale_fk' at line 1
mysql> alter table zonegeografice delete
ERROR 1064 (42000): You have an error in
corresponds to your MySQL server version
e column animale_fk' at line 1

column animale_fk;
your SQL syntax; check the manual that
for the right syntax to use near 'colum
column animale_fk;
your SQL syntax; check the manual that
for the right syntax to use near 'delet

mysql> alter table zonegeografice drop column animale_fk;


Query OK, 0 rows affected (0.25 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table zonegeografice;
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table
| Create Table
|
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| zonegeografice | CREATE TABLE `zonegeografice` (
`zonegeografice_id` int(2) DEFAULT NULL,
`denumire` char(20) COLLATE utf8_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin |
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> alter table animale add column zonegeografice_fk int(2);
Query OK, 0 rows affected (0.17 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table animale;
+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Table | Create Table
+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| animale | CREATE TABLE `animale` (
`animale_id` int(3) DEFAULT NULL,
`nume` char(20) COLLATE utf8_bin DEFAULT NULL,
`mancare` char(20) COLLATE utf8_bin DEFAULT NULL,
`zonegeografice_fk` int(2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin |
+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------1 row in set (0.00 sec)
mysql> insert into animale (animale_id ,
ERROR 1064 (42000): You have an error in
corresponds to your MySQL server version
e (1,caine,oase)' at line 1
mysql> insert into animale (animale_id ,
');
ERROR 1064 (42000): You have an error in
corresponds to your MySQL server version
e (1,'caine','oase')' at line 1
mysql> insert into animale (animale_id ,
');
Query OK, 1 row affected (0.05 sec)
mysql> select * from animale;

nume , mancare) valuse (1,caine,oase);


your SQL syntax; check the manual that
for the right syntax to use near 'valus
nume , mancare) valuse (1,'caine','oase
your SQL syntax; check the manual that
for the right syntax to use near 'valus
nume , mancare) values (1,'caine','oase

+------------+-------+---------+-------------------+
| animale_id | nume | mancare | zonegeografice_fk |
+------------+-------+---------+-------------------+
|
1 | caine | oase
|
NULL |
+------------+-------+---------+-------------------+
1 row in set (0.02 sec)
mysql> insert into zonegeografice (zonegeografice_id , denumire) values (1 , 'Ch
ina');
Query OK, 1 row affected (0.02 sec)
mysql> select * from zonegeografice;
+-------------------+----------+
| zonegeografice_id | denumire |
+-------------------+----------+
|
1 | China
|
+-------------------+----------+
1 row in set (0.02 sec)
mysql> insert into zonegeografice (zonegeografice_id , denumire) values (2 , 'Ja
ponia');
Query OK, 1 row affected (0.03 sec)
mysql> select * from zonegeografice;
+-------------------+----------+
| zonegeografice_id | denumire |
+-------------------+----------+
|
1 | China
|
|
2 | Japonia |
+-------------------+----------+
2 rows in set (0.00 sec)
mysql> alter table zonegeografice update zonegeografice_id autoincrement;
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 'updat
e zonegeografice_id autoincrement' at line 1
mysql> alter table zonegeografice modify zonegeografice_id autoincrement;
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 'autoi
ncrement' at line 1
mysql> alter table zonegeografice modify zonegeografice_id zonegeografice_id int
(2) autoincrement;
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 'zoneg
eografice_id int(2) autoincrement' at line 1
mysql> alter table zonegeografice modify zonegeografice_id zonegeografice_id int
(2) not null autoincrement;
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 'zoneg
eografice_id int(2) not null autoincrement' at line 1
mysql> alter table zonegeografice modify zonegeografice_id int(2) not null auto_
increment;
ERROR 1075 (42000): Incorrect table definition; there can be only one auto colum
n and it must be defined as a key
mysql> alter table zonegeografice modify zonegeografice_id int(2) auto_increment
;
ERROR 1075 (42000): Incorrect table definition; there can be only one auto colum
n and it must be defined as a key
mysql> alter table zonegeografice modify zonegeografice_id int(2) primary key no
t null auto_increment;

Query OK, 2 rows affected (0.19 sec)


Records: 2 Duplicates: 0 Warnings: 0
mysql> insert into zonegeografice (denumire) values ('Romania');
Query OK, 1 row affected (0.03 sec)
mysql> select * from zonegeografice;
+-------------------+----------+
| zonegeografice_id | denumire |
+-------------------+----------+
|
1 | China
|
|
2 | Japonia |
|
3 | Romania |
+-------------------+----------+
3 rows in set (0.00 sec)
mysql> insert into zonegeografice 'Rusia';
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 ''Rusi
a'' at line 1
mysql> select * from animale;
+------------+-------+---------+-------------------+
| animale_id | nume | mancare | zonegeografice_fk |
+------------+-------+---------+-------------------+
|
1 | caine | oase
|
NULL |
+------------+-------+---------+-------------------+
1 row in set (0.00 sec)
mysql> insert into animale (animale_id , nume , mancare) values (2,'pisica','iep
uri');
Query OK, 1 row affected (0.05 sec)
mysql> select * from animale;
+------------+--------+---------+-------------------+
| animale_id | nume | mancare | zonegeografice_fk |
+------------+--------+---------+-------------------+
|
1 | caine | oase
|
NULL |
|
2 | pisica | iepuri |
NULL |
+------------+--------+---------+-------------------+
2 rows in set (0.00 sec)
mysql> update animale set zonegeografice_fk=1 where animale_id=1;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from animale;
+------------+--------+---------+-------------------+
| animale_id | nume | mancare | zonegeografice_fk |
+------------+--------+---------+-------------------+
|
1 | caine | oase
|
1 |
|
2 | pisica | iepuri |
NULL |
+------------+--------+---------+-------------------+
2 rows in set (0.00 sec)
mysql> update animale set zonegeografice_fk=2 where animale_id=2;
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from animale;
+------------+--------+---------+-------------------+

| animale_id | nume | mancare | zonegeografice_fk |


+------------+--------+---------+-------------------+
|
1 | caine | oase
|
1 |
|
2 | pisica | iepuri |
2 |
+------------+--------+---------+-------------------+
2 rows in set (0.00 sec)
mysql> update animale set zonegeografice_fk=2 where animale_id=3;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select * from animale;
+------------+--------+---------+-------------------+
| animale_id | nume | mancare | zonegeografice_fk |
+------------+--------+---------+-------------------+
|
1 | caine | oase
|
1 |
|
2 | pisica | iepuri |
2 |
+------------+--------+---------+-------------------+
2 rows in set (0.00 sec)
mysql> update animale set zonegeografice_fk=3 where animale_id=2;
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from animale;
+------------+--------+---------+-------------------+
| animale_id | nume | mancare | zonegeografice_fk |
+------------+--------+---------+-------------------+
|
1 | caine | oase
|
1 |
|
2 | pisica | iepuri |
3 |
+------------+--------+---------+-------------------+
2 rows in set (0.00 sec)
mysql> select * from animale where nume = 'caine';
+------------+-------+---------+-------------------+
| animale_id | nume | mancare | zonegeografice_fk |
+------------+-------+---------+-------------------+
|
1 | caine | oase
|
1 |
+------------+-------+---------+-------------------+
1 row in set (0.01 sec)
mysql> select * from animale where animale_id=1;
+------------+-------+---------+-------------------+
| animale_id | nume | mancare | zonegeografice_fk |
+------------+-------+---------+-------------------+
|
1 | caine | oase
|
1 |
+------------+-------+---------+-------------------+
1 row in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database
|
+--------------------+
| information_schema |
| dbt
|
| mineru
|
| mysql
|
| performance_schema |
| test
|
| uab29mar
|

| uage25mai
|
+--------------------+
8 rows in set (0.00 sec)
mysql> use uab29mar\
ERROR 1049 (42000): Unknown database 'uab29mar\'
mysql> use uab29mar
Database changed
mysql> show tables;

Anda mungkin juga menyukai