这是我的表的架构:
create table LPCG(ID integer primary key, PCG text, Desc text, test text);
Run Code Online (Sandbox Code Playgroud)
我希望删除列"test",因此使用命令:
alter table LPCG drop column test;
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误消息:
Error: near "drop": syntax error
Run Code Online (Sandbox Code Playgroud)
有人可以帮我纠正我的错误吗?
另一个问题是:我理解ID是主要的键属性.我可以删掉那个专栏吗?如果没有,是否有人使用过的解决方法?
在此先感谢您的帮助.
可能重复:
Postgres DB上的整数超出范围
当我的代码尝试将大数字插入100001857905525到heroku的数据库中时,我收到错误:
ActiveRecord::StatementInvalid (PGError: ERROR: integer out of range )
Run Code Online (Sandbox Code Playgroud)
该列已定义为整数.我使用sqlite3数据库.我的代码部署到heroku.
我在localhost上运行时工作正常.但是只有在heroku上运行代码时才会出现上述错误.也许我可以通过将列定义为长整数或双精度来解决问题.我如何在Ruby/Rails中执行此操作?
import sqlite3
class class1:
def __init__(self):
self.print1()
def print1(self):
con = sqlite3.connect('mydb.sqlite')
cur = con.cursor()
cur.execute("select fname from tblsample1 order by fname")
ar=cur.fetchall()
print(ar)
class1()
Run Code Online (Sandbox Code Playgroud)
给出如下所示的输出
[(u'arun',), (u'kiran',), (u'kulku',), (u'sugu',)]
Run Code Online (Sandbox Code Playgroud)
我需要从数组中删除你,我需要输出如下所示
['arun', 'kiran', 'kulku', 'sugu']
Run Code Online (Sandbox Code Playgroud) sqlite> SELECT * FROM RawResponseTimes WHERE CreationTime <= 2011-06-14 17:17:23;
Error: near ":17": syntax error
Run Code Online (Sandbox Code Playgroud)
一切似乎都很好,但是对小时17不满意,是什么给出的?
使用SQLite.
如果我插入重复的行,Android的SQLite库如何解决冲突?我正在为API级别7构建我的应用程序,遗憾的是,它没有SQLiteDatabase.insertOnConflict()从API级别8开始包含的方法.
我正在尝试在我的帐户上安装sqlite3-ruby gem(版本1.3.4)(共享主机上的CentOS,所以我需要在没有root的情况下安装它)并且安装的sqlite版本对于更新的版本来说不够新sqlite3-ruby,所以我需要在我的帐户下编译库.我使用的sqlite版本是1.7.0,因为我发现更新版本存在问题.
我已经完成了这项工作 - 我下载了sqlite-3.7.0.tar.gz并按如下方式安装:
./configure –prefix=$HOME
make && make install
Run Code Online (Sandbox Code Playgroud)
然后去了我的rails 3应用程序并执行以下操作:
bundle config build.sqlite3-ruby “--with-sqlite3-include=$HOME/include --with-sqlite3-lib=$HOME/lib”
Run Code Online (Sandbox Code Playgroud)
然后:
bundle install --path vendor/bundle
Run Code Online (Sandbox Code Playgroud)
但是,我得到以下内容,我的软件包无法完全安装:
Installing sqlite3 (1.3.4) with native extensions /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:533:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/usr/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... no
checking for sqlite3_initialize()... no
checking for sqlite3_backup_init()... no
checking for sqlite3_column_database_name()... no
checking for sqlite3_enable_load_extension()... no
checking for sqlite3_load_extension()... no
creating Makefile
make
gcc …Run Code Online (Sandbox Code Playgroud) 我是一个更新的rails和SQLite.
这是我的方案:我已经sqlite3在我的Windows Vista机器上安装了.博客应用程序代码也已在实施c:\rails\blog.我提出了我的命令提示并直接进入c:\rails\blog\db.我运行命令sqlite3进入数据库控制台.当我使用该.databases命令时,没有列出任何数据库?为什么?我做错了什么?
首先,如果我错了,请纠正我,但是如果你关闭数据库连接,你不能使用你从中得到的光标,对吗?
db.open();
Cursor c = db.query(true, "MyTable", columns, null, null, null, null, null, null);
db.close();
// The Cursor is empty now because the db was closed...
c.moveToNext();
Log.v(TAG, c.toString(0));
Run Code Online (Sandbox Code Playgroud)
那么在关闭数据库后有没有办法使用Cursor?就像有没有办法将它传递到其他地方并使用它有点像一个对象?或者,在完成光标操作之前,您是否始终保持数据库连接处于打开状态?
我已经阅读了SQLite create table语句的相当酷的BNF语法
在这里找到:http://www.sqlite.org/lang_createtable.html
我想知道如何在这些之间创建链接表
我有一张桌子,比方说,房子和另一个electric_items.
我想创建一个链接表,将house_id和item_id作为复合键,但我不知道我该怎么做,它似乎不允许主键成为外键?
注意我想要第三个字段pap_tested,它存储房子中电子项目的日期是pap_tested,所以这个链接表通过复合主键似乎是最好的方法.
在我按问题描述之前,我想指出我知道其他线程提出这个问题,但是我没有能够解决我的问题.
我一直在使用BumpAPI开发一个共享应用程序,它在接收到块时将其保存到SQLite数据库以便在列表视图活动中进行检索,这一切都正常工作并保存数据,但是如果相同的文本是发送两次它将一次又一次保存,列表视图将显示这一点,从我读过的我需要'UNIQUE'标识符?但是对于SQL来说是全新的我在实现这个方面感到茫然,这是我的DataHelper类,我用来创建和添加条目,是否有人可以修改它或告诉我一个可能的解决方案?
非常感谢
public class DataHelper {
private static final String DATABASE_NAME = "tags.db";
private static final int DATABASE_VERSION = 1;
private static final String TABLE_NAME = "TagTable";
private Context context;
private SQLiteDatabase db;
private SQLiteStatement insertStmt;
private static final String INSERT = "insert into "
+ TABLE_NAME + "(name) values (?)";
public DataHelper(Context context) {
this.context = context;
OpenHelper openHelper = new OpenHelper(this.context);
this.db = openHelper.getWritableDatabase();
this.insertStmt = this.db.compileStatement(INSERT);
}
public long insert(String name) {
this.insertStmt.bindString(1, name);
return this.insertStmt.executeInsert(); …Run Code Online (Sandbox Code Playgroud) sqlite ×10
android ×3
java ×2
ruby ×2
alter-table ×1
create-table ×1
cursor ×1
heroku ×1
primary-key ×1
python ×1
sdk ×1
sql ×1