国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學習啦 > 學習電腦 > 操作系統(tǒng) > Linux教程 > linux中mysql基本命令

    linux中mysql基本命令

    時間: 佳洲1085 分享

    linux中mysql基本命令

      linux中mysql數(shù)據(jù)庫是經(jīng)常用到的數(shù)據(jù)庫,掌握有關(guān)的基本命令能讓我們更好的學習linux中的mysql,下面由學習啦小編整理了linux的mysql基本命令的相關(guān)知識,希望對你有幫助。

      linux中mysql基本命令一、mysql數(shù)據(jù)庫操作

      創(chuàng)建數(shù)據(jù)庫

      create database database_name;

      GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON 數(shù)據(jù)庫名.* TO 數(shù)據(jù)庫名@localhost IDENTIFIED BY '密碼';

      SET PASSWORD FOR '數(shù)據(jù)庫名'@'localhost' = OLD_PASSWORD('密碼');

      查看數(shù)據(jù)庫

      show databases;

      使用數(shù)據(jù)庫

      use database_name;

      刪除數(shù)據(jù)庫

      drop database if exists database_name;

      linux中mysql基本命令二、mysql數(shù)據(jù)表操作

      創(chuàng)建表

      CREATE TABLE `tbl_user_info` (

      `id` int(12) unsigned NOT NULL AUTO_INCREMENT COMMENT '用戶id',

      `name` varchar(48) NOT NULL COMMENT '用戶名(拼音)',

      `ch_name` varchar(32) NOT NULL COMMENT '用戶名(中文)用于顯示',

      `type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '0:管理員 1:普通用戶',

      `description` varchar(256) DEFAULT NULL COMMENT '備注',

      `add_time` timestamp NOT NULL DEFAULT '1971-01-01 01:01:01' COMMENT '操作時間',

      `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '編輯修改時間',

      `operator` varchar(50) NOT NULL DEFAULT '' COMMENT '操作人',

      `extends` varchar(2048) NOT NULL DEFAULT '' COMMENT '擴展位',

      `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '0:用戶注銷 1:用戶有效',

      PRIMARY KEY (`id`),

      KEY `idx_operator` (`operator`)

      ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用戶權(quán)限配置明細表(用于記錄給用戶配置的權(quán)限信息) 王X 2016-09-12';

      查看數(shù)據(jù)庫中的表

      show tables;

      查看表結(jié)構(gòu)

      show create table table_name \G

      修改表名

      rename table old_table_name to new_table_name;

      刪除表

      drop table table_name; DROP TABLE會永久性地取消表定義

      刪除表記錄

      delete from tbl_user_account where id=5;

      更新表記錄

      update tbl_user_account set username=‘zhangsan' where id=5;

      插入表記錄

      insert into tbl_user_account (字段1,字段2,字段3,…) values(1,2,3,...);

      查找表記錄

      select * from tbl_user_account where id=5;

      增加表字段

      alter table tbl_user_account add flag tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:未設(shè)置權(quán)限 1:已設(shè)置權(quán)限';

      刪除表字段

      alter table tbl_user_account drop field_name;

      修改原字段名稱和類型

      alter table tbl_user_account change old_field_name new_field_name field_type;

      增加索引

      alter table tbl_user_account add index index_name(field_name);

      增加唯一索引

      alter table tbl_user_account add unique index_name(field_name);

      增加主鍵索引

      alter table tbl_user_account add primary key index_name(field_name);

      刪除索引

      alter table tbl_user_account drop index index_name;

    3629820