1.建立乙個名稱為employee的mysql預設型別myisam表
create table employee (id smallint(5) not null,depno int(5) not null,name varchar(20) not null,cardnumber int(15) not null,primary key (id,depno));
插入一條記錄
insert into employee values(1,805,'jim',2010090101);
2.建立和employee的表結構一樣的乙個表employee1
create table employee1 like employee
3.建立帶有employee表資料的表employee2
create table employee2 select * from employee
4.在mysql資料庫中建立乙個employee表
create table mysql.employee like employee;
5.顯示建立表employee的表結構
mysql> desc mysql.employee;
| field | type | null | key | default | extra |
| id | smallint(5) | no | pri | null | |
| depno | int(5) | no | pri | null | |
| name | varchar(20) | no | | null | |
| cardnumber | int(15) | no | | null | |
4 rows in set (0.01 sec)
mysql> drop table mysql.employee;
query ok, 0 rows affected (0.00 sec)
6.在mysql資料庫中建立乙個帶有資料的employee表
mysql> create table mysql.employee select * from employee;
query ok, 1 row affected (0.02 sec)
records: 1 duplicates: 0 warnings: 0
mysql> select * from mysql.employee;
| id | depno | name | cardnumber |
| 1 | 805 | liming | 2010090101 |
1 row in set (0.00 sec)
分享到:
2011-08-12 15:56
瀏覽 1019
分類:資料庫
mysql5 6更改資料庫編碼
今天在測試環境上出現了亂碼,但是同樣的程式在正式環境 阿里雲 沒有亂碼。檢視了一下mysql編碼發現,測試環境的編碼不全是utf8。所以需要將mysql的編碼都設定成utf8。正式環境和測試環境的mysql編碼截圖如下 解決方案如下 1 將mysql的安裝目錄的my default.ini複製乙份,...
MySQL 5 6 資料型別
數值型別型別 說明大小 有符號範圍 無符號範圍 bit位欄位,1 64位 tinyint 整數值1位元組 128,127 0,255 smallint 整數值2位元組 32768,32767 0,65535 mediumint 整數值3位元組 8388608,8388607 0,16777215 i...
mysql5 6 資料型別
int 5 表示顯示寬度為5,預設為顯示寬度11.zerofill屬性 用0填充前面空位 auto increment屬性 只用於整數。一般從1開始,每行增加1.乙個表最多只能有乙個這樣的列。對於要使用auto increment的列應該定義為not null並定義為primary key或uniq...