Mysql 資料庫操作

2021-08-07 21:19:57 字數 3596 閱讀 9612

--給資料庫表增加字段

alter table baofoo_ma.`ma_merchant_company` add estimated_tran_amount decimal(20,2) default null comment '商戶預估筆均交易金額'

-- 注意 comment ''中間是空格不是"="

-- 建立資料庫

create database baofoo_ma;

-- 建立表

use baofoo_ma;

create table baofoo_ma.`ma_project_request` (

`id` bigint(20) not null auto_increment comment '表主鍵',

`request_id` varchar(100) not null comment '需求專案id',

`request_name` varchar(100) not null comment '需求名稱',

`request_des` varchar(300) not null comment '需求描述',

`request_time` timestamp not null default current_timestamp comment '需求提出時間',

`request_dept_id` int(11) not null comment '需求部門(1:商戶營銷中心;2:技術支援;3:新顏徵信;4:清算部;5:風險管理中心; 6: 產品研發中心;7:財務部;8:金融合作部;9:科技事業部;10:資管事業部;11:跨境事業部;12:客服部;99:其他)',

`request_provider` varchar(50) not null comment '需求提出人',

`leader` varchar(50) not null comment '直屬領導',

`product_id` varchar(100) not null comment '涉及產品id(1:認證;2:代扣;3:快捷;4:網銀b2c;5:網銀b2b;6:代付;7:清算對賬;8:退款;9:聚合支付;10:渠道能力;11:資金存管;12:徵信;13:跨境;14:資管;99:其他)',

`model` int(11) not null comment '涉及模組(1:商戶對接介面或介面;2:商戶前台;3:ad管台;4:官網;5:測試環境;6:渠道接入;99:其他)',

`influence_range` int(11) not null comment '影響範圍(1:大商戶定製;2:新行業標準;3:新產品功能;99:其他)',

`trade_estimate` varchar(50) default null comment '預計影響交易量',

`product_manager` varchar(50) not null comment '產品經理',

`request_detail` varchar(200) not null comment '具體需求梳理',

`product_addr` varchar(100) default null comment 'jira工單位址',

`priority` tinyint(4) not null comment '優先順序(1:一星;2:二星;3:三星)',

`uptime_estimate` timestamp not null default current_timestamp comment '預計上線時間',

`workload` int(11) not null comment '產品研發工作量',

`remark` varchar(200) default null comment '備註',

`state` int(11) not null comment '需求狀態(1:提交;2:評審;3:開發;4:測試;5:上線;6:終止;7:重啟)',

`update_time` timestamp null default current_timestamp comment '變更時間',

`develop_group` varchar(100) default null comment '開發小組',

`develop_man` varchar(50) default null comment '開發人員',

`test_man` varchar(50) default null comment '測試人員',

`file_url` varchar(100) default null comment '附件url位址',

`file_type` varchar(10) default null comment '檔案型別',

primary key (`id`)

) engine=innodb auto_increment=11 default charset=utf8

-- 展示建立表資訊

show create table baofoo_ma.ma_merchant_pay_card;

-- 給表名加注釋 

create table `ma_merchant_payment` (

`id` int(11) not null auto_increment comment '主鍵',

`member_id` bigint(20) not null comment '商戶號',

`state` tinyint(3) not null default '1' comment '狀態 1:開啟;0:禁用',

`create_time` timestamp not null default current_timestamp comment '建立時間',

`create_by` varchar(50) default null comment '建立人',

`update_time` timestamp null default current_timestamp comment '更新時間',

`update_by` varchar(50) default null comment '更新人',

primary key (`id`),

unique key `member_id` (`member_id`)

) engine=innodb auto_increment=1 default charset=utf8 comment='商戶付款表'; 

拷貝源表資料到備份表:

批量新增:

alter table

table

add(`customer_name_pre` varchar(255) not null comment '所屬客戶(歷史)'

,`customer_name_after` varchar(255) not null comment '所屬客戶(當前)');

批量修改:

alter table baofoo_ma.`ma_merchant_change_info_log` 

modify column `customer_name_pre` varchar (255) default null comment '所屬客戶(歷史)',

modify column  `customer_name_after` varchar (255) default null comment '所屬客戶(當前)';

mysql資料庫核對 Mysql資料庫操作總結

1 部署資料庫服務 mariadb yum install y mariadb 運算元據庫命令 mariadb server 啟動資料庫服務 systemctl startmariadb 建立資料庫 create database 資料庫名 建立好資料庫之後可以檢視資料庫是否建立 show data...

mysql資料庫基本操作 MYSQL資料庫基本操作

1.連線mysql mysql u 使用者名稱 p 回車後要求輸入密碼,密碼不可見 2.退出mysql命令 exit 回車 3.修改密碼 mysqladmin u使用者名稱 p舊密碼 password 新密碼4.檢視mysql許可權和使用者select host,user fromuser 對資料庫...

mysql資料庫語法 MySQL資料庫操作語法詳解

1 資料庫建立 建庫語句如下 create database schema會建立乙個給定名稱的資料庫,只有擁有create許可權才能使用該語法。不加if not exists時,如果需要建立資料庫已經同名存在則會報錯。create specification中指定了建立資料庫特性。資料庫特性存放在資...