[英]SQL adding composite primary key through alter table option
I have already created a table to the database. 我已经创建了一个数据库表。
Table is something like following (I am using sqlite on mac for iPhone dev) 表格如下所示(我在iPhone开发人员的Mac上使用sqlite)
create table
(
attendanceDate varchar,
studentNo integer,
absentDetail varchar
);
Now I have already committed this statements. 现在,我已经提交了此声明。 What I need is the following:
我需要的是以下内容:
I don't know the alter table syntax in sqlite3. 我不知道sqlite3中的alter table语法。
So, I need help. 所以,我需要帮助。
Thanks in advance. 提前致谢。
SQLITE3 does not have syntax to do what you want. SQLITE3没有语法可以执行所需的操作。
From the SQLITE documentation at http://www.sqlite.org/lang_altertable.html 从位于http://www.sqlite.org/lang_altertable.html的SQLITE文档中
SQLite supports a limited subset of ALTER TABLE.
SQLite支持ALTER TABLE的有限子集。 The ALTER TABLE command in SQLite allows the user to rename a table or to add a new column to an existing table.
SQLite中的ALTER TABLE命令允许用户重命名表或向现有表添加新列。 It is not possible to rename a colum, remove a column, or add or remove constraints from a table.
无法重命名列,删除列或在表中添加或删除约束。
You will need to recreate the table with the composite primary key and foreign key defined. 您将需要使用定义的复合主键和外键重新创建表。
I got the solution, By R&D. 通过研发,我找到了解决方案。
I think, I should drop my table & recreate the table by following syntax, 我认为,我应该删除表并按照以下语法重新创建表,
That will work as what I needed. 那将按我的需要工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.