Anda di halaman 1dari 9

mysql -u root -p

Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.5.57-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2017, 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> help

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.
edit (\e) Edit command with $EDITOR.
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.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
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.
system (\!) Execute a system shell command.
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> clear
mysql> \c
mysql> clear \c
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.
edit (\e) Edit command with $EDITOR.
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.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
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.
system (\!) Execute a system shell command.
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> clear
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql> create table employee
-> (
-> );
ERROR 1046 (3D000): No database selected
mysql> show 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
'database' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
+--------------------+
4 rows in set (0.01 sec)

mysql> create database company_026;


Query OK, 1 row affected (0.00 sec)

mysql> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| company_026 |
| mysql |
| performance_schema |
| phpmyadmin |
+--------------------+
5 rows in set (0.00 sec)

mysql> use company_026


Database changed
mysql> use company_026;
Database changed
mysql> create table employee_026
-> (
-> fname varchar(15) not null,
-> minit char,
-> lname varchar(15),
-> ssn char(9),
-> bdate date,
-> address varchar(30),
-> gender char,
-> salary decimal(10,2),
-> super_ssn char(9),
-> dno int not null,
-> primary key(ssn),
-> foreign key(super_ssn) references employee(ssn));
ERROR 1005 (HY000): Can't create table 'company_026.employee_026' (errno: 150)
mysql> create table employee_026
-> (
-> fname varchar(15) not null,
-> minit varchar,
-> lname varchar(15),
-> ssn varchar(9),
-> bdate date,
-> address varchar(30),
-> gender varchar,
-> salary decimal(10,2),
-> super_ssn varchar(9),
-> dno int not null,
-> primary key(ssn),
-> foreign key(super_ssn) references employee(ssn),
-> );
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 '
lname varchar(15),
ssn varchar(9),
bdate date,
address varchar(30),
gender var' at line 4
mysql> create table employee_026
-> (
-> fname varchar(15) not null,
-> minit varchar,
-> lname varchar(15),
-> ssn varchar(9),
-> bdate date,
-> address varchar(30),
-> gender varchar,
-> salary decimal(10,2),
-> super_ssn varchar(9),
-> dno int not null,
-> primary key(ssn),
-> foreign key(super_ssn) references employee(ssn));
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 '
lname varchar(15),
ssn varchar(9),
bdate date,
address varchar(30),
gender var' at line 4
mysql> create table employee_026
-> (
-> fname varchar(15) not null,
-> minit varchar,
-> lname varchar(15),
-> ssn varchar(9),
-> bdate date,
-> address varchar(30),
-> gender varchar,
-> salary decimal(10,2),
-> super_ssn varchar(9),
-> dno int not null,
-> primary key(ssn),
-> foreign key(super_ssn) references employee_026(ssn));
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 '
lname varchar(15),
ssn varchar(9),
bdate date,
address varchar(30),
gender var' at line 4
mysql> create table employee_026
-> (
-> fname varchar(15) not null,
-> minit varchar,
-> lname varchar(15),
-> ssn varchar(9),
-> bdate date,
-> address varchar(30),
-> gender varchar,
-> salary decimal(10,2),
-> super_ssn varchar(9),
-> dno int not null,
-> primary key(ssn),
-> foreign key(super_ssn) references employee_026(ssn));
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 '
lname varchar(15),
ssn varchar(9),
bdate date,
address varchar(30),
gender var' at line 4
mysql> create table employee_026
-> (
-> fname varchar(15) not null,
-> minit varchar,
-> lname varchar(15),
-> ssn varchar(9),
-> bdate date,
-> address varchar(30),
-> gender varchar,
-> salary decimal(10,2),
-> super_ssn varchar(9),
-> dno int not null,
-> primary key(ssn),
-> foreign key(super_ssn) references employee_026(ssn));
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 '
lname varchar(15),
ssn varchar(9),
bdate date,
address varchar(30),
gender var' at line 4
mysql> create table employee_026
-> (
-> fname varchar(15) not null,
-> minit varchar,
-> lname varchar(15),
-> ssn varchar(9),
-> bdate date,
-> address varchar(30),
-> gender varchar,
-> salary decimal(10,2),
-> super_ssn varchar(9),
-> dno int not null,
-> primary key(ssn),
-> foreign key(super_ssn) references employee_026(ssn));
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 '
lname varchar(15),
ssn varchar(9),
bdate date,
address varchar(30),
gender var' at line 4
mysql> create table employee_026
-> (
-> fname varchar(15) not null,
-> minit varchar,
-> lname varchar(15),
-> ssn varchar(9),
-> bdate date,
-> address varchar(30),
-> gender char,
-> salary decimal(10,2),
-> super_ssn varchar(9),
-> dno int not null,
-> primary key(ssn),
-> foreign key(super_ssn) references employee_026(ssn));
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 '
lname varchar(15),
ssn varchar(9),
bdate date,
address varchar(30),
gender cha' at line 4
mysql> create table employee_026
-> (
-> fname varchar(15) not null,
-> minit char,
-> lname varchar(15),
-> ssn char(9),
-> bdate date,
-> address varchar(30),
-> gender char,
-> salary decimal(10,2),
-> super_ssn char(9),
-> dno int not null,
-> primary key(ssn),
-> foreign key(super_ssn) references employee_026(ssn));
Query OK, 0 rows affected (0.09 sec)

