MySQL基礎-建立資料庫和表,mysql資料庫

來源:互聯網
上載者:User

MySQL基礎-建立資料庫和表,mysql資料庫

MySQL基礎-建立資料庫和表

顯示資料庫一覽show databases; (SQL命令本身不區分大小寫)

mysql> show databases;

Database

information_schema

mysql

test

小結:information_schema資料庫又稱資訊架構,管理從表開始的資料庫組成資訊,以及使用者管理資訊的檢索專用的資料庫。確認這些資料庫內容就可以掌握現在資料庫的狀態。不可在mysql和information_shema資料庫中儲存使用者經常使用的資料。最後的test資料庫是測試用的資料庫,安裝mysql會自動建立test資料庫,資料庫本身是空的。



mysql 在B資料庫下 建立一個與A資料庫中一樣的表

create table B.test as select * from A.test;--------------結構,資料內容一致,但是不會複製索引以及外鍵
所以分兩步:
1:create table B.test like A.test;-------複製表結構
2:insert into B.test select * from A.test;----------複製資料
 
MYsql資料庫怎建立表?

CREATE DATABASE cookbook; 建立一個叫“cookbook”的資料庫

USE cookbook; 使用cookbook這個資料庫
CREATE TABLE limbs (thing VARCHAR(20),legs INT,arms INT); 建立表“limbs”其中包括thing,legs,aems 欄位
建立表的命令是 CREATE TABLE 表名稱
後面括弧裡的內容是表中欄位的屬性
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.