msyql常用命令
1.创建、删除数据库
create database dbname;
drop database dbname;
2.选择某一个数据库
use dbname;
3.显示所有表
show tables;
4.查看某一张表的格式
describe tablename;
5.删除某一张表
drop tablename;
6.创建一张表
例如:create table doctor(ID int,name char(20),title char(20),major char(20),office char(20));
7.设置主键的方法
建表时设置
create table tableName( id int primary key );
create table tableName( id int, primary key (id) );
单独设置主键
alter table tableName add primary key(id);
删除主键
alter table tableName drop primary key;
8.设置外键的方法
外键必须唯一(unique或primary key)且非空(NOT NULL)
建表时设置
create table tableName1( tableName2_id int not null, foreign key(tableName2_id) references tableName2(id) );
单独添加外键
alter table tableName1 add constraint tableName1_ref_tableName2(foreignKeyName) foreign key(tableName2_id) references tableName2(id);
删除外键
alter table table1 drop foreign key foreignKeyName;
9.向表格插入内容
insert into employee
(empno,name,office,salary)
values
(1001,'Han Mei',101,3500),
(1003,'Li Lei',102,4200);
10.更改表的表头字段的属性(数据类型,长度等)
alter table 表名称 change 字段名称 字段名称 字段类型 [是否允许非空];
alter table 表名称 modify 字段名称 字段类型 [是否允许非空];
msyql常用命令的更多相关文章
- linux常用软件安装,常用命令
jdk [root@localhost]# tar -zxvf jdk-8u144-linux-x64.tar.gz [root@localhost]# vi /etc/profile 在profil ...
- Linux 常用命令(持续补充)
常用命令: command &:将进程放在后台执行 ctrl + z:暂停当前进程 并放入后台 jobs:查看当前后台任务 bg( %id):将任务转为后台执行 fg( %id):将任务调回前 ...
- LVM基本介绍与常用命令
一.LVM介绍LVM是 Logical Volume Manager(逻辑卷管理)的简写,它是Linux环境下对磁盘分区进行管理的一种机制LVM - 优点:LVM通常用于装备大量磁盘的系统,但它同样适 ...
- Linux学习笔记(一):常用命令
经过统计Linux中能够识别的命令超过3000种,当然常用的命令就远远没有这么多了,按照我的习惯,我把已经学过的Linux常用命令做了以下几个方面的分割: 1.文件处理命令 2.文件搜索命令 3.帮助 ...
- git常用命令(持续更新中)
git常用命令(持续更新中) 本地仓库操作git int 初始化本地仓库git add . ...
- 【原】npm 常用命令详解
今年上半年在学习gulp的使用,对npm的掌握是必不可少的,经常到npm官网查询文档让我感到不爽,还不如整理了一些常用的命令到自己博客上,于是根据自己的理解简单翻译过来,终于有点输出,想学习npm这块 ...
- npm常用命令
npm常用命令 环境:win7 npm 是什么 NPM(node package manager),通常称为node包管理器.顾名思义,它的主要功能就是管理node包,包括:安装.卸载.更新.查看.搜 ...
- Git 常用命令
一.初始環境配置 git config --global user.name "John Doe"git config --global user.email johndoe@ex ...
- linux iptables常用命令之配置生产环境iptables及优化
在了解iptables的详细原理之前,我们先来看下如何使用iptables,以终为始,有可能会让你对iptables了解更深 所以接下来我们以配置一个生产环境下的iptables为例来讲讲它的常用命令 ...
随机推荐
- [LeetCode] 908. Smallest Range I 最小区间
Given an array A of integers, for each integer A[i] we may choose any x with -K <= x <= K, and ...
- [LeetCode] 210. Course Schedule II 课程清单之二
There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may have prereq ...
- [LeetCode] 207. Course Schedule 课程清单
There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may have prereq ...
- oracle--错误笔记(二)--ORA-16014
ORA-16014错误解决办法 01.问题以及解决过程 SQL> select status from v$instance; STATUS ------------ MOUNTED SQL&g ...
- ASP.NET Core2使用Autofac实现IOC依赖注入竟然能如此的优雅简便(转载)
原文地址:https://www.cnblogs.com/Andre/p/9604759.html 初识ASP.NET Core的小伙伴一定会发现,其几乎所有的项目依赖都是通过依赖注入方式进行链式串通 ...
- 第28课 “共享状态”提供者(std::promise/std::package_task)
一. std::promise和std::package_task (一)共享状态.提供者和管理者 // CLASS TEMPLATE _Promise template <class _Ty& ...
- 微信企业号消息接口PHP SDK
微信企业号消息接口PHP SDK及Demo <?php /* 方倍工作室 http://www.fangbei.org/ CopyRight 2015 All Rights Reserved * ...
- 动手学深度学习8-softmax分类pytorch简洁实现
定义和初始化模型 softamx和交叉熵损失函数 定义优化算法 训练模型 import torch from torch import nn from torch.nn import init imp ...
- Python文件读写机制
Python提供了必要的函数和方法进行默认情况下的文件基本操作 文件打开方式: open(name[,mode[buf]]) name:文件路径 mode:打开方式 buf:缓冲buffering大小 ...
- Can't locate Math/Round.pm in @INC
遭遇报错: Can't locate Math/Round.pm in @INC 经过亲自测试,下面的命令解决了我的问题. yum install perl-Math-Round 参考资料 ===== ...