SQL建表,包含主键,自增ID,默认值,字段注释,表注释

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 17:58   1187   0

#创建数据表SQL语句

我这里是python

sql= '''
    create table test_users(
        id int primary key not null auto_increment comment 'ID',
        name varchar(100) not null comment '用户名',
        nickname varchar(100) not null comment '昵称',
        password varchar(32) not null comment '密码',
        state int not null default "1" comment '状态,1为正常,0为禁用'
    )
'''

#修改表注释

table_sql = '''
    alter table test_users comment='测试用户表';
'''
cursor.execute(sql)
cursor.execute(table_sql)

作为一名合格的PHP不仅需要好的代码编写能力,还需要掌握服务器相关知识,下面给大家推荐腾讯云搞活动的服务器,刚开始不需要服务器配置太好,纯当练手!点击链接查看官方活动https://cloud.tencent.com/act/cps/redirect?redirect=1067&cps_key=32f906e6e5f3be5e8669b35951da56fc&from=console

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP