鍍金池/ 問答/ 數(shù)據(jù)庫問答
柚稚 回答

你就簡單理解為export是導(dǎo)出一個變量,而不是導(dǎo)出它的值。外面的程序使用這個變量訪問到它導(dǎo)出的值。

var m = 1;
export m;

之所以這句是錯的,是因為它導(dǎo)出的是m的值,而不是m。

命于你 回答

clipboard.png

用instanceof判斷。然后取出數(shù)據(jù)。再執(zhí)行公共方法
直接泛型就搞定了

有點壞 回答

圖片描述


    class User {
        private String country;
        private String province;
        private String name;

        public User(String country, String province, String name) {
            this.country = country;
            this.province = province;
            this.name = name;
        }

        public String getCountry() {
            return country;
        }

        public void setCountry(String country) {
            this.country = country;
        }

        public String getProvince() {
            return province;
        }

        public void setProvince(String province) {
            this.province = province;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
    class Res {
        private String country;
        private String province;
        private Integer count;

        public Res(String country, String province, Integer count) {
            this.country = country;
            this.province = province;
            this.count = count;
        }

        public String getCountry() {
            return country;
        }

        public void setCountry(String country) {
            this.country = country;
        }

        public String getProvince() {
            return province;
        }

        public void setProvince(String province) {
            this.province = province;
        }

        public Integer getCount() {
            return count;
        }

        public void setCount(Integer count) {
            this.count = count;
        }
    }

    @Test
    public void test1() throws Exception {
        List<Res> result = new ArrayList<>();

        List<User> list = new ArrayList<>();
        list.add(new User("中國", "北京", "張三"));
        list.add(new User("中國", "北京", "張三"));
        list.add(new User("中國", "北京", "李四"));
        list.add(new User("中國", "北京", "李四"));
        list.add(new User("中國", "北京", "李四"));
        list.add(new User("中國", "北京", "王五"));
        list.add(new User("中國", "湖南", "張三"));
        list.add(new User("中國", "湖南", "張三"));
        list.add(new User("中國", "湖南", "張三"));

        list.stream()
                .collect(Collectors.groupingBy(e -> e.getProvince()))
                .forEach((k, v) -> {
                    StringBuilder count = new StringBuilder("0");
                    v.stream().
                            collect(Collectors.groupingBy(e -> e.getName()))
                            .forEach((k2, v2) -> {
                                if (v2.size() > 1) {
                                    int c = Integer.parseInt(count.toString());
                                    count.delete(0, count.length());
                                    count.append(c + v2.size());
                                }
                            });
                    result.add(new Res(v.get(0).getCountry(), v.get(0).getProvince(), Integer.parseInt(count.toString())));
                    count.delete(0, count.length());
                });
        System.out.println(new ObjectMapper().writeValueAsString(result));
    }

StringBuilder只是起了一個計數(shù)的作用, 雖然有點low~

吃藕丑 回答

select ip,devname,F.faultCode等
from (原來的查詢語句)
where ip like '%模糊條件%'
and devname like '%模糊條件%';

傲嬌范 回答

InnoDB聚集索引是按照主鍵(primary key)進行聚集的,每張表只能有一個聚集索引,表數(shù)據(jù)文件本身就是按B+Tree組織的一個索引結(jié)構(gòu),葉子節(jié)點的data域保存了完整的數(shù)據(jù)記錄;所以說,InnoDB表數(shù)據(jù)文件本身就是主索引文件,也就是你剛剛說的“同一個結(jié)構(gòu)中保存了 B+Tree 索引和數(shù)據(jù)行”。聚集索引的方式會使根據(jù)主鍵的范圍查找和排序非??欤▍⒖季奂饕臄?shù)據(jù)結(jié)構(gòu))。

InnoDB輔助索引的實現(xiàn)方式是所有輔助索引都引用主鍵作為data域,因此輔助索引搜索需要檢索兩次索引才能獲得數(shù)據(jù)記錄,但是這樣輔助索引的變更會很方便(不會影響根據(jù)主索引組織的數(shù)據(jù)文件本身),同時因為所有的輔助索引都引用主索引,不建議主索引過大。

不討囍 回答

1、刪除今天以前的數(shù)據(jù),那是說每天凌晨刪除昨天數(shù)據(jù)即可,你一天就1000W?刪除也不需要排序,直接delete from table where 。。 limit 1000即可。另外也可以每次刪除更少量的數(shù)據(jù),避免產(chǎn)生鎖,執(zhí)行頻率高一點就行。
2、也可以采用分區(qū)的方式,按天分區(qū),每天刪除過期分區(qū)表

