MySQL創(chuàng)建數(shù)據(jù)庫和創(chuàng)建數(shù)據(jù)表
創(chuàng)建數(shù)據(jù)庫
1. 連接 MySQL? ? ? mysql -u root -p?
2. 查看當(dāng)前的數(shù)據(jù)庫? show databases;
3. 創(chuàng)建數(shù)據(jù)庫? create database 數(shù)據(jù)庫名; 創(chuàng)建數(shù)據(jù)庫
4. 創(chuàng)建數(shù)據(jù)庫時(shí)設(shè)置字符編碼??create database 數(shù)據(jù)庫名 character set utf8;?
5. 查看和顯示數(shù)據(jù)庫的編碼方式? show create database 數(shù)據(jù)庫名; 顯示數(shù)據(jù)庫的創(chuàng)建信息。
6. 進(jìn)入或切換數(shù)據(jù)庫???use 數(shù)據(jù)庫名 進(jìn)入或切換數(shù)據(jù)庫
7. 顯示當(dāng)前數(shù)據(jù)庫 select database();
創(chuàng)建數(shù)據(jù)表
1. 查看當(dāng)前數(shù)據(jù)庫中的表???show tables;查看當(dāng)前數(shù)據(jù)庫中有哪些表
2. 創(chuàng)建表 create table 表名; 來創(chuàng)建一張表。
3. 顯示表信息 show create table 表名; 來顯示已創(chuàng)建的表的信息
4. 給表增加字段? alter table 表名 add 字段名 數(shù)據(jù)類型; 為已存在的表添加一個(gè)新字段。
?
5. 刪除表的字段 alter table 表名 drop 字段名; 刪除一個(gè)表中已存在的字段。
?
6. 修改字段的數(shù)據(jù)類型? alter table 表名 modify 字段名 數(shù)據(jù)類型; 修改表中現(xiàn)有字段的數(shù)據(jù)類型。
?文章來源地址http://www.zghlxwxcb.cn/news/detail-631077.html
7. 修改字段的數(shù)據(jù)類型并且改名 alter table?
文章來源:http://www.zghlxwxcb.cn/news/detail-631077.html
?
到了這里,關(guān)于MySQL(1) MySQL創(chuàng)建數(shù)據(jù)庫和創(chuàng)建數(shù)據(jù)表的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!