1 Star 0 Fork 0

QQXQQ/Relatdb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
test.go 620 Bytes
一键复制 编辑 原始数据 按行查看 历史
QQXQQ 提交于 2024-06-08 15:46 . 20240608
package main
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func main() {
db, err := sql.Open("mysql", "root:123456@tcp(localhost:3306)/default")
if err != nil {
panic(err)
}
res, err := db.Exec(`
create table if not exists User(
id INT PRIMARY KEY AUTO_INCREMENT COMMENT '主键',
email VARCHAR(50) UNIQUE COMMENT '邮箱',
age INT UNSIGNED DEFAULT 1 COMMENT '年龄',
noId INT(6) ZEROFILL
);
insert into User VALUES (1,'1@qq.com',1,1);
insert into User(id,noId,email,age) VALUES (1,1,'1@qq.com',1);
`)
if err != nil {
panic(err)
return
}
println(res)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/QQXQQ/Relatdb.git
git@gitee.com:QQXQQ/Relatdb.git
QQXQQ
Relatdb
Relatdb
master

搜索帮助