日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

MySql DDL语言(数据库和数据表的管理)

發布時間:2023/12/10 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySql DDL语言(数据库和数据表的管理) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

  數據定義語言,負責數據庫和數據表的管理

⒈數據庫的管理

  1.創建數據庫   

1 create database if not exists DatabaseName; #if not exists可以省略

  2.修改數據庫

   ?、僦孛麛祿烀Q(已經廢棄,強制修改只能到數據庫指向的文件夾重命名后重啟服務)

1 rename database oldDatabaseName to newDatabaseName;

    ②修改數據庫的字符集

1 alter database DatabaseName character set utf8;

  3.刪除數據庫

1 drop database if exists DatabaseName; #if exists可以省略

⒉數據表的管理

  1.創建數據表

1 create table if not exists TableName( #if not exists可以省略 2 id int, 3 name varchar(50) 4 );

  2.修改數據表

    ①修改列名稱

1 alter table TableName change column OldColumnName NewColumnName NewColumnType;

   ?、谛薷牧蓄愋突蚣s束

1 alter table TableName modify column ColumnName NewColumnType;

   ?、厶砑有铝?/p> 1 alter table TableName add column AddColumnName AddColumnType;

    ④刪除列

1 alter table TableName drop column ColumnName;

   ?、菪薷臄祿砻Q

1 alter table TableName rename to NewTableName;

  3.刪除數據表

1 drop table if exists TableName; #if exists可以省略

  4.復制數據表

    ①僅復制數據表結構 

1 create table NewTableName like TableName;

   ?、趶椭茢祿斫Y構+數據表數據

1 create table NewTableName select * from TableName;

   ?、壑粡椭撇糠謹祿頂祿?/p> 1 create table NewTableName select id from TableName where id between 10 and 15;

   ?、軆H僅復制某些字段

1 create table NewTableName select id from TableName where 0;

      0代表恒不成立,可以1=2替代,1代表成立,若篩選條件不成立,則認為沒有合適的數據,則只復制選中的結構

?

轉載于:https://www.cnblogs.com/fanqisoft/p/10697710.html

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的MySql DDL语言(数据库和数据表的管理)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。