create table tableF select * from tableA
怎么能在创建表的时候同时给tableF 建立 pk以及设定表的编码啊?

解决方案 »

  1.   

    create table tableF select * from tableA;
    alter table...
      

  2.   

    create table tableF select * from tableA;
    alter table tablef ADD [CONSTRAINT [symbol]]
            FOREIGN KEY [index_name] (index_col_name,...);
    alter table tablef CHARACTER SET charset_name 
      

  3.   

    先CREATE再ALTER并不能保证你的字符集设置。 事后的字符集设计修改仅对之后插入的记录有效。还是应该先创建表,然后再添加记录。create table tableF select * from tableA where 1<0;
    alter table tableF ADD PRIMARY KEY (id) CHARACTER SET 'gbk';
    insert into tableF  select * from tableA ;