zoukankan      html  css  js  c++  java
  • 显示数据库中的所有表和所有数据库

    MSSQL中查询所有数据库

    方法1:select * from sysdatabases;

    方法2:exec sp_helpdb(使用存储过程查询)

    MSQL中查询数据库中的所有表

    方法1:select * from sysobjects;

    方法2:exec sp_help(使用存储过程查询)

    MySQL中查询所有数据库

    show databases;

    MySQL数据库中查询所有表

    show tables;

    --------------------------------

    插入一个表中的数据有三种方法:

    1、insert into student values(5,116,26,90); // 即插入这一行的数据个数、类型一致。 即student里面的所有字段。

    或者insert into student(id,name) values(5,116);

    2、insert into student set name=116,id=5;

    3、复制一个表 insert into student2 select * from student; 

    ------------------------------------

    select * from student where classGrent between 20 and 30;

    ------------------------

    create database 数据库名;
    create table student2(id int(8),name varchar(12),classGrent varchar(12) result varchar(12)); 创建表
    ------------------
    alter table 表名 rename to 新表名
    -------------------------------------
    更新表中数据
    mysql>update MYTABLE set sex="f" where name='hyq'; 

    update newstudentinfo set name='zhangsan' where id=1; 

    --------------------------------------------------------------

    修改表中的某个字段

    修改某个表的字段类型及指定为空或非空
    >alter table 表名称 change 字段名称 字段名称 字段类型 [是否允许非空];
    >alter table 表名称 modify 字段名称 字段类型 [是否允许非空];

    >alter table 表名称 modify 字段名称 字段类型 [是否允许非空];

    修改字段名:

         alter table     tablename    change   old_field_name    new_field_name  old_type;

     

  • 相关阅读:
    linux运维之分析系统负载及运行状况
    linux运维之分析日志相关命令(1)
    centos7修改网卡名称为eth0
    LANMP环境编译参数查看方法
    自动化部署之搭建yum仓
    浙大 PAT 乙级 1001-1075 目录索引
    更改docker服务网段分配地址
    MySQL主从复制(Replication for Backup)
    MySQL读写分离-简单思考
    NGINX负载均衡缓存配置
  • 原文地址:https://www.cnblogs.com/bluewelkin/p/3679904.html
Copyright © 2011-2022 走看看