derby mysql 同步_[Derby]数据库操作说明
1. 創建新數據庫
connect 'jdbc:derby:mydb;create=true';
ij> connect 'jdbc:derby:mydb;create=true';
ij>
將在當前目錄下建立數據庫目錄 mydb;如果已經存在數據庫 mydb,則提示:
警告 01J01:未創建數據庫"mydb",而是建立到現有數據庫的連接。
ij> connect 'jdbc:derby:mydb;create=true';
警告 01J01:未創建數據庫"mydb",而是建立到現有數據庫的連接。
ij>
2. 創建新表/刪除表
create table mytable(number varchar(4), name varchar(10), age int, address varchar(40));
ij> create table mytable(number varchar(4), name varchar(10), age int, address varchar(40));
已插入/更新/刪除 0 行
ij>
//刪除整個表
drop table mytable;
ij> drop table mytable;
已插入/更新/刪除 0 行
ij>
3. 表中添加數據
ij> insert into mytable values('1001', 'one', 20, 'street 1');
已插入/更新/刪除 1 行
ij> insert into mytable values('1002', 'two', 22, 'street 2');
已插入/更新/刪除 1 行
ij> select * from mytable;
NUM&|NAME????? |AGE??????? |ADDRESS
--------------------------------------------------------------------
1001|one??????? |20???????? |street 1
1002|two??????? |22???????? |street 2
已選擇 2 行
4. 查看表
show tables;
ij> show tables;
TABLE_SCHEM???????? |TABLE_NAME??????????????????? |REMARKS
------------------------------------------------------------------------
SYS???????????????? |SYSALIASES?????????????????? |
SYS???????????????? |SYSCHECKS??????????????????? |
SYS???????????????? |SYSCOLPERMS??????????????????? |
SYS???????????????? |SYSCOLUMNS???????????????????? |
SYS???????????????? |SYSCONGLOMERATES???????????? |
SYS???????????????? |SYSCONSTRAINTS?????????????? |
SYS???????????????? |SYSDEPENDS??????????????????? |
SYS???????????????? |SYSFILES????????????????????? |
SYS???????????????? |SYSFOREIGNKEYS??????????????? |
SYS???????????????? |SYSKEYS?????????????????????? |
SYS???????????????? |SYSROUTINEPERMS?????????????? |
SYS???????????????? |SYSSCHEMAS??????????????????? |
SYS???????????????? |SYSSTATEMENTS???????????????? |
SYS???????????????? |SYSSTATISTICS???????????????? |
SYS???????????????? |SYSTABLEPERMS???????????????? |
SYS???????????????? |SYSTABLES???????????????????? |
SYS???????????????? |SYSTRIGGERS?????????????????? |
SYS???????????????? |SYSVIEWS????????????????????? |
SYSIBM????????????? |SYSDUMMY1???????????????????? |
APP???????????????? |MYTABLE?????????????????????? |
最后一個是我們自己創建的表 MYTABLE
5. 查看表的結構
describe mytable;
ij> describe mytable;
COLUMN_NAME???????? |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&
------------------------------------------------------------------------------
NUMBER????????????? |VARCHAR |NULL|NULL|4???? |NULL????? |8???????? |YES
NAME??????????????? |VARCHAR |NULL|NULL|10??? |NULL????? |20??????? |YES
AGE???????????????? |INTEGER |0?? |10 |10??? |NULL????? |NULL????? |YES
ADDRESS???????????? |VARCHAR |NULL|NULL|40??? |NULL????? |80??????? |YES
已選擇 4 行
ij>
6. 表中添加數據
insert into mytable values('1001', 'one', 20, 'street 1');
insert into mytable values('1002', 'two', 22, 'street 2');
ij> insert into mytable values('1001', 'one', 20, 'street 1');
已插入/更新/刪除 1 行
ij> insert into mytable values('1002', 'two', 22, 'street 2');
已插入/更新/刪除 1 行
ij>
7. 查詢數據
select * from mytable;
select number, name from mytable;
ij> select * from mytable;
NUM&|NAME????? |AGE??????? |ADDRESS
--------------------------------------------------------------------
1001|one?????? |20???????? |street 1
1002|two?????? |22???????? |street 2
已選擇 2 行
ij> select number, name from mytable;
NUM&|NAME
---------------
1001|one
1002|two
已選擇 2 行
8. 更新數據
update mytable set name = 'one_one' where number = '1001';
ij> update mytable set name = 'one_one' where number = '1001';
已插入/更新/刪除 1 行
ij> select * from mytable;
NUM&|NAME????? |AGE??????? |ADDRESS
--------------------------------------------------------------------
1001|one_one?? |20???????? |street 1
1002|two?????? |22???????? |street 2
已選擇 2 行
ij>
9. 刪除表中數據,保留表格式
delete from mytable where name = 'two';
delete from mytable;
ij> delete from mytable where name = 'two';
已插入/更新/刪除 1 行
ij> select * from mytable;
NUM&|NAME????? |AGE??????? |ADDRESS
--------------------------------------------------------------------
1001|one_one?? |20???????? |street 1
已選擇 1 行
ij> delete from mytable;
已插入/更新/刪除 1 行
ij> select * from mytable;
NUM&|NAME????? |AGE??????? |ADDRESS
--------------------------------------------------------------------
已選擇 0 行
ij> describe mytable;
COLUMN_NAME???????? |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&
------------------------------------------------------------------------------
NUMBER????????????? |VARCHAR |NULL|NULL|4???? |NULL????? |8???????? |YES
NAME??????????????? |VARCHAR |NULL|NULL|10??? |NULL????? |20??????? |YES
AGE???????????????? |INTEGER |0?? |10 |10??? |NULL????? |NULL????? |YES
ADDRESS???????????? |VARCHAR |NULL|NULL|40??? |NULL????? |80??????? |YES
已選擇 4 行
ij>
總結
以上是生活随笔為你收集整理的derby mysql 同步_[Derby]数据库操作说明的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 同时运行两个PHP吗,PHP-避免由两个
- 下一篇: java源代码实例倒计时_Java倒计时