Skip to content

Commit 898753e

Browse files
authored
Update memo.md
1 parent 6f49705 commit 898753e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

MySQL/memo.md

+25
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,28 @@ SELECT * FROM information_schema.PROCESSLIST;
7474
show processlist;
7575
```
7676

77+
### テーブル定義の確認
78+
- CREATE TABLE文を取得
79+
```sql
80+
SHOW CREATE TABLE tablename;
81+
```
82+
83+
- SQLの結果で取得
84+
```sql
85+
SHOW FULL COLUMNS FROM tablename;
86+
```
87+
```sql
88+
DESC tablename;
89+
```
90+
91+
### テーブルコピー
92+
- 定義をコピーしてデータをインサート
93+
```sql
94+
CREATE TABLE newtable LIKE oldtable;
95+
INSERT INTO newtable SELECT * FROM oldtable;
96+
```
97+
98+
- データ(と定義)を使ってコピー
99+
```sql
100+
CREATE TABLE newtable SELECT * FROM oldtable;
101+
```

0 commit comments

Comments
 (0)