亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    MySQL如何操作數(shù)據(jù)表

    MySQL操作數(shù)據(jù)表的方法并不復雜,下面將為您詳細介紹MYSQL添加字段、修改字段、刪除字段、 獲取表名等操作的實現(xiàn)方法,希望對您學習MySQL添加字段方面會有所幫助。

    MySQL如何操作數(shù)據(jù)表

    MySQL添加字段的方法并不復雜,下面將為您詳細介紹MYSQL添加字段和修改字段等操作的實現(xiàn)方法,希望對您學習MySQL添加字段方面會有所幫助。

    1添加表字段

    alter table table1 add transactor varchar(10) not Null; alter table   table1 add id int unsigned not Null auto_increment primary key

    添加到特定字段后面的語句例子:

    ALTER TABLE <表名> ADD <新字段名><數(shù)據(jù)類型>[約束條件]; ALTER TABLE MyTableName ADD newDBField varchar(30) NULL AFTER existDBField; ALTER TABLE tableName001 ADD WebAdminPass varchar(30) NULL AFTER Result;

    2.修改某個表的字段類型及指定為空或非空

    alter table 表名稱 change 字段名稱 字段名稱 字段類型 [是否允許非空]; alter table 表名稱 modify 字段名稱 字段類型 [是否允許非空]; alter table 表名稱 modify 字段名稱 字段類型 [是否允許非空];

    3.修改某個表的字段名稱及指定為空或非空

    alter table 表名稱 change 字段原名稱 字段新名稱 字段類型 [是否允許非空

    4如果要刪除某一字段,可用命令:

    ALTER TABLE mytable DROP 字段名;

    mysql SQL獲取表名&字段名的查詢語句

    1:查詢數(shù)據(jù)庫中所有表名

    select table_name   from information_schema.tables   where table_schema='csdb' and table_type='base table'; table_schema:數(shù)據(jù)庫名稱      information_schema 表示系統(tǒng)庫。    table_type='base table‘:限定只查詢基表。

    2:查詢指定數(shù)據(jù)庫中指定表的所有字段名column_name

       select column_name      from information_schema.columns      where table_schema='csdb' and table_name='users';   table_schema:數(shù)據(jù)庫名      table_name:表名

    工作用到例子:

    select count(*) from information_schema.columns where table_schema='yanfa' and table_name='tableName001' and column_name='Result1';  #select table_name from information_schema.tables where table_schema='yanfa' and table_type='base table';

    相關學習推薦:mysql教程(視頻)

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號