数据库(12.27 day 1)

一.软件安装;

二.SQL指令分类;

三.DDL指令(库,表);

一.Mysql,Navicat安装

        略;

二.SQL指令分为四类:

三.DDL-数据库操作

        1.查询数据库

                show database;  //显示数据库列表

                show create database  <dbName> ; //显示创建的SQL指令

        2.创建数据库

                create database  <dbName> ;

                (create database if not exists <dbName>;)

        3.创建数据库时指定字符集

                create database  <dbName>  character set utf-8;

        4.修改数据库字符集

                alter database  <dbName>  character set utf-8;  //utf-8   gbk

        5.删除数据库

                drop database (if exists)  <dbName>;

        6.使用/切换数据库

                use <dbName>;

        

        7.创建数据表

                create table students(

                ......

);

        

        not null    //非空

        unique    //字段值不重复

        char()    //定长

        varchar()    //非定长

        8.查询数据表

                show tables;

        

        9.查询表结构

                desc <tableName>;

        

        10.删除数据表

                drop table  (if exists) <tableName>;

        11.修改数据表

                alter table <tableName> rename to <newtableName>;  //修改表名

                alter table <tableName> character set utf8;  //修改表字符集

                alter table <tableName> add 字段名 类型;//添加字段(列)

                alter table <tableName> change 旧字段名 新字段名 类型;  //修改字段名和类型

                alter table <tableName> modify 字段名 类型;  //只修改字段类型

                alter table <tableName> drop 字段名;//删除字段(列)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值