database-table

What is table partitioning?

人走茶凉 提交于 2019-12-03 08:22:06
问题 In which case we should use table partitioning? 回答1: Partitioning enables tables and indexes or index-organized tables to be subdivided into smaller manageable pieces and these each small piece is called a "partition". For more info: Partitioning in Oracle. What? Why? When? Who? Where? How? 回答2: An example may help. We collected data on a daily basis from a set of 124 grocery stores. Each days data was completely distinct from every other days. We partitioned the data on the date. This

SELECT data FROM two tables in MySQL

泄露秘密 提交于 2019-12-03 06:12:58
What I have: The next structure: table_zero -> id (PRIMARY with auto increment) -> other table_1 -> id (foreign key to table zero id) -> varchar(80) Example value: (aahellobbb) -> one_field table_2 -> id (foreign key to table zero id) -> varchar(160) Example value: (aaececehellobbb) -> other_field What I want: Search and get an (id,varchar) array containing all matches with the LIKE '%str%' on the varchar field. For example, if I search with the "hello" string, then I should get both example values with their respective ids. These ids are always going to be different, since they are references

How can I list all tables in a database with Squirrel SQL?

跟風遠走 提交于 2019-12-03 04:57:12
I use Squirrel SQL to connect to a JavaDB/Derby database on my desktop. I can run SQL queries. But how can I list all tables in the database? And preferably all column and column types. You can do it easily from the GUI. After you open your session, click the Objects tab, then expand the tree. Expand the db, schema, and then table nodes, and you'll see all of your tables. If you click on a particular table node, a table will open to the right. By clicking the Columns tab, you can get the column names, types, and other meta data. Or are you looking for SQL commands? Sometimes I noticed that

PHP MySQL search with multiple criteria

白昼怎懂夜的黑 提交于 2019-12-02 08:31:44
问题 I have a search form in a website and would like to have several search terms which is input by the user to perform db search, terms as below: Keywords Property For (Sale, Rent...) Property Type (Apartment, Terrace House...) State Min Price Max Price Here is script to perform search with above term's input public function get_property_list_by_search($start, $per_page, $keyword, $prop_for, $min, $state, $ptype, $max, $mysqli) { if(empty($start) && empty($per_page)) { return 0; } $start = preg

MySQL Error 1 (HY000) Trouble creating file Errcode 2

左心房为你撑大大i 提交于 2019-11-29 12:10:43
I'm having issues creating a table for my ruby on rails app. It's driving me crazy! The following is returned when I try to create the table: ERROR 1 (HY000): Can't create/write to file '/usr/local/mysql/data/test_development/users.MYI' (Errcode: 2) It's worth mentioning I'm a total newbie, btw. This forum post seems to deal with the same problem: Try the following: mkdir /var/lib/mysql/tmp chown mysql:mysql /var/lib/mysql/tmp Add the following line into the [mysqld] section: tmpdir = /var/lib/mysql/tmp Restart the server I hope you got this resolved as it has been a year. But I just ran into

What is the difference between a schema and a table and a database?

 ̄綄美尐妖づ 提交于 2019-11-28 14:59:01
This is probably a n00blike (or worse) question. But I've always viewed a schema as a table definition in a database. This is wrong or not entirely correct. I don't remember much from my database courses. schema : database : table :: floor plan : house : room A relation schema is the logical definition of a table - it defines what the name of the table is, and what the name and type of each column is. It's like a plan or a blueprint. A database schema is the collection of relation schemas for a whole database. A table is a structure with a bunch of rows (aka "tuples"), each of which has the

How to reduce size of SQL Server table that grew from a datatype change

回眸只為那壹抹淺笑 提交于 2019-11-28 06:25:03
I have a table on SQL Server 2005 that was about 4gb in size. (about 17 million records) I changed one of the fields from datatype char(30) to char(60) (there are in total 25 fields most of which are char(10) so the amount of char space adds up to about 300) This caused the table to double in size (over 9gb) I then changed the char(60) to varchar(60) and then ran a function to cut extra whitespace out of the data (so as to reduce the average length of the data in the field to about 15) This did not reduce the table size. Shrinking the database did not help either. Short of actually recreating

Copy a table from one database to another in Postgres

别说谁变了你拦得住时间么 提交于 2019-11-28 02:34:16
I am trying to copy an entire table from one database to another in Postgres. Any suggestions? Extract the table and pipe it directly to the target database: pg_dump -t table_to_copy source_db | psql target_db You can also use the backup functionality in pgAdmin II. Just follow these steps: In pgAdmin, right click the table you want to move, select "Backup" Pick the directory for the output file and set Format to "plain" Click the "Dump Options #1" tab, check "Only data" or "only Schema" (depending on what you are doing) Under the Queries section, click "Use Column Inserts" and "User Insert

SQL DROP TABLE foreign key constraint

十年热恋 提交于 2019-11-27 16:45:36
If I want to delete all the tables in my database like this, will it take care of the foreign key constraint? If not, how do I take care of that first? GO IF OBJECT_ID('dbo.[Course]','U') IS NOT NULL DROP TABLE dbo.[Course] GO IF OBJECT_ID('dbo.[Student]','U') IS NOT NULL DROP TABLE dbo.[Student] marc_s No, this will not drop your table if there are indeed foreign keys referencing it. To get all foreign key relationships referencing your table, you could use this SQL (if you're on SQL Server 2005 and up): SELECT * FROM sys.foreign_keys WHERE referenced_object_id = object_id('Student') and if

Table Scan and Index Scan in SQL

半腔热情 提交于 2019-11-27 15:13:02
问题 What is the difference between Table scan and Index scan in SQL and where it is used specifically? 回答1: Table scan means iterate over all table rows. Index scan means iterate over all index items, when item index meets search condition, table row is retrived through index. Usualy index scan is less expensive than a table scan because index is more flat than a table. They are lot of bibliografy about this issue. Sample: Microsoft: Which is Faster: Index Access or Table Scan?: Index access is