大濕胸 回答

參考文檔serverStatus,對每個輸出結(jié)果項都有詳細說明。mappedmappedWithJournal只針對MMAPv1引擎有效

Only for the MMAPv1 storage engine.

3.2以后默認的存儲引擎是WiredTiger,所以這兩個值一直為0。
至于映射方式,MMAPv1使用的就是Linux操作系統(tǒng)的內(nèi)存映射,篇幅所限沒法在這里解釋,不過網(wǎng)上已經(jīng)有很多相關(guān)的資料。

舊時光 回答

像做網(wǎng)站一樣用ruby或者其他語言做server來鏈接R

陌南塵 回答
  1. 通過定位設(shè)備(手機等)獲取配送員的定位數(shù)據(jù)(經(jīng)緯度)上傳到 服務(wù)器,可以使用workerman 的websocket連接通訊。
  2. 另外再起一個websoctet監(jiān)聽端口與用戶之間的通訊,將獲取到的定位數(shù)據(jù)廣播給所有連接的用戶
  3. 頁面上可以使用高德地圖,百度地圖等對外的api接入,形成一條軌跡線,點等都是可以的。

基本的過程就是這樣。

不舍棄 回答

會有影響的、

更別說你百萬級的數(shù)據(jù)

之前有位前輩也問過一樣的問題

》》詳情《《

北城荒 回答
Db::table('think_user')->where('status', 1)->whereOr('status', 2)->select()
老梗 回答

用戶的唯一標識 是openid或者uid 你這樣區(qū)分是對的。

九年囚 回答

1.你的表里面已經(jīng)有有xpm字段了.就不用增加字段了吧.

添加字段 alter table totaltable add xpm int

2.現(xiàn)在你表中的xpm是沒有數(shù)據(jù)的.你想把數(shù)據(jù)填充進來.

如果學生不多,你可以手動添加.(利用軟件)
數(shù)量足夠多,那么你就把數(shù)據(jù)整理好.生產(chǎn)sql.重新添加
老梗 回答

mysqli::store_result
手機隨手翻的……
其實你直接去翻函數(shù)參考里的Mysql分類,然后再去mysqli里頭找方法就能找到了。

法克魷 回答

MySQL 里面有auto_increment 自增字段,PostgreSQL 沒有自增字段這一說法,但是有單獨的對象:序列。 可以用序列或者其他方法來是實現(xiàn)這樣的語法?;蛘咴O(shè)置某一列的默認值為sequence的值即可

在字段默認值里設(shè) nextval('products_product_no_seq')即可。
創(chuàng)建sequence參見https://www.postgresql.org/do...

CREATE SEQUENCE products_product_no_seq START 101;
CREATE TABLE products (
    product_no integer DEFAULT nextval('products_product_no_seq'),
    ...
);
風畔 回答

oplog只會記錄變化的部分,沒有選項可以選擇不同的模式。Change stream是基于oplog的,所以其實它也只能給到變化的部分。Full Document模式給你的是經(jīng)過查詢之后得到的大多數(shù)節(jié)點上提交過的這個文件的版本。如果有其他操作夾在更新和這次讀取之間,你得到的可能會是后一次更新之后的文檔。這點在文檔里有描述:Look Full Document for Update Operations

If there are one or more majority-committed operations that modified the updated document after the update operation but before the lookup, the full document returned may differ significantly from the document at the time of the update operation.

不知道你的具體場景是什么,知道具體場景可能還可以進一步探討其他解決方案。

伴謊 回答
  1. where條件是zzz,select的字段只有xxx,如果表數(shù)量不大,使用base索引的全掃描可能效率最高。
  2. Using where; Using index的意思是使用了索引覆蓋,但需要根據(jù)where條件對索引進行過濾,但仍不需要回表查詢數(shù)據(jù)。
萌吟 回答

mysql查詢優(yōu)化器認為全表掃描時如果速度大于使用索引,就會不用索引,你可以使用FORCE INDEX強制mysql使用索引

艷骨 回答

先不說用什么數(shù)據(jù)庫,書籍這種資源類的東西,我會以文件的形式,保存到硬盤的,而不是直接保存在數(shù)據(jù)庫里,保存在數(shù)據(jù)庫,只是一個文件物理地址。