樹心幽徑

« 20180609在ubuntu用c列出mysql ilvssell資料庫三個資料表的內容 | Main | 20180611在GTK視窗上建立二個Widget控制項(一個text,一個label或二個label) »

20180610在ubuntu用c在mysql ilvssell資料庫建立資料表new_id_reg
2018/06/10,09:56

(1) t10.c

:

  if (mysql_query(con, "DROP TABLE IF EXISTS new_id_reg"))
  {
      fprintf(stderr, "%s\n", mysql_error(con));
      mysql_close(con);
      exit(1);
  }
  printf("DROP TABLE new_id_reg ok!\n");

 mysql_query(con, "set names utf8");

 char st[]="CREATE TABLE new_id_reg(sta_no char(1),inday char(20) default '2018-08-08 08:08:08',custno char(10) default '818818',money_store int default 0, saleno char(10) default '-' ,remain int default 0,serial char(20) primary key,oldremain int default 0) ";
  printf("Prepare %s\n", st);

  if (mysql_query(con, st))
  {
      fprintf(stderr, "%s\n", mysql_error(con));
      mysql_close(con);
      exit(1);
  }
  printf("Execute ok!  %s\n", st);

:

(2)

treehrt@treehrt-fire:~/mysqlc$ gcc t10.c `mysql_config --cflags --libs`
treehrt@treehrt-fire:~/mysqlc$ ./a.out
MySQL client version: 5.7.22
DROP TABLE new_id_reg ok!
Prepare CREATE TABLE new_id_reg(sta_no char(1),inday char(20) default '2018-08-08 08:08:08',custno char(10) default '818818',money_store int default 0, saleno char(10) default '-' ,remain int default 0,serial char(20) primary key,oldremain int default 0)
Execute ok! 

 

迴響

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType