Learning SQL for beginners (0)Ajenda
Bài đăng này đã không được cập nhật trong 9 năm
If you do not know about computer system development and want to learn SQL, this post may be helpful for you.
This post is an agenda, so in other post, more detail information will be written.
1. Prepare
At first, you can visit a site bellow: http://www.wampserver.com/
After that, you can download and install to your computer. By the way, although you learn about SQL, why WAMP is required? Actually only MySQL is enough. but somehow the file size of WAMP is smaller than My SQL. So you can download and install it quickly.
2. Setting
After WAMP has been installed, open bellow: http://localhost/phpmyadmin
Database -> Create database -> ( name ) -> Create
3. Practice
Next, open "mySQL consle"
password :(null)
use (name)
- create
CREATE TABLE TMEMBER01(
NID INT(3),
CNAME VARCHAR(30),
CADDRESS VARCHAR(40),
DBIRTHDATE DATE,
CNOTICE VARCHAR(20)
);
- drop
drop table tmember01;
- select (show)
SELECT
*
FROM
TMEMBER01;
-- This is same as upward
SELECT
NID, CNAME, CADDRESS, DBIRTHDATE, CNOTICE
FROM
TMEMBER01;
- insert
insert into TMEMBER01(
NID, CNAME, CADDRESS, DBIRTHDATE, CNOTICE
)
values(
101, 'Yokota Kaoru', 'Cau Giay', '1978/05/15', 'employee'
);
---
insert into TMEMBER01(
NID, CNAME, CADDRESS, DBIRTHDATE, CNOTICE
)
values(
102, 'Suzuki Takashi', 'Trang Thay Tong', '1981/09/01', 'employee'
);
---
insert into TMEMBER01(
NID, CNAME, CADDRESS, DBIRTHDATE, CNOTICE
)
values(
103, 'Yamada Norio', 'Kim Ma', '1989/12/03', 'intern'
);
- clone
-- with records
CREATE TABLE TMEMBER02
SELECT * FROM TMEMBER01;
-- without records, that is, only table def
CREATE TABLE TMEMBER11
SELECT * FROM TMEMBER01
where 1=0;
- update
UPDATE
TMEMBER01
SET
CADDRESS ='Dao Cat Ba'
where
NID=103;
- delete
DELETE FROM
TMEMBER01
WHERE
NID=102;
- all delete
TRUNCATE TABLE TMEMBER01;
This is same as "DELETE FROM TMEMBER01;". But it is faster than delete command, and better memory usage.
4. End of Practice
exit
5. Appendix
if you are an Oracle Database Programmer, you can find some difference between Oracle and MySQL.
How different are data types?
Oracle | MySQL |
---|---|
number | int |
varchar2 | varchar |
date | datetime |
[note]In fact, we can use "date" in MySQL. But it is quite different with Oracle. In MySQL, "date" can have only "YYYY/MM/DD" although Oracle can have "YYYY/MM/DD hh:mm:ss". When we want to have "YYYY/MM/DD hh:mm:ss" in MySQL, we have to use "datetime" type.
この記事は英語版です。日本語版は以下リンクをどうぞ。
https://viblo.asia/Kaoru/posts/YAQrMJw7G40E
All rights reserved