node.js - 2
2019.10.08 08:55
Node.js MySQL Drop Table
조회 수 357 추천 수 0 댓글 0
테이블 삭제
var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "yourusername", password: "yourpassword", database: "mydb" }); con.connect(function(err) { if (err) throw err; var sql = "DROP TABLE customers"; con.query(sql, function (err, result) { if (err) throw err; console.log("Table deleted"); }); });
C:\Users\Your Name>node demo_db_drop_table.js
Table deleted
테이블이 존재하는 경우 삭제
var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "yourusername", password: "yourpassword", database: "mydb" }); con.connect(function(err) { if (err) throw err; var sql = "DROP TABLE IF EXISTS customers"; con.query(sql, function (err, result) { if (err) throw err; console.log(result); }); });
C:\Users\Your Name>node demo_db_drop_table_if.js
테이블이 존재하는 경우의 결과객체(Result Object)
{ fieldCount: 0, affectedRows: 0, insertId: 0, serverstatus: 2, warningCount: 0, message: '', protocol41: true, changedRows: 0 }
테이블이 없는 경우의 결과객체
{ fieldCount: 0, affectedRows: 0, insertId: 0, serverstatus: 2, warningCount: 1, message: '', protocol41: true, changedRows: 0 }
번호 | 분류 | 제목 | 날짜 | 조회 수 |
---|---|---|---|---|
38 | node.js - 1 | Express에서 POST 방식 사용하기 | 2019.10.16 | 349 |
37 | node.js - 1 | Express에서 MySql 사용 | 2019.10.10 | 843 |
36 | node.js - 2 | Node.js MySQL Limit | 2019.10.10 | 288 |
35 | node.js - 2 | Node.js MySQL Update | 2019.10.10 | 276 |
» | node.js - 2 | Node.js MySQL Drop Table | 2019.10.08 | 357 |
33 | node.js - 2 | Node.js MySQL Delete | 2019.10.08 | 302 |
32 | node.js - 2 | Node.js MySQL Order By | 2019.10.08 | 285 |
31 | node.js - 2 | Node.js MySQL Where | 2019.10.08 | 494 |
30 | node.js - 2 | Node.js MySQL Select From | 2019.10.08 | 630 |
29 | node.js - 2 | Node.js MySQL Insert Into | 2019.10.01 | 933 |
28 | node.js - 2 | Node.js MySQL Create Table | 2019.10.01 | 324 |
27 | PUG | PUG 07 / INCLUDES | 2019.10.01 | 358 |
26 | PUG | PUG 06 / DOCTYPE | 2019.10.01 | 431 |
25 | node.js - 2 | Node.js MySQL | 2019.09.27 | 315 |
24 | node.js - 2 | NPM의 사용 | 2019.09.26 | 313 |
23 | node.js - 2 | Node.js URL Module | 2019.09.26 | 461 |
22 | PUG | PUG 05 / Conditionals | 2019.09.19 | 755 |
21 | PUG | PUG 04 / Comments | 2019.09.19 | 329 |
20 | PUG | PUG 03 / Code | 2019.09.19 | 691 |
19 | PUG | PUG 02 / Case | 2019.09.19 | 367 |