공 지

본 사이트는 지속적으로 업데이트 되고 있답니다. 혹시, 화면 구성이 이상하게 보인다면, "Ctrl+F5"를 이용하여 "새로 고침"을 시도해 보세요.

C/C++ 강의 C++의 핵심, 클래스를 업로드 했습니다.

실무 Python 강의 Flask Web Framework 를 올렸습니다.














DB SQL(Structured Query Language) Note

- tested with Mysql in Ubuntu
- ">": DB server cursor, "$": Terminal cursor

Want To Sql code
Database Connect to a database

> connect db_name;

Create a database Syntax: "create database db_name db_specification",
For example,

> CREATE DATABASE db_name;
> CREATE DATABASE db_name character set UTF8 collate utf8_general_ci;
> CREATE DATABASE db_name character set UTF8mb4 collate utf8mb4_bin;

Use a database

> USE db_name;

Show a database

> SHOW db_name;

Delete a database

> DROP database db_name;

Export a database to a file In Terminal,

$ mysqldump -u user_name -p db_name > db_dump_name.sql

Import a database from a file In Terminal,

$ mysql -u user_name -p db_name < db_dump_name.sql


If you see an error of "unknown database", create a database named "db_name" first.
Table Create a table Syntax: "CREATE TABLE tlb_name (column_name_1 column_datatype_1, column_name_2 column_datatype_2, ...)"
For example,

> CREATE TABLE tbl_name (idnum INT AUTO_INCREMENT primary key NOT NULL, email VARCHAR(50) UNIQUE NOT NULL, visit BIGINT DEFAULT 0, visit SMALLINT DEFAULT 0, DATUM DATE NOT NULL);

Show tables

> SHOW tables;

Show columns from a table

> SHOW columns FROM tbl_name;

Show column definition of a table

> DESCRIBE tbl_name;

Show all column information of a table

> SHOW FULL COLUMNS FROM table_name;

Delete a table

> DROP TABLE tbl_name;

Add a column to a table Syntax: "ALTER TABLE tbl_name ADD COLUMN column_name column_datatype AFTER column_name_2"
For example,

> ALTER TABLE tbl_name ADD COLUMN column_name varchar(15) AFTER column_name_2;
> ALTER TABLE tbl_name ADD COLUMN column_name varchar(50) character set utf8 collate utf8_general_ci not null;

Modify a column in a table Syntax: "ALTER TABLE tbl_name MODIFY column_name column_datatype"
For example,

> ALTER TABLE tbl_name MODIFY column_name int(11);

Delete a column in a table

> ALTER TABLE tbl_name DROP COLUMN column_name;

Get data from a table Get data for column_name_0:

> SELECT column_name_0 FROM tbl_name WHERE column_name_1 condition_1 column_name_2 condition_2;

Get data for all columns:

> SELECT * FROM tbl_name WHERE column_name_1 condition_1 column_name_2 condition_2;

Insert data into a table

> INSERT INTO tbl_name VALUES (column_val_1, column_val_2, ..., column_val_n);

Update data in a table Syntax: "UPDATE tbl_name SET column_name_1=value WHERE column_name_2 condition_2"
For example,

> UPDATE tbl_name SET column_name_1=column_name_1+72 WHERE column_name_2=12;

Delete data from a table

> DELETE FROM tbl_name WHERE column_name_1=condition_1;






발자취

2019-09-11 "키클 코딩랩 - 미국 공학박사 아빠의 코딩 연구소"로 이름 변경
2019-06-28 코딩 교실 공개
2019-03-18 코딩 교실 제작 시작

바로가기
Python 배움터
C/C++ 배움터
About
Contact
Privacy Policy
강의목록
질문하기
처음으로