0001 function primary_key = mysql_table_key(table,conn_id)
0002
0003
0004
0005
0006
0007
0008
0009 try
0010 conn_id;
0011 catch
0012 conn_id= 0;
0013 end
0014
0015 mysql_check_conn(conn_id,'open');
0016
0017 [tableDescription{1:6}] = mysql(conn_id,sprintf('describe %s',table));
0018
0019
0020 keyType = tableDescription{4};
0021
0022 primaryIdxs = strmatch('PRI',keyType);
0023
0024 if(length(primaryIdxs) == 1)
0025 primary_key = tableDescription{1}{primaryIdxs};
0026 else
0027 primary_key = tableDescription{1}(primaryIdxs);
0028 end