160 likes | 356 Views
MySQL API( c ) & SQL2. Please@sparcs.kaist.ac.kr 강동훈. Contents. Overview How to use MySQL(SQL2) How to use MySQL API (in C). Overview. SQL Structured Query Language based on the relational database. Data definition Data manipulation Query MySQL. Connect to MySQL Server
E N D
MySQL API( c ) & SQL2 Please@sparcs.kaist.ac.kr 강동훈
Contents • Overview • How to use MySQL(SQL2) • How to use MySQL API (in C)
Overview • SQL • Structured Query Language • based on the relational database. • Data definition • Data manipulation • Query • MySQL
Connect to MySQL Server shell> mysql -h host -u user -p <사용할 DB> <Enter> password: ******** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 459 to server version: 3.22.20a-log Type 'help' for help. mysql> How to use MySQL #1
How to use MySQL #2 • Data Definition 1 mysql> SHOW DATABASES;
How to use MySQL #3 • Data Definition 2 mysql> CREATE DATABASE docmanager; mysql> USE docmanager Database changed mysql> SHOW TABLES; Empty set (0.00 sec) mysql> 형식 : CREATE DATABASE <DATABASE NAME>; USE <사용할 DB NAME>
Data definition 3 How to use MySQL #4 mysql> CREATE TABLE docmanager (title VARCHAR(40), description -> VARCHAR(40),file_name VARCHAR(20), -> enrolled DATE, updated DATE, owner VARCHAR(20)); (CF) desc 형식 : CREATE TABLE 테이블명(컬럼의 형식);
How to use MySQL #5 • Data Manipulation 1 mysql> INSERT INTO docmanager -> VALUES(‘MySQL Seminar', ‘MySQL?', ‘MySQL.ppt', ‘2000-07- ‘> 04',’2000-07-05’, ‘please’); mysql> UPDATE docmanager SET updated=“2000-07-06" WHERE title=“MySQL Seminar"; 형식: INSERT INTO 테이블명 VALUES(컬럼의 데이터 값..); UPDATE 테이블명 SET 컬럼명 = 식,… [WHERE 조건];
How to use MySQL #5 • Data manipulation 2 mysql> SELECT * FROM docmanager; mysql> SELECT * FROM docmanager WHERE owner = “please"; mysql> SELECT owner FROM docmanager; 형식: SELECT 컬럼명 … from 테이블명 [WHERE 조건];
Process 1.connect to SQL server 2.Quest Queries 3.manipulate result sets How to use MySQL API(in C) #1
How to use MySQL API(in C) #2 Mysql_init() Mysql_store_result() Mysql_use_result() Mysql_real_connect() Mysql_fetch_row() Mysql_query() Mysql_real_query() Mysql_free_result() If result set exists(only to “SELECT” Query) Mysql_close()
Gcc –g –o mysqlapiexample mysqlapiexample.c –L/usr/lib/mysql –lmysqlclient
How to use MySQL API(in C) #4 • C API Function Description