zoukankan      html  css  js  c++  java
  • 【2020082504】数据表的管理-表的基本操作

    1. 创建表(指定字符集)

    create table 表名(

        字段名 数据类型 约束,---约束可以不写,也可以有很多,且顺序不限制

        字段名 数据类型 约束,

        ...

        字段名 数据类型 约束

        );

    1. 如果你想设置数字为无符号则加上 unsigned
    2. 如果你不想字段为NULL可以设置字段的属性为 NOT NULL,在操作数据库时如果输入该字段的数据为NULL,就会报错
    3. DEFAULT表示设置一个字段的默认值
    4. AUTO_INCREMENT定义列为自增的属性,一般用于主键,数值会自动加1
    5. PRIMARY KEY关键字用于定义列为主键,主键的值不能重复。

    e.g. 创建班级表

    create table class_1 (

        id int primary key auto_increment,

        name varchar(32) not null,

        age int not null);

    2. 查看数据库中的表

    -- use 数据库名;

    -- show tables;

    3.查看数据表结构

    desc 数据表名;

  • 相关阅读:
    [Leetcode]@python 89. Gray Code
    [Leetcode]@python 88. Merge Sorted Array.py
    [Leetcode]@python 87. Scramble String.py
    [Leetcode]@python 86. Partition List.py
    [leetcode]@python 85. Maximal Rectangle
    0523BOM
    0522作业星座
    0522dom
    0520
    0519作业
  • 原文地址:https://www.cnblogs.com/zhouxue0621/p/13560338.html
Copyright © 2011-2022 走看看