SlideShare una empresa de Scribd logo
1 de 6
[root@koneksi ~]# service mysqld start
Starting mysqld:                                           [   OK   ]
[root@koneksi ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.1.67 Source distribution

Copyright (c) 2000, 2012, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| appPegawai         |
| coba               |
| dbpegawai          |
| mysql              |
| test               |
+--------------------+
6 rows in set (0.04 sec)

mysql> create database pbd;
Query OK, 1 row affected (0.00 sec)

mysql> use pbd;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> create table siswa(
    -> id int primary key,
    -> nama varchar(30),
    -> alamat text,
    -> jk char(1));
Query OK, 0 rows affected (0.08 sec)

mysql> show tables;
+---------------+
| Tables_in_pbd |
+---------------+
| siswa         |
+---------------+
1 row in set (0.00 sec)

mysql> desc siswa;
+--------+-------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id     | int(11)     | NO   | PRI | NULL    |       |
| nama   | varchar(30) | YES |      | NULL    |       |
| alamat | text        | YES |      | NULL    |       |
| jk     | char(1)     | YES |      | NULL    |       |
+--------+-------------+------+-----+---------+-------+
4 rows in set (0.02 sec)

mysql> insert into siswa(id, nama, alamat, jk)
-> values(1, 'Sapari Andi', 'Mampang', 'L');
Query OK, 1 row affected (0.00 sec)

mysql> insert into siswa(id, nama, alamat, jk)values(1, 'Sapari Andi',
'Mampang', 'L')
    -> ;
ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
mysql> insert into siswa(id, nama, alamat, jk)
    -> values (2, 'Dede Hidayat');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> insert into siswa(id, nama) values (2, 'Dede Hidayat');
Query OK, 1 row affected (0.00 sec)

mysql> show tables;
+---------------+
| Tables_in_pbd |
+---------------+
| siswa         |
+---------------+
1 row in set (0.00 sec)

mysql> desc siswa;
+--------+-------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id     | int(11)     | NO   | PRI | NULL    |       |
| nama   | varchar(30) | YES |      | NULL    |       |
| alamat | text        | YES |      | NULL    |       |
| jk     | char(1)     | YES |      | NULL    |       |
+--------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> select * from siswa;
+----+--------------+---------+------+
| id | nama         | alamat | jk    |
+----+--------------+---------+------+
| 1 | Sapari Andi | Mampang | L      |
| 2 | Dede Hidayat | NULL     | NULL |
+----+--------------+---------+------+
2 rows in set (0.00 sec)

mysql> insert into siswa values(3, 'Heni Lestari', 'Kalibata', 'P');
Query OK, 1 row affected (0.00 sec)

mysql> select nama from siswa;
+--------------+
| nama         |
+--------------+
| Sapari Andi |
| Dede Hidayat |
| Heni Lestari |
+--------------+
3 rows in set (0.00 sec)

mysql> select * from siswa;
+----+--------------+----------+------+
| id | nama         | alamat   | jk   |
+----+--------------+----------+------+
| 1 | Sapari Andi | Mampang | L       |
| 2 | Dede Hidayat | NULL      | NULL |
| 3 | Heni Lestari | Kalibata | P     |
+----+--------------+----------+------+
3 rows in set (0.00 sec)
mysql> update siswa set alamat='Ciamis' where id=2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from siswa;
+----+--------------+----------+------+
| id | nama         | alamat   | jk   |
+----+--------------+----------+------+
| 1 | Sapari Andi | Mampang | L       |
| 2 | Dede Hidayat | Ciamis    | NULL |
| 3 | Heni Lestari | Kalibata | P     |
+----+--------------+----------+------+
3 rows in set (0.00 sec)

mysql> update siswa set jk='L' where id=2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from siswa;
+----+--------------+----------+------+
| id | nama         | alamat   | jk   |
+----+--------------+----------+------+
| 1 | Sapari Andi | Mampang | L       |
| 2 | Dede Hidayat | Ciamis    | L    |
| 3 | Heni Lestari | Kalibata | P     |
+----+--------------+----------+------+
3 rows in set (0.00 sec)

mysql> update siswa set jk=1 where jk='P';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from siswa;
+----+--------------+----------+------+
| id | nama         | alamat   | jk   |
+----+--------------+----------+------+
| 1 | Sapari Andi | Mampang | L       |
| 2 | Dede Hidayat | Ciamis    | L    |
| 3 | Heni Lestari | Kalibata | 1     |
+----+--------------+----------+------+
3 rows in set (0.00 sec)

mysql> update siswa set jk=0 where jk='L';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> select * from siswa;
+----+--------------+----------+------+
| id | nama         | alamat   | jk   |
+----+--------------+----------+------+
| 1 | Sapari Andi | Mampang | 0       |
| 2 | Dede Hidayat | Ciamis    | 0    |
| 3 | Heni Lestari | Kalibata | 1     |
+----+--------------+----------+------+
3 rows in set (0.00 sec)

mysql> delete from siswa where id=2;
Query OK, 1 row affected (0.00 sec)

mysql> select * from siswa;
+----+--------------+----------+------+
| id | nama         | alamat   | jk   |
+----+--------------+----------+------+
| 1 | Sapari Andi | Mampang | 0       |
| 3 | Heni Lestari | Kalibata | 1     |
+----+--------------+----------+------+
2 rows in set (0.00 sec)

mysql> select * from siswa order by alamat;
+----+--------------+----------+------+
| id | nama         | alamat   | jk   |
+----+--------------+----------+------+
| 3 | Heni Lestari | Kalibata | 1     |
| 1 | Sapari Andi | Mampang | 0       |
+----+--------------+----------+------+
2 rows in set (0.00 sec)

mysql> create table guru(
    -> id int primary key auto_increment,
    -> nama varchar(30),
    -> alamat text,
    -> gaji double);
Query OK, 0 rows affected (0.06 sec)

mysql> insert into guru(nama,alamat,gaji)
    -> values('Karim Santoso','Pancoran',8000000);
Query OK, 1 row affected (0.00 sec)

mysql> select * from guru;
+----+---------------+----------+---------+
| id | nama          | alamat   | gaji    |
+----+---------------+----------+---------+
| 1 | Karim Santoso | Pancoran | 8000000 |
+----+---------------+----------+---------+
1 row in set (0.00 sec)

mysql> desc guru;
+--------+-------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+--------+-------------+------+-----+---------+----------------+
| id     | int(11)     | NO   | PRI | NULL    | auto_increment |
| nama   | varchar(30) | YES |      | NULL    |                |
| alamat | text        | YES |      | NULL    |                |
| gaji   | double      | YES |      | NULL    |                |
+--------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> create table mahasiswa(
    -> npm int primary key auto_increment,
    -> nama varchar(30),
    -> ;
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 3
mysql> show tables;
+---------------+
| Tables_in_pbd |
+---------------+
| guru          |
| siswa         |
+---------------+
2 rows in set (0.00 sec)

mysql> create table mahasiswa(
    -> npm int primary key auto_increment,
    -> nama varchar(30));
Query OK, 0 rows affected (0.06 sec)
mysql> create table matakuliah(
    -> kodemk int primary key,
    -> mk varchar(30));
Query OK, 0 rows affected (0.06 sec)

mysql> create table krs(
    -> npm int,
    -> ta int,
    -> semester char(1),
    -> kodemk int);
Query OK, 0 rows affected (0.07 sec)

mysql> show tables;
+---------------+
| Tables_in_pbd |
+---------------+
| guru          |
| krs           |
| mahasiswa     |
| matakuliah    |
| siswa         |
+---------------+
5 rows in set (0.00 sec)

mysql> desc pbd;
ERROR 1146 (42S02): Table 'pbd.pbd' doesn't exist
mysql> show tables;
+---------------+
| Tables_in_pbd |
+---------------+
| guru           |
| krs            |
| mahasiswa      |
| matakuliah     |
| siswa          |
+---------------+
5 rows in set (0.00 sec)

mysql> desc krs;
+----------+---------+------+-----+---------+-------+
| Field    | Type    | Null | Key | Default | Extra |
+----------+---------+------+-----+---------+-------+
| npm      | int(11) | YES |      | NULL    |       |
| ta       | int(11) | YES |      | NULL    |       |
| semester | char(1) | YES |      | NULL    |       |
| kodemk   | int(11) | YES |      | NULL    |       |
+----------+---------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> desc mahasiswa;
+-------+-------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| npm   | int(11)      | NO   | PRI | NULL    | auto_increment |
| nama | varchar(30) | YES |        | NULL    |                |
+-------+-------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)

mysql> desc matakuliah;
+--------+-------------+------+-----+---------+-------+
| Field | Type          | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| kodemk | int(11)      | NO   | PRI | NULL    |       |
| mk     | varchar(30) | YES |       | NULL    |       |
+--------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql>

Más contenido relacionado

La actualidad más candente

Direct SGA access without SQL
Direct SGA access without SQLDirect SGA access without SQL
Direct SGA access without SQL
Kyle Hailey
 
OOUG: Oracle transaction locking
OOUG: Oracle transaction lockingOOUG: Oracle transaction locking
OOUG: Oracle transaction locking
Kyle Hailey
 

La actualidad más candente (20)

SQLd360
SQLd360SQLd360
SQLd360
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
 
aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.
 
Direct SGA access without SQL
Direct SGA access without SQLDirect SGA access without SQL
Direct SGA access without SQL
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
 
Same plan different performance
Same plan different performanceSame plan different performance
Same plan different performance
 
OOUG: Oracle transaction locking
OOUG: Oracle transaction lockingOOUG: Oracle transaction locking
OOUG: Oracle transaction locking
 
Optimizing queries MySQL
Optimizing queries MySQLOptimizing queries MySQL
Optimizing queries MySQL
 
Oracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptOracle Database Performance Tuning Concept
Oracle Database Performance Tuning Concept
 
4. plsql
4. plsql4. plsql
4. plsql
 
MySQL SQL Tutorial
MySQL SQL TutorialMySQL SQL Tutorial
MySQL SQL Tutorial
 
MySQL Timeout Variables Explained
MySQL Timeout Variables Explained MySQL Timeout Variables Explained
MySQL Timeout Variables Explained
 
MySQL 5.7 NF – JSON Datatype 활용
MySQL 5.7 NF – JSON Datatype 활용MySQL 5.7 NF – JSON Datatype 활용
MySQL 5.7 NF – JSON Datatype 활용
 
Sql select
Sql select Sql select
Sql select
 
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZEMySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
 
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docxKeepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
 
AWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add upAWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add up
 
Curso de MySQL 5.7
Curso de MySQL 5.7Curso de MySQL 5.7
Curso de MySQL 5.7
 

Destacado (9)

Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Twitterplug
TwitterplugTwitterplug
Twitterplug
 
RSpec
RSpecRSpec
RSpec
 
Uninstall ShhMBP
Uninstall ShhMBPUninstall ShhMBP
Uninstall ShhMBP
 
Explicar a Crise
 Explicar a Crise Explicar a Crise
Explicar a Crise
 
Para vane
Para vanePara vane
Para vane
 
World generation final
World generation finalWorld generation final
World generation final
 
Backstopper 3-D Dodgeball
Backstopper 3-D DodgeballBackstopper 3-D Dodgeball
Backstopper 3-D Dodgeball
 
Format Cover Tugas Observasi Lapangan
Format  Cover Tugas Observasi LapanganFormat  Cover Tugas Observasi Lapangan
Format Cover Tugas Observasi Lapangan
 

Similar a Cat database

Applied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System PresentationApplied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System Presentation
Richard Crowley
 
අරුණ හේරත්_MYSQL සිංහල_TL_I_033__techlogiclk.com.pdf
අරුණ හේරත්_MYSQL සිංහල_TL_I_033__techlogiclk.com.pdfඅරුණ හේරත්_MYSQL සිංහල_TL_I_033__techlogiclk.com.pdf
අරුණ හේරත්_MYSQL සිංහල_TL_I_033__techlogiclk.com.pdf
AnilManage
 
MySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SFMySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SF
Ronald Bradford
 
Mysqlfunctions
MysqlfunctionsMysqlfunctions
Mysqlfunctions
N13M
 
MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07
Ronald Bradford
 

Similar a Cat database (20)

Design and Develop SQL DDL statements which demonstrate the use of SQL objec...
 Design and Develop SQL DDL statements which demonstrate the use of SQL objec... Design and Develop SQL DDL statements which demonstrate the use of SQL objec...
Design and Develop SQL DDL statements which demonstrate the use of SQL objec...
 
Mysql basics1
Mysql basics1Mysql basics1
Mysql basics1
 
Hanya contoh saja dari xampp
Hanya contoh saja dari xamppHanya contoh saja dari xampp
Hanya contoh saja dari xampp
 
Applied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System PresentationApplied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System Presentation
 
MySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesMySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queries
 
My SQL
My SQLMy SQL
My SQL
 
අරුණ හේරත්_MYSQL සිංහල_TL_I_033__techlogiclk.com.pdf
අරුණ හේරත්_MYSQL සිංහල_TL_I_033__techlogiclk.com.pdfඅරුණ හේරත්_MYSQL සිංහල_TL_I_033__techlogiclk.com.pdf
අරුණ හේරත්_MYSQL සිංහල_TL_I_033__techlogiclk.com.pdf
 
Explain
ExplainExplain
Explain
 
Tugas praktikum smbd
Tugas praktikum smbdTugas praktikum smbd
Tugas praktikum smbd
 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
 
MySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SFMySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SF
 
Empresa completo
Empresa completoEmpresa completo
Empresa completo
 
Optimizing Queries Using Window Functions
Optimizing Queries Using Window FunctionsOptimizing Queries Using Window Functions
Optimizing Queries Using Window Functions
 
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.
 
Mysqlfunctions
MysqlfunctionsMysqlfunctions
Mysqlfunctions
 
My sql statements by okello erick
My sql statements by okello erickMy sql statements by okello erick
My sql statements by okello erick
 
MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07
 
MySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That BiteMySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That Bite
 
My sql1
My sql1My sql1
My sql1
 

Último

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
17thcssbs2
 

Último (20)

Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
factors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptxfactors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptx
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 

Cat database

  • 1. [root@koneksi ~]# service mysqld start Starting mysqld: [ OK ] [root@koneksi ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 2 Server version: 5.1.67 Source distribution Copyright (c) 2000, 2012, 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | appPegawai | | coba | | dbpegawai | | mysql | | test | +--------------------+ 6 rows in set (0.04 sec) mysql> create database pbd; Query OK, 1 row affected (0.00 sec) mysql> use pbd; Database changed mysql> show tables; Empty set (0.00 sec) mysql> create table siswa( -> id int primary key, -> nama varchar(30), -> alamat text, -> jk char(1)); Query OK, 0 rows affected (0.08 sec) mysql> show tables; +---------------+ | Tables_in_pbd | +---------------+ | siswa | +---------------+ 1 row in set (0.00 sec) mysql> desc siswa; +--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | id | int(11) | NO | PRI | NULL | | | nama | varchar(30) | YES | | NULL | | | alamat | text | YES | | NULL | | | jk | char(1) | YES | | NULL | | +--------+-------------+------+-----+---------+-------+ 4 rows in set (0.02 sec) mysql> insert into siswa(id, nama, alamat, jk)
  • 2. -> values(1, 'Sapari Andi', 'Mampang', 'L'); Query OK, 1 row affected (0.00 sec) mysql> insert into siswa(id, nama, alamat, jk)values(1, 'Sapari Andi', 'Mampang', 'L') -> ; ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY' mysql> insert into siswa(id, nama, alamat, jk) -> values (2, 'Dede Hidayat'); ERROR 1136 (21S01): Column count doesn't match value count at row 1 mysql> insert into siswa(id, nama) values (2, 'Dede Hidayat'); Query OK, 1 row affected (0.00 sec) mysql> show tables; +---------------+ | Tables_in_pbd | +---------------+ | siswa | +---------------+ 1 row in set (0.00 sec) mysql> desc siswa; +--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | id | int(11) | NO | PRI | NULL | | | nama | varchar(30) | YES | | NULL | | | alamat | text | YES | | NULL | | | jk | char(1) | YES | | NULL | | +--------+-------------+------+-----+---------+-------+ 4 rows in set (0.00 sec) mysql> select * from siswa; +----+--------------+---------+------+ | id | nama | alamat | jk | +----+--------------+---------+------+ | 1 | Sapari Andi | Mampang | L | | 2 | Dede Hidayat | NULL | NULL | +----+--------------+---------+------+ 2 rows in set (0.00 sec) mysql> insert into siswa values(3, 'Heni Lestari', 'Kalibata', 'P'); Query OK, 1 row affected (0.00 sec) mysql> select nama from siswa; +--------------+ | nama | +--------------+ | Sapari Andi | | Dede Hidayat | | Heni Lestari | +--------------+ 3 rows in set (0.00 sec) mysql> select * from siswa; +----+--------------+----------+------+ | id | nama | alamat | jk | +----+--------------+----------+------+ | 1 | Sapari Andi | Mampang | L | | 2 | Dede Hidayat | NULL | NULL | | 3 | Heni Lestari | Kalibata | P | +----+--------------+----------+------+ 3 rows in set (0.00 sec)
  • 3. mysql> update siswa set alamat='Ciamis' where id=2; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from siswa; +----+--------------+----------+------+ | id | nama | alamat | jk | +----+--------------+----------+------+ | 1 | Sapari Andi | Mampang | L | | 2 | Dede Hidayat | Ciamis | NULL | | 3 | Heni Lestari | Kalibata | P | +----+--------------+----------+------+ 3 rows in set (0.00 sec) mysql> update siswa set jk='L' where id=2; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from siswa; +----+--------------+----------+------+ | id | nama | alamat | jk | +----+--------------+----------+------+ | 1 | Sapari Andi | Mampang | L | | 2 | Dede Hidayat | Ciamis | L | | 3 | Heni Lestari | Kalibata | P | +----+--------------+----------+------+ 3 rows in set (0.00 sec) mysql> update siswa set jk=1 where jk='P'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from siswa; +----+--------------+----------+------+ | id | nama | alamat | jk | +----+--------------+----------+------+ | 1 | Sapari Andi | Mampang | L | | 2 | Dede Hidayat | Ciamis | L | | 3 | Heni Lestari | Kalibata | 1 | +----+--------------+----------+------+ 3 rows in set (0.00 sec) mysql> update siswa set jk=0 where jk='L'; Query OK, 2 rows affected (0.00 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysql> select * from siswa; +----+--------------+----------+------+ | id | nama | alamat | jk | +----+--------------+----------+------+ | 1 | Sapari Andi | Mampang | 0 | | 2 | Dede Hidayat | Ciamis | 0 | | 3 | Heni Lestari | Kalibata | 1 | +----+--------------+----------+------+ 3 rows in set (0.00 sec) mysql> delete from siswa where id=2; Query OK, 1 row affected (0.00 sec) mysql> select * from siswa; +----+--------------+----------+------+ | id | nama | alamat | jk | +----+--------------+----------+------+ | 1 | Sapari Andi | Mampang | 0 |
  • 4. | 3 | Heni Lestari | Kalibata | 1 | +----+--------------+----------+------+ 2 rows in set (0.00 sec) mysql> select * from siswa order by alamat; +----+--------------+----------+------+ | id | nama | alamat | jk | +----+--------------+----------+------+ | 3 | Heni Lestari | Kalibata | 1 | | 1 | Sapari Andi | Mampang | 0 | +----+--------------+----------+------+ 2 rows in set (0.00 sec) mysql> create table guru( -> id int primary key auto_increment, -> nama varchar(30), -> alamat text, -> gaji double); Query OK, 0 rows affected (0.06 sec) mysql> insert into guru(nama,alamat,gaji) -> values('Karim Santoso','Pancoran',8000000); Query OK, 1 row affected (0.00 sec) mysql> select * from guru; +----+---------------+----------+---------+ | id | nama | alamat | gaji | +----+---------------+----------+---------+ | 1 | Karim Santoso | Pancoran | 8000000 | +----+---------------+----------+---------+ 1 row in set (0.00 sec) mysql> desc guru; +--------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | nama | varchar(30) | YES | | NULL | | | alamat | text | YES | | NULL | | | gaji | double | YES | | NULL | | +--------+-------------+------+-----+---------+----------------+ 4 rows in set (0.00 sec) mysql> create table mahasiswa( -> npm int primary key auto_increment, -> nama varchar(30), -> ; 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 3 mysql> show tables; +---------------+ | Tables_in_pbd | +---------------+ | guru | | siswa | +---------------+ 2 rows in set (0.00 sec) mysql> create table mahasiswa( -> npm int primary key auto_increment, -> nama varchar(30)); Query OK, 0 rows affected (0.06 sec)
  • 5. mysql> create table matakuliah( -> kodemk int primary key, -> mk varchar(30)); Query OK, 0 rows affected (0.06 sec) mysql> create table krs( -> npm int, -> ta int, -> semester char(1), -> kodemk int); Query OK, 0 rows affected (0.07 sec) mysql> show tables; +---------------+ | Tables_in_pbd | +---------------+ | guru | | krs | | mahasiswa | | matakuliah | | siswa | +---------------+ 5 rows in set (0.00 sec) mysql> desc pbd; ERROR 1146 (42S02): Table 'pbd.pbd' doesn't exist mysql> show tables; +---------------+ | Tables_in_pbd | +---------------+ | guru | | krs | | mahasiswa | | matakuliah | | siswa | +---------------+ 5 rows in set (0.00 sec) mysql> desc krs; +----------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+---------+------+-----+---------+-------+ | npm | int(11) | YES | | NULL | | | ta | int(11) | YES | | NULL | | | semester | char(1) | YES | | NULL | | | kodemk | int(11) | YES | | NULL | | +----------+---------+------+-----+---------+-------+ 4 rows in set (0.00 sec) mysql> desc mahasiswa; +-------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+----------------+ | npm | int(11) | NO | PRI | NULL | auto_increment | | nama | varchar(30) | YES | | NULL | | +-------+-------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec) mysql> desc matakuliah; +--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | kodemk | int(11) | NO | PRI | NULL | | | mk | varchar(30) | YES | | NULL | |