mysql> desc employee_026


->
-> ;
+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| fname | varchar(15) | NO | | NULL | |
| minit | char(1) | YES | | NULL | |
| lname | varchar(15) | YES | | NULL | |
| ssn | char(9) | NO | PRI | | |
| bdate | date | YES | | NULL | |
| address | varchar(30) | YES | | NULL | |
| gender | char(1) | YES | | NULL | |
| salary | decimal(10,2) | YES | | NULL | |
| super_ssn | char(9) | YES | MUL | NULL | |
| dno | int(11) | NO | | NULL | |
+-----------+---------------+------+-----+---------+-------+
10 rows in set (0.00 sec)

mysql> create table department


-> (
-> dname varchar(15) not null,
-> dnumber int,
-> mgr_ssn char(9) not null,
-> mgr_start_date date,
-> primary key(dnumber),
-> foreign key(mgr_ssn) references employee_026(ssn));
Query OK, 0 rows affected (0.07 sec)

mysql> desc department;


+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| dname | varchar(15) | NO | | NULL | |
| dnumber | int(11) | NO | PRI | 0 | |
| mgr_ssn | char(9) | NO | MUL | NULL | |
| mgr_start_date | date | YES | | NULL | |
+----------------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> create table dept_loc


-> (
->
-> dnumber int,
-> dlocation varchar(30),
-> primary key(dnumber,dlocation),
-> foreign key(dnumber) references depatment(dnumber));
ERROR 1005 (HY000): Can't create table 'company_026.dept_loc' (errno: 150)
mysql> create table dept_loc
-> (
->
-> dnumber int,
-> dlocation varchar(30),
-> primary key(dnumber,dlocation),
-> foreign key(dnumber) references department(dnumber));
Query OK, 0 rows affected (0.04 sec)

mysql> create table project


-> (
-> pname varchar(15) not null,
-> pnumber int not null,
-> plocation varchar(30) ,
-> dnum int ,
-> primary key(pnumber),
-> foreign key(dnum) references department(dnumber));
Query OK, 0 rows affected (0.07 sec)

mysql>
mysql>
mysql>
mysql> create table works_on
-> (
-> essn char(9) not null,
-> pno int not null,
-> hours decimal(5,1),
-> primary key(pno,essn),
-> foreign key(essn) references employee_026(ssn));
Query OK, 0 rows affected (0.18 sec)

mysql> foreign key(pno) references project(pnumber));


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 'foreign
key(pno) references project(pnumber))' at line 1
mysql>
mysql>
mysql> alter works_on
-> (
-> foreign key(pno) references project(pnumber));
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 'works_on
(
foreign key(pno) references project(pnumber))' at line 1
mysql> desc department;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| dname | varchar(15) | NO | | NULL | |
| dnumber | int(11) | NO | PRI | 0 | |
| mgr_ssn | char(9) | NO | MUL | NULL | |
| mgr_start_date | date | YES | | NULL | |
+----------------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> create table dependent


-> (
-> essn char(9) not null,
-> dependent_name varchar(20) not null,
-> gender char,
-> bdate date,
-> relationship varchar(20),
-> primary key(dependent_name,essn),
-> foreign key(essn) references employee_026(ssn));
Query OK, 0 rows affected (0.05 sec)

Anda mungkin juga menyukai