开发者

How do I write this Django model in SQL?

I want to create a new column. How do I write this in SQL?

class mytable(models开发者_JAVA技巧.Model):
    created_at = models.DateTimeField(auto_now_add=True)


If you don't want to use South to manage this automatically - which is highly recommended, by the way - you can easily see what SQL you need by running ./manage.py sqlall <appname>. This will show you all the SQL to create the models in your app, so you can find the definition of your new field there.


ALTER TABLE mytable
  ADD created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