1 / 13

MySQL API( c ) & SQL2

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

emily-olson
Download Presentation

MySQL API( c ) & SQL2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MySQL API( c ) & SQL2 Please@sparcs.kaist.ac.kr 강동훈

  2. Contents • Overview • How to use MySQL(SQL2) • How to use MySQL API (in C)

  3. Overview • SQL • Structured Query Language • based on the relational database. • Data definition • Data manipulation • Query • MySQL

  4. 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

  5. How to use MySQL #2 • Data Definition 1 mysql> SHOW DATABASES;

  6. 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>

  7. 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 테이블명(컬럼의 형식);

  8. 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 조건];

  9. 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 조건];

  10. Process 1.connect to SQL server 2.Quest Queries 3.manipulate result sets How to use MySQL API(in C) #1

  11. 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()

  12. Gcc –g –o mysqlapiexample mysqlapiexample.c –L/usr/lib/mysql –lmysqlclient

  13. How to use MySQL API(in C) #4 • C API Function Description

More Related