Project

General

Profile

MySQL操作相关

Added by W.Happy 4 months ago

-- 创建数据库
CREATE DATABASE hello;

-- 创建数据库表
CREATE TABLE posts (id INT NOT NULL, name: VARCHAR(255), title: VARCHAR(255), CONSTRAINT pk_posts_id PRIMARY KEY(id));

-- 插入数据
INSERT posts (id, name, title) VALUES (1, 'name1', 'title1');

-- 更新表
UPDATE posts SET name='name1_v1', title='title1_v1' WHERE id = 1;

-- 开始事务:https://dev.mysql.com/doc/refman/5.7/en/commit.html
START TRANSACTION;

-- 提交事务
COMMIT